packages feed

effect-monad 0.6 → 0.6.1

raw patch · 3 files changed

+7/−6 lines, 3 files

Files

effect-monad.cabal view
@@ -1,5 +1,5 @@ name:                   effect-monad-version:                0.6+version:                0.6.1 synopsis:               Embeds effect systems into Haskell using parameteric effect monads description:                Provides the 'parametric effect monad' structure to Haskell with a number of analogous of familiar monads (Reader, Writer, State, Maybe, Counter, Update) and a wrapper over normal monads (Control.Effect.Monad). This provides a way to embed effect systems into Haskell. For more information see with paper \"Embedding effect systems in Haskell\" by Orchard and Petricek <http://www.cl.cam.ac.uk/~dao29/publ/haskell14-effects.pdf> (Haskell, 2014) and the examples in <https://github.com/dorchard/effect-monad/tree/master/examples>. 
examples/State.hs view
@@ -7,8 +7,9 @@ x_var = Var::(Var "x") y_var = Var::(Var "y") + {- Computation with a read effect on variable "x" and a read-write (update) effect on variable "y" -}-foo :: State '["x" :-> Int :! R, "y" :-> [Int] :! RW] [Int]+-- foo :: State '["x" :-> Int :! R, "y" :-> [Int] :! RW] [Int] foo = do x <- get x_var          y <- get y_var          put y_var (x:y)@@ -17,9 +18,9 @@  foo_run = runState foo (Ext (x_var :-> (1 :! Eff)) (Ext (y_var :-> ([2,3] :! Eff)) Empty)) -foo2 :: State '["x" :-> Int :! RW] Int-foo2 = do x <- get x_var-          put x_var (x+1)+--foo2 :: State '["x" :-> Int :! RW] Int+foo2 = do x <- get (Var::(Var "x"))+          put (Var::(Var "x")) (x+1)           return x  foo2_run = (runState foo2) (Ext (x_var :-> 10 :! Eff) Empty)
src/Control/Effect/State.hs view
@@ -135,7 +135,7 @@ get _ = State $ \(Ext (v :-> (a :! _)) Empty) -> (a, Empty)  {-| Write to a variable 'v' with a value of type 'a'. Raises a write effect -}-put :: Var v -> a -> State '[k :-> a :! W] ()+put :: Var v -> a -> State '[v :-> a :! W] () put _ a = State $ \Empty -> ((), Ext (Var :-> a :! Eff) Empty)  {-| Captures what it means to be a set of state effects -}