effect-monad 0.8.0.0 → 0.8.1.0
raw patch · 6 files changed
+62/−6 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- effect-monad.cabal +1/−1
- examples/Inc.hs +35/−0
- examples/Reader.hs +1/−1
- examples/State.hs +8/−4
- examples/WriterM.hs +17/−0
- src/Control/Effect/ParameterisedAsGraded.hs +0/−0
effect-monad.cabal view
@@ -1,5 +1,5 @@ name: effect-monad-version: 0.8.0.0+version: 0.8.1.0 synopsis: Embeds effect systems and program logics into Haskell using graded monads and parameterised monads description: Provides the graded monad structure to Haskell via Control.Effect
+ examples/Inc.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PolyKinds #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE RebindableSyntax #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE TypeSynonymInstances #-}+module EffectsInHaskellProblem where++import Control.Effect+import Control.Effect.State+import GHC.TypeLits+import Prelude hiding (log, Monad(..), (>>))++varX :: Var "x"+varX = Var++inc :: State '["x" :-> Int :! 'RW] ()+inc =+ get varX >>= (put varX . (+1))++-- No instance for (Control.Effect.State.Nubable '["x" :-> (Int :! 'W)] '[])+inc2 =+ inc >>=+ \_ ->+ inc
examples/Reader.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE ImplicitParams, DataKinds, RebindableSyntax, TypeOperators, ScopedTypeVariables #-}+{-# LANGUAGE ImplicitParams, DataKinds, RebindableSyntax, TypeOperators, ScopedTypeVariables, FlexibleContexts #-} import Prelude hiding (Monad(..)) import Control.Effect import Control.Effect.Reader
examples/State.hs view
@@ -1,15 +1,19 @@-{-# LANGUAGE DataKinds, RebindableSyntax, TypeOperators, FlexibleInstances #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE RebindableSyntax #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE FlexibleInstances #-} import Prelude hiding (Monad(..)) import Control.Effect import Control.Effect.State -x_var = Var::(Var "x")-y_var = Var::(Var "y")+x_var = Var @ "x"+y_var = Var @ "y" {- Computation with a read effect on variable "x" and a read-write (update) effect on variable "y" -}--- example :: State '["x" :-> Int :! R, "y" :-> [Int] :! RW] [Int]++example :: State '["x" :-> Int :! R, "y" :-> [Int] :! RW] [Int] example = do x <- get x_var y <- get y_var
+ examples/WriterM.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE FlexibleInstances #-}++import Data.Monoid++data Writer w a = Writer { runWriter :: (a, w) }++instance Monoid w => Monad (Writer w) where+ return a = Writer (a, mempty)+ (Writer (a, w)) >>= k = let (b, w') = runWriter (k a)+ in Writer (b, w `mappend` w')++instance Monad (Writer (Maybe a)) where+ return a = Writer (a, Nothing)+ (Writer (a, w)) >>= k = let (b, w') = runWriter (k a)+ in case w' of + Nothing -> Writer (b, w)+ Just w' -> Writer (b, Just w')
src/Control/Effect/ParameterisedAsGraded.hs view