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

Commit

Permalink
Merge pull request #3 from purescript/class
Browse files Browse the repository at this point in the history
Move MonadEff over
  • Loading branch information
paf31 committed Jun 9, 2015
2 parents 1f48316 + 5038b75 commit df0abe0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
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

0 comments on commit df0abe0

Please sign in to comment.