post(typoclassopedia): Monad Transformers##DefinitionAndLaws
This commit is contained in:
parent
2a22aae326
commit
78c9fccc72
@ -694,3 +694,23 @@ g >=> return = g
|
|||||||
= (\x -> g x >>= h) >=> k
|
= (\x -> g x >>= h) >=> k
|
||||||
= (g >=> h) >=> k
|
= (g >=> h) >=> k
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Monad Transformers
|
||||||
|
==================
|
||||||
|
|
||||||
|
## Definition and laws
|
||||||
|
|
||||||
|
```haskell
|
||||||
|
class MonadTrans t where
|
||||||
|
lift :: Monad m => m a -> t m a
|
||||||
|
```
|
||||||
|
|
||||||
|
### Exercises
|
||||||
|
|
||||||
|
1. What is the kind of `t` in the declaration of `MonadTrans`?
|
||||||
|
|
||||||
|
**Solution**:
|
||||||
|
|
||||||
|
`t` is of the kind `(* -> *) -> * -> *`, as we see in `(t m) a`, `t` accepts a `Monad` first, which is of type `* -> *`, and then
|
||||||
|
another argument of kind `*`.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user