Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Move MonadEff over #3

Merged
merged 1 commit into from
Jun 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
26 changes: 26 additions & 0 deletions docs/Control.Monad.Eff.Class.md
Original file line number Diff line number Diff line change
@@ -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)
```


24 changes: 24 additions & 0 deletions src/Control/Monad/Eff/Class.purs
Original file line number Diff line number Diff line change
@@ -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