From 5038b75831e4cd9b038d14b0b375e632ef925e5a Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Tue, 9 Jun 2015 10:53:25 -0700 Subject: [PATCH] Move MonadEff over --- README.md | 1 + docs/Control.Monad.Eff.Class.md | 26 ++++++++++++++++++++++++++ src/Control/Monad/Eff/Class.purs | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 docs/Control.Monad.Eff.Class.md create mode 100644 src/Control/Monad/Eff/Class.purs diff --git a/README.md b/README.md index 6af62dd..2458767 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,4 @@ bower install purescript-eff - [Control.Monad.Eff](docs/Control.Monad.Eff.md) - [Control.Monad.Eff.Unsafe](docs/Control.Monad.Eff.Unsafe.md) +- [Control.Monad.Eff.Class](docs/Control.Monad.Eff.Class.md) diff --git a/docs/Control.Monad.Eff.Class.md b/docs/Control.Monad.Eff.Class.md new file mode 100644 index 0000000..fbfd2ce --- /dev/null +++ b/docs/Control.Monad.Eff.Class.md @@ -0,0 +1,26 @@ +## Module Control.Monad.Eff.Class + +#### `MonadEff` + +``` purescript +class (Monad m) <= MonadEff eff m where + liftEff :: forall a. Eff eff a -> m a +``` + +The `MonadEff` class captures those monads which support native effects. + +Instances are provided for `Eff` itself, and the standard monad transformers. + +`liftEff` can be used in any appropriate monad transformer stack to lift an action +of type `Eff eff a` into the monad. + +Note that `MonadEff` is parameterized by the row of effects, so type inference can be +tricky. It is generally recommended to either work with a polymorphic row of effects, +or a concrete, closed row of effects such as `(trace :: Trace)`. + +##### Instances +``` purescript +instance monadEffEff :: MonadEff eff (Eff eff) +``` + + diff --git a/src/Control/Monad/Eff/Class.purs b/src/Control/Monad/Eff/Class.purs new file mode 100644 index 0000000..dbfd58e --- /dev/null +++ b/src/Control/Monad/Eff/Class.purs @@ -0,0 +1,24 @@ +module Control.Monad.Eff.Class + ( MonadEff + , liftEff + ) where + +import Prelude + +import Control.Monad.Eff + +-- | The `MonadEff` class captures those monads which support native effects. +-- | +-- | Instances are provided for `Eff` itself, and the standard monad transformers. +-- | +-- | `liftEff` can be used in any appropriate monad transformer stack to lift an action +-- | of type `Eff eff a` into the monad. +-- | +-- | Note that `MonadEff` is parameterized by the row of effects, so type inference can be +-- | tricky. It is generally recommended to either work with a polymorphic row of effects, +-- | or a concrete, closed row of effects such as `(trace :: Trace)`. +class (Monad m) <= MonadEff eff m where + liftEff :: forall a. Eff eff a -> m a + +instance monadEffEff :: MonadEff eff (Eff eff) where + liftEff = id