simple-sessions 0.1 → 0.1.1
raw patch · 4 files changed
+27/−26 lines, 4 filesdep +synchronous-channels
Dependencies added: synchronous-channels
Files
- Control/Concurrent/SimpleSession/Implicit.lhs +6/−4
- Control/Concurrent/SimpleSession/Positional.lhs +5/−4
- Control/Concurrent/SimpleSession/TChan.lhs +8/−13
- simple-sessions.cabal +8/−5
Control/Concurrent/SimpleSession/Implicit.lhs view
@@ -26,6 +26,7 @@ > import Control.Concurrent.SimpleSession.UChan > import Control.Monad.Indexed > import Control.Concurrent.SimpleSession.SessionTypes+> import Control.Monad (ap) } @@ -125,16 +126,17 @@ computations in the |IO| monad. > instance IxFunctor Session where-> imap f = undefined+> imap f m = Session (fmap f . unSession m) > > instance IxPointed Session where-> ireturn = undefined+> ireturn x = Session (const $ return x) > > instance IxApplicative Session where-> iap = undefined+> iap f x = Session (\r -> unSession f r `ap` unSession x r) > > instance IxMonad Session where-> ibind = undefined+> ibind k m = Session (\r -> unSession m r >>= \a ->+> unSession (k a) r) < instance IxMonad Session where < ret a = Session (\_ -> return a)
Control/Concurrent/SimpleSession/Positional.lhs view
@@ -25,6 +25,7 @@ > import Control.Concurrent.SimpleSession.TChan > import Control.Monad.Indexed > import Control.Concurrent.SimpleSession.SessionTypes+> import Control.Monad (ap) > > newtype Rendezvous r = Rendezvous (TChan UChan) >@@ -80,13 +81,13 @@ > newtype Session s s' a = Session { unSession :: IO a } > > instance IxFunctor Session where-> imap = undefined+> imap f = Session . fmap f . unSession > instance IxPointed Session where-> ireturn = undefined+> ireturn = Session . return > instance IxApplicative Session where-> iap = undefined+> iap (Session f) (Session x) = Session (f `ap` x) > instance IxMonad Session where-> ibind = undefined+> ibind k m = Session (unSession m >>= unSession . k) > > io :: IO a -> Session s s a > io = Session
Control/Concurrent/SimpleSession/TChan.lhs view
@@ -5,29 +5,24 @@ > TChan, newTChan, writeTChan, readTChan > ) where > -> import Control.Concurrent.MVar+> import Control.Concurrent.Chan.Synchronous } -An |TChan a| is a monomorphic, synchronous channel that can transmit-values of type |a|:+A |TChan a| is a monomorphic, synchronous channel that can transmit+values of type |a|. -> newtype TChan a+> type TChan a \ignore{ -> = CC (MVar (MVar a))+> = Chan a > -> newTChan = newEmptyMVar >>= return . CC+> newTChan = newChan > -> writeTChan (CC cc) v = do-> mv <- takeMVar cc-> putMVar mv v+> writeTChan = writeChan > -> readTChan (CC cc) = do-> mv <- newEmptyMVar-> putMVar cc mv-> takeMVar mv+> readTChan = readChan }
simple-sessions.cabal view
@@ -1,5 +1,5 @@ Name: simple-sessions-Version: 0.1+Version: 0.1.1 Cabal-Version: >= 1.2 License: BSD3 License-File: LICENSE@@ -12,9 +12,10 @@ Build-type: Simple Description: This library is based on the session types implementation- from "Haskell Session Types with Almost No Class," from the 2008- Haskell Symposium. For a full-featured session types library,- see the sessions package.+ from \"Haskell Session Types with (Almost) No Class,\" from+ the 2008 Haskell Symposium. For a full-featured session types+ library, see the sessions package+ (<http://hackage.haskell.org/cgi-bin/hackage-scripts/package/sessions>). Extra-Source-Files: TODO@@ -22,7 +23,9 @@ Control/Concurrent/SimpleSession/Examples/Positional.lhs Library- Build-Depends: base, category-extras+ Build-Depends: base,+ category-extras,+ synchronous-channels Exposed-modules: Control.Concurrent.SimpleSession.SessionTypes, Control.Concurrent.SimpleSession.Implicit,