This repository has been archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from purescript/class
Move MonadEff over
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |