och*_*les 21 monads haskell monad-transformers applicative
我transformers在最近的博客文章中写过,有人问"人们使用Control.Applicative.Lift做什么?" 我不能回答这个问题,所以我呼应问题StackOverflow的-什么是 Control.Applicative.Lift干什么用的?
我在包中看到了一个使用它的例子,但我似乎完全无法解析它的作用.有没有人知道野外任何其他的例子?
Don*_*art 19
电梯是一个相对较新的贡献:
data Lift f a = Pure a | Other (f a)
Run Code Online (Sandbox Code Playgroud)
也就是说,给定一个仿函数f,你可以通过f用纯值组合来获得一个新的仿函数.
包本身就是一个例子:
-- | An applicative functor that collects a monoid (e.g. lists) of errors.
-- A sequence of computations fails if any of its components do, but
-- unlike monads made with 'ErrorT' from "Control.Monad.Trans.Error",
-- these computations continue after an error, collecting all the errors.
type Errors e = Lift (Constant e)
-- | Report an error.
failure :: Monoid e => e -> Errors e a
failure e = Other (Constant e)
Run Code Online (Sandbox Code Playgroud)
但是,我不知道其中的任何野外用途.
| 归档时间: |
|
| 查看次数: |
970 次 |
| 最近记录: |