extensible-effects 2.6.3.0 → 3.0.0.0
raw patch · 23 files changed
+137/−35 lines, 23 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Control.Eff: class (FindElem t r) => Member (t :: * -> *) r
+ Control.Eff: class Member t r => SetMember (tag :: k -> * -> *) (t :: * -> *) r | tag r -> t
+ Control.Eff: data Eff r a
+ Control.Eff: run :: Eff '[] w -> w
+ Control.Eff.Extend: (^$) :: forall r b w. Arrs r b w -> Arr r b w
+ Control.Eff.Extend: (^|>) :: Arrs r a b -> Arr r b c -> Arrs r a c
+ Control.Eff.Extend: E :: (Union r b) -> (Arrs r b a) -> Eff r a
+ Control.Eff.Extend: Val :: a -> Eff r a
+ Control.Eff.Extend: arr :: (a -> b) -> Arrs r a b
+ Control.Eff.Extend: class (FindElem t r) => Member (t :: * -> *) r
+ Control.Eff.Extend: class Member t r => SetMember (tag :: k -> * -> *) (t :: * -> *) r | tag r -> t
+ Control.Eff.Extend: comp :: Arrs r a b -> Arrs r b c -> Arrs r a c
+ Control.Eff.Extend: data Arrs r a b
+ Control.Eff.Extend: data Eff r a
+ Control.Eff.Extend: data Union (r :: [* -> *]) v
+ Control.Eff.Extend: decomp :: Union (t : r) v -> Either (Union r v) (t v)
+ Control.Eff.Extend: first :: Arr r a b -> Arr r (a, c) (b, c)
+ Control.Eff.Extend: handle_relay :: (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff (t : r) a -> Eff r w
+ Control.Eff.Extend: handle_relay_s :: s -> (s -> a -> Eff r w) -> (forall v. s -> t v -> (s -> Arr r v w) -> Eff r w) -> Eff (t : r) a -> Eff r w
+ Control.Eff.Extend: ident :: Arrs r a a
+ Control.Eff.Extend: inj :: Member t r => t v -> Union r v
+ Control.Eff.Extend: interpose :: Member t r => (a -> Eff r w) -> (forall v. t v -> Arr r v w -> Eff r w) -> Eff r a -> Eff r w
+ Control.Eff.Extend: prj :: Member t r => Union r v -> Maybe (t v)
+ Control.Eff.Extend: qApp :: forall r b w. Arrs r b w -> Arr r b w
+ Control.Eff.Extend: qComp :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arr r' a c
+ Control.Eff.Extend: qComps :: Arrs r a b -> (Eff r b -> Eff r' c) -> Arrs r' a c
+ Control.Eff.Extend: raise :: Eff r a -> Eff (e : r) a
+ Control.Eff.Extend: run :: Eff '[] w -> w
+ Control.Eff.Extend: send :: Member t r => t v -> Eff r v
+ Control.Eff.Extend: singleK :: Arr r a b -> Arrs r a b
+ Control.Eff.Extend: type Arr r a b = a -> Eff r b
+ Control.Eff.Extend: weaken :: Union r w -> Union (any : r) w
Files
- README.md +1/−1
- extensible-effects.cabal +2/−1
- src/Control/Eff.hs +32/−4
- src/Control/Eff/Choose.hs +4/−2
- src/Control/Eff/Coroutine.hs +1/−0
- src/Control/Eff/Cut.hs +1/−0
- src/Control/Eff/Example.hs +1/−0
- src/Control/Eff/Exception.hs +5/−4
- src/Control/Eff/Extend.hs +40/−0
- src/Control/Eff/Fresh.hs +3/−2
- src/Control/Eff/Internal.hs +3/−4
- src/Control/Eff/NdetEff.hs +3/−2
- src/Control/Eff/Operational.hs +1/−0
- src/Control/Eff/QuickStart.hs +10/−1
- src/Control/Eff/Reader/Lazy.hs +3/−2
- src/Control/Eff/Reader/Strict.hs +3/−2
- src/Control/Eff/State/Lazy.hs +4/−2
- src/Control/Eff/State/OnDemand.hs +4/−2
- src/Control/Eff/State/Strict.hs +4/−2
- src/Control/Eff/Trace.hs +1/−0
- src/Control/Eff/Writer/Lazy.hs +3/−2
- src/Control/Eff/Writer/Strict.hs +3/−2
- src/Data/OpenUnion.hs +5/−0
README.md view
@@ -8,7 +8,7 @@ *Implement effectful computations in a modular way!* -The main and only monad is built upon `Eff` from `Control.Eff`.+The main monad of this package is `Eff` from `Control.Eff`. `Eff r a` is parameterized by the effect-list `r` and the monadic-result type `a` similar to other monads. It is the intention that all other monadic computations can be replaced by the
extensible-effects.cabal view
@@ -6,7 +6,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 2.6.3.0+version: 3.0.0.0 -- A short (one-line) description of the package. synopsis: An Alternative to Monad Transformers@@ -85,6 +85,7 @@ Control.Eff.Writer.Strict Data.OpenUnion Control.Eff.QuickStart+ Control.Eff.Extend -- Modules included in this library but not exported. other-modules: Control.Eff.Internal
src/Control/Eff.hs view
@@ -1,6 +1,34 @@-module Control.Eff ( module Internal- , module OpenUnion- ) where+{-# LANGUAGE ExplicitNamespaces #-} -import Control.Eff.Internal as Internal hiding (Lift(..), lift, runLift)+-- | A monadic library for implementing effectful computation in a modular way.+--+-- This module provides the @Eff@ monad - the base type for all effectful+-- computation.+-- The @Member@ typeclass is the main interface for describing which effects+-- are necessary for a given function.+--+-- Consult the @Control.Eff.QuickStart@ module and the readme for gentle+-- introductions.+--+-- To use extensible effects effectively some language extensions are+-- necessary/recommended.+--+-- @+-- {-\# LANGUAGE ScopedTypeVariables \#-}+-- {-\# LANGUAGE FlexibleContexts \#-}+-- {-\# LANGUAGE MonoLocalBinds \#-}+-- @+--++module Control.Eff+ ( -- * Effect base-type+ Internal.run+ , Internal.Eff+ -- * Effect list+ , OpenUnion.Member+ , OpenUnion.SetMember+ , type(<::)+ ) where++import Control.Eff.Internal as Internal import Data.OpenUnion as OpenUnion
src/Control/Eff/Choose.hs view
@@ -18,8 +18,10 @@ , mplus' ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift+ import Control.Applicative import Control.Monad import Control.Monad.Base
src/Control/Eff/Coroutine.hs view
@@ -11,6 +11,7 @@ ) where import Control.Eff+import Control.Eff.Extend -- ------------------------------------------------------------------------ -- | Co-routines
src/Control/Eff/Cut.hs view
@@ -41,6 +41,7 @@ module Control.Eff.Cut where import Control.Eff+import Control.Eff.Extend import Control.Eff.Exception import Control.Eff.Choose
src/Control/Eff/Example.hs view
@@ -7,6 +7,7 @@ module Control.Eff.Example where import Control.Eff+import Control.Eff.Extend import Control.Eff.Exception import Control.Eff.Reader.Lazy
src/Control/Eff/Exception.hs view
@@ -24,8 +24,9 @@ , ignoreFail ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Monad (void) import Control.Monad.Base@@ -54,8 +55,8 @@ throwError e = send (Exc e) {-# INLINE throwError #-} --- | Throw an exception in an effectful computation. The type is unit, --- which suppresses the ghc-mod warning "A do-notation statement +-- | Throw an exception in an effectful computation. The type is unit,+-- which suppresses the ghc-mod warning "A do-notation statement -- discarded a result of type" throwError_ :: (Member (Exc e) r) => e -> Eff r () throwError_ = throwError
+ src/Control/Eff/Extend.hs view
@@ -0,0 +1,40 @@+-- | This module exports functions, types, and typeclasses necessary for+-- implementing a custom effect and/or effect handler.+--++module Control.Eff.Extend+ ( -- * The effect monad+ Eff(..)+ , run+ -- * Open Unions+ , OpenUnion.Union+ , OpenUnion.Member+ , inj+ , prj+ , decomp+ , SetMember+ , weaken+ -- * Helper functions that are used for implementing effect-handlers+ , handle_relay+ , handle_relay_s+ , interpose+ , raise+ , send+ -- * Arrow types and compositions+ , Arr+ , Arrs+ , first+ , singleK+ , qApp+ , (^$)+ , arr+ , ident+ , comp+ , (^|>)+ , qComp+ , qComps+ )+where++import Data.OpenUnion as OpenUnion+import Control.Eff.Internal
src/Control/Eff/Fresh.hs view
@@ -13,8 +13,9 @@ , runFresh' ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Monad.Base import Control.Monad.Trans.Control
src/Control/Eff/Internal.hs view
@@ -22,8 +22,7 @@ -- Extensible Effects are implemented as typeclass constraints on an Eff[ect] datatype. -- A contrived example can be found under "Control.Eff.Example". To run the -- effects, consult the tests.-module Control.Eff.Internal ( module Control.Eff.Internal- ) where+module Control.Eff.Internal where #if __GLASGOW_HASKELL__ < 710 import Control.Applicative@@ -189,10 +188,10 @@ -- --------------------------------------------------------------------------- | The initial case, no effects. Get the result from a pure computation.+-- | Get the result from a pure (i.e. no effects) computation. -- -- The type of run ensures that all effects must be handled:--- only pure computations may be run.+-- only pure computations can be run. run :: Eff '[] w -> w run (Val x) = x -- | the other case is unreachable since Union [] a cannot be
src/Control/Eff/NdetEff.hs view
@@ -15,8 +15,9 @@ -- | Another implementation of nondeterministic choice effect module Control.Eff.NdetEff where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Applicative import Control.Monad
src/Control/Eff/Operational.hs view
@@ -19,6 +19,7 @@ ) where import Control.Eff+import Control.Eff.Extend -- | Lift values to an effect. -- You can think this is a generalization of @Lift@.
src/Control/Eff/QuickStart.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE MonoLocalBinds #-} -- | This module contains several tiny examples of how to use effects. -- For technical details, see the documentation in the effect-modules.@@ -11,15 +12,23 @@ -- be used to construct much more complicated programs by composing the little -- pieces shown here. ----- This module imports and reexports modules from this library:+-- This module imports and reexports modules from this library and requires+-- some language extensions: -- -- @+-- {-\# LANGUAGE ScopedTypeVariables \#-}+-- {-\# LANGUAGE FlexibleContexts \#-}+-- {-\# LANGUAGE MonoLocalBinds \#-}+-- -- import Control.Eff -- import Control.Eff.Reader.Lazy -- import Control.Eff.Writer.Lazy -- import Control.Eff.State.Lazy -- import Control.Eff.Exception -- @+--+-- If you want to see what each extension is good for, you can disable it and+-- see what GHC will complain about. -- module Control.Eff.QuickStart ( -- * Examples
src/Control/Eff/Reader/Lazy.hs view
@@ -15,8 +15,9 @@ , runReader ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Monad.Base import Control.Monad.Trans.Control
src/Control/Eff/Reader/Strict.hs view
@@ -16,8 +16,9 @@ , runReader ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Monad.Base import Control.Monad.Trans.Control
src/Control/Eff/State/Lazy.hs view
@@ -11,10 +11,12 @@ -- | Lazy state effect module Control.Eff.State.Lazy where -import Control.Eff.Internal+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift+ import Control.Eff.Writer.Lazy import Control.Eff.Reader.Lazy-import Data.OpenUnion import Control.Monad.Base import Control.Monad.Trans.Control
src/Control/Eff/State/OnDemand.hs view
@@ -11,10 +11,12 @@ -- | Lazy state effect module Control.Eff.State.OnDemand where -import Control.Eff.Internal+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift+ import Control.Eff.Writer.Lazy import Control.Eff.Reader.Lazy-import Data.OpenUnion import Control.Monad.Base import Control.Monad.Trans.Control
src/Control/Eff/State/Strict.hs view
@@ -12,10 +12,12 @@ -- | Strict state effect module Control.Eff.State.Strict where -import Control.Eff.Internal+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift+ import Control.Eff.Writer.Strict import Control.Eff.Reader.Strict-import Data.OpenUnion import Control.Monad.Base import Control.Monad.Trans.Control
src/Control/Eff/Trace.hs view
@@ -10,6 +10,7 @@ ) where import Control.Eff+import Control.Eff.Extend -- | Trace effect for debugging data Trace v where
src/Control/Eff/Writer/Lazy.hs view
@@ -24,8 +24,9 @@ , execMonoidWriter ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Applicative ((<|>))
src/Control/Eff/Writer/Strict.hs view
@@ -25,8 +25,9 @@ , execMonoidWriter ) where -import Control.Eff.Internal-import Data.OpenUnion+import Control.Eff+import Control.Eff.Extend+import Control.Eff.Lift import Control.Applicative ((<|>))
src/Data/OpenUnion.hs view
@@ -94,6 +94,11 @@ newtype P t r = P{unP :: Int} +-- | Typeclass that asserts that effect @t@ is contained inside the effect-list+-- @r@.+--+-- The @FindElem@ typeclass is necessary for implementation reasons and is not+-- required for using the effect list. class (FindElem t r) => Member (t :: * -> *) r where inj :: t v -> Union r v prj :: Union r v -> Maybe (t v)