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

Commit df0abe0

Browse files
committed
Merge pull request #3 from purescript/class
Move MonadEff over
2 parents 1f48316 + 5038b75 commit df0abe0

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ bower install purescript-eff
1414

1515
- [Control.Monad.Eff](docs/Control.Monad.Eff.md)
1616
- [Control.Monad.Eff.Unsafe](docs/Control.Monad.Eff.Unsafe.md)
17+
- [Control.Monad.Eff.Class](docs/Control.Monad.Eff.Class.md)

docs/Control.Monad.Eff.Class.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Module Control.Monad.Eff.Class
2+
3+
#### `MonadEff`
4+
5+
``` purescript
6+
class (Monad m) <= MonadEff eff m where
7+
liftEff :: forall a. Eff eff a -> m a
8+
```
9+
10+
The `MonadEff` class captures those monads which support native effects.
11+
12+
Instances are provided for `Eff` itself, and the standard monad transformers.
13+
14+
`liftEff` can be used in any appropriate monad transformer stack to lift an action
15+
of type `Eff eff a` into the monad.
16+
17+
Note that `MonadEff` is parameterized by the row of effects, so type inference can be
18+
tricky. It is generally recommended to either work with a polymorphic row of effects,
19+
or a concrete, closed row of effects such as `(trace :: Trace)`.
20+
21+
##### Instances
22+
``` purescript
23+
instance monadEffEff :: MonadEff eff (Eff eff)
24+
```
25+
26+

src/Control/Monad/Eff/Class.purs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Control.Monad.Eff.Class
2+
( MonadEff
3+
, liftEff
4+
) where
5+
6+
import Prelude
7+
8+
import Control.Monad.Eff
9+
10+
-- | The `MonadEff` class captures those monads which support native effects.
11+
-- |
12+
-- | Instances are provided for `Eff` itself, and the standard monad transformers.
13+
-- |
14+
-- | `liftEff` can be used in any appropriate monad transformer stack to lift an action
15+
-- | of type `Eff eff a` into the monad.
16+
-- |
17+
-- | Note that `MonadEff` is parameterized by the row of effects, so type inference can be
18+
-- | tricky. It is generally recommended to either work with a polymorphic row of effects,
19+
-- | or a concrete, closed row of effects such as `(trace :: Trace)`.
20+
class (Monad m) <= MonadEff eff m where
21+
liftEff :: forall a. Eff eff a -> m a
22+
23+
instance monadEffEff :: MonadEff eff (Eff eff) where
24+
liftEff = id

0 commit comments

Comments
 (0)