opensoundcontrol-ht 0.1.1.2 → 0.2
raw patch · 5 files changed
+45/−101 lines, 5 filesdep ~binarydep ~hoscdep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: binary, hosc, transformers
API changes (from Hackage documentation)
- Sound.OpenSoundControl.Transport.Monad: class Monad m => C m
- Sound.OpenSoundControl.Transport.Monad: instance (Transport t, MonadIO io) => C (ReaderT t io)
- Sound.OpenSoundControl.Transport.Monad: recv :: C m => m OSC
- Sound.OpenSoundControl.Transport.Monad: send :: C m => OSC -> m ()
- Sound.OpenSoundControl.Transport.Monad: wait :: C m => String -> m OSC
- Sound.OpenSoundControl.Transport.Monad: waitFor :: C m => (OSC -> Maybe a) -> m a
- Sound.OpenSoundControl.Transport.Monad.ByteString: instance C T
- Sound.OpenSoundControl.Transport.Monad.IO: class Transport t
- Sound.OpenSoundControl.Transport.Monad.IO: recv :: C m => m OSC
- Sound.OpenSoundControl.Transport.Monad.IO: send :: C m => OSC -> m ()
- Sound.OpenSoundControl.Transport.Monad.IO: type T t = ReaderT t IO
- Sound.OpenSoundControl.Transport.Monad.IO: wait :: C m => String -> m OSC
- Sound.OpenSoundControl.Transport.Monad.IO: waitFor :: C m => (OSC -> Maybe a) -> m a
- Sound.OpenSoundControl.Transport.Monad.IO: with :: Transport t => IO t -> T t a -> IO a
+ Sound.OpenSoundControl.Transport.Monad.ByteString: data T a
+ Sound.OpenSoundControl.Transport.Monad.ByteString: instance DuplexOSC T
+ Sound.OpenSoundControl.Transport.Monad.ByteString: instance RecvOSC T
+ Sound.OpenSoundControl.Transport.Monad.ByteString: instance SendOSC T
- Sound.OpenSoundControl.Transport.File: open :: OSC -> FilePath -> IO T
+ Sound.OpenSoundControl.Transport.File: open :: Packet -> FilePath -> IO T
- Sound.OpenSoundControl.Transport.Monad.ByteString: run :: OSC -> T () -> ByteString
+ Sound.OpenSoundControl.Transport.Monad.ByteString: run :: Packet -> T () -> ByteString
Files
- opensoundcontrol-ht.cabal +13/−14
- src/Sound/OpenSoundControl/Transport/File.hs +10/−8
- src/Sound/OpenSoundControl/Transport/Monad.hs +0/−48
- src/Sound/OpenSoundControl/Transport/Monad/ByteString.hs +22/−11
- src/Sound/OpenSoundControl/Transport/Monad/IO.hs +0/−20
opensoundcontrol-ht.cabal view
@@ -1,25 +1,25 @@ Name: opensoundcontrol-ht-Version: 0.1.1.2+Version: 0.2 License: GPL License-File: LICENSE-Copyright: Henning Thielemann, 2009+Copyright: Henning Thielemann, 2009-2013 Author: Henning Thielemann <supercollider@henning-thielemann.de> Maintainer: Henning Thielemann <supercollider@henning-thielemann.de> Stability: Experimental Homepage: http://www.haskell.org/haskellwiki/SuperCollider Synopsis: Haskell OpenSoundControl utilities Description:- Some additional modules I regular use+ Some additional modules I use in connection with the SuperCollider wrapper hsc3 by Rohan Drape. It contains: .- * a @Transport@ type for writing to files (that's however less important, since @hsc3@ itself does now support SuperCollider Non-Real-Time mode)+ * a @Transport@ handle type for writing to files .- * a @Transport@ monad class that can be used to hide the handle of the SuperCollider connection, simulate communication without I\/O (e.g. testing) and maybe others.+ * a @Transport@ monad type for writing to a bytestring without IO. . Also see the supercollider-ht package which uses this one. Category: Sound-Tested-With: GHC==6.4.1, GHC==6.8.2+Tested-With: GHC==7.4.2 Cabal-Version: >=1.6 Build-Type: Simple Source-Repository head@@ -29,17 +29,19 @@ Source-Repository this type: darcs location: http://code.haskell.org/~thielema/opensoundcontrol/- tag: 0.1.1.2+ tag: 0.2 Flag splitBase description: Choose the new smaller, split-up base package. Library- Build-Depends: hosc >=0.1 && <0.9- Build-Depends: transformers >=0.2 && <0.4- Build-Depends: binary >=0.2 && <1, bytestring >=0.9 && <0.11- Build-Depends: utility-ht >=0.0.1 && <0.1+ Build-Depends:+ hosc >=0.13 && <0.14,+ transformers >=0.2 && <0.5,+ binary >=0.2 && <0.6,+ bytestring >=0.9 && <0.11,+ utility-ht >=0.0.1 && <0.1 If flag(splitBase) Build-Depends: random >=1.0 && <2,@@ -49,10 +51,7 @@ Build-Depends: base >=1.0 && <2 GHC-Options: -Wall- Extensions: GeneralizedNewtypeDeriving Hs-source-dirs: src Exposed-modules: Sound.OpenSoundControl.Transport.File- Sound.OpenSoundControl.Transport.Monad- Sound.OpenSoundControl.Transport.Monad.IO Sound.OpenSoundControl.Transport.Monad.ByteString
src/Sound/OpenSoundControl/Transport/File.hs view
@@ -1,25 +1,27 @@ module Sound.OpenSoundControl.Transport.File (T, open, ) where -import Sound.OpenSoundControl.Transport (Transport(..), )-import Sound.OpenSoundControl.Byte (encode_u32, )-import Sound.OpenSoundControl.OSC (encodeOSC, OSC, )+import qualified Sound.OpenSoundControl.Type as OSC+import Sound.OpenSoundControl.Coding.Byte (encode_u32, )+import Sound.OpenSoundControl.Class (encodeOSC, )+import Sound.OSC.Transport.FD (Transport(..), ) -import Control.Monad (liftM, ) import qualified Data.ByteString.Lazy as B import System.IO (Handle, openBinaryFile, hClose, IOMode(WriteMode), )+import Control.Monad (liftM, ) + -- | The File transport handle data type.-data T = Cons OSC Handle+data T = Cons OSC.Packet Handle deriving (Eq, Show) instance Transport T where- send (Cons _ h) msg =+ sendOSC (Cons _ h) msg = let b = encodeOSC msg n = fromIntegral (B.length b) in B.hPut h (B.append (encode_u32 n) b) - recv (Cons msg _) = return msg+ recvPacket (Cons msg _) = return msg close (Cons _ h) = hClose h @@ -29,6 +31,6 @@ Open a command file. All 'recv' calls are answered with @msg@. -}-open :: OSC -> FilePath -> IO T+open :: OSC.Packet -> FilePath -> IO T open msg fileName = liftM (Cons msg) $ openBinaryFile fileName WriteMode
− src/Sound/OpenSoundControl/Transport/Monad.hs
@@ -1,48 +0,0 @@-{- |-Monad class for monads that are able to do or simulate communication-via Open Sound Control.--}-module Sound.OpenSoundControl.Transport.Monad (- C, send, recv, waitFor, wait,- ) where--import qualified Sound.OpenSoundControl.Transport as Trans-import Sound.OpenSoundControl.Transport (Transport)-import Sound.OpenSoundControl.OSC (OSC(Message))--import Control.Monad.Trans.Reader (ReaderT(ReaderT))-import Control.Monad.IO.Class (MonadIO, liftIO, )--import Data.Maybe.HT (toMaybe, )---class Monad m => C m where- -- | Encode and send an OSC packet.- send :: OSC -> m ()- -- | Receive and decode an OSC packet.- recv :: m OSC--instance (Transport t, MonadIO io) => C (ReaderT t io) where- send osc = ReaderT $ liftIO . flip Trans.send osc- recv = ReaderT $ liftIO . Trans.recv----- Does the OSC message have the specified address.-hasAddress :: String -> OSC -> Bool-hasAddress x (Message y _) = x == y-hasAddress _ _ = False---- Repeat action until function does not give Nothing when applied to result.-untilM :: Monad m => (a -> Maybe b) -> m a -> m b-untilM f act =- let go = maybe go return . f =<< act- in go---- | Wait for an OSC message where the supplied function does not give--- Nothing, discarding intervening messages.-waitFor :: C m => (OSC -> Maybe a) -> m a-waitFor f = untilM f recv---- | A 'waitFor' for variant matching on address string of messages.-wait :: C m => String -> m OSC-wait s = waitFor (\o -> toMaybe (hasAddress s o) o)
src/Sound/OpenSoundControl/Transport/Monad/ByteString.hs view
@@ -1,33 +1,44 @@-module Sound.OpenSoundControl.Transport.Monad.ByteString (run, ) where+module Sound.OpenSoundControl.Transport.Monad.ByteString (T, run, ) where -import qualified Sound.OpenSoundControl.Transport.Monad as TM+import qualified Sound.OSC.Transport.Monad as TM -import Sound.OpenSoundControl.OSC (encodeOSC, OSC, )+import qualified Sound.OpenSoundControl.Type as OSC+import Sound.OpenSoundControl.Class (encodeOSC, ) +import qualified Data.ByteString.Lazy as B+import qualified Data.Binary.Put as Put+ import Control.Monad.Trans.Reader (ReaderT, runReaderT, ask, ) import Control.Monad.Trans.Class (lift, ) -import qualified Data.ByteString.Lazy as B-import qualified Data.Binary.Put as Put +newtype T a = Cons {decons :: ReaderT OSC.Packet Put.PutM a} -newtype T a = Cons (ReaderT OSC Put.PutM a)- deriving (Functor, Monad) +instance Functor T where+ fmap f (Cons act) = Cons $ fmap f act -instance TM.C T where- send msg = Cons $ lift $+instance Monad T where+ return = Cons . return+ Cons x >>= k =+ Cons $ decons . k =<< x+++instance TM.SendOSC T where+ sendOSC msg = Cons $ lift $ let b = encodeOSC msg in Put.putWord32be (fromIntegral (B.length b)) >> Put.putLazyByteString b - recv = Cons ask+instance TM.RecvOSC T where+ recvPacket = Cons ask +instance TM.DuplexOSC T where {- | Write sent messages to a ByteString. All 'recv' calls are answered with @msg@. -}-run :: OSC -> T () -> B.ByteString+run :: OSC.Packet -> T () -> B.ByteString run msg (Cons m) = Put.runPut (runReaderT m msg)
− src/Sound/OpenSoundControl/Transport/Monad/IO.hs
@@ -1,20 +0,0 @@-{- |-Run a generic Transport monad action in the IO monad-using the IO transport types, e.g. TCP, UDP, or File.--}-module Sound.OpenSoundControl.Transport.Monad.IO- (T, Transport, send, recv, wait, waitFor, with, ) where--import qualified Sound.OpenSoundControl.Transport as Trans-import Sound.OpenSoundControl.Transport.Monad (C, send, recv, wait, waitFor, )-import Sound.OpenSoundControl.Transport (Transport)--import Control.Monad.Trans.Reader (ReaderT(runReaderT))---type T t = ReaderT t IO----- | Bracket Open Sound Control communication.-with :: Transport t => IO t -> T t a -> IO a-with u = Trans.withTransport u . runReaderT