小编Kat*_*nto的帖子

是否有基于 Monad 类型类的 van Laarhoven 光学器件?

据我了解,每个 van Laarhoven 光学类型都可以通过类型构造函数的约束来定义:

type Lens      s t a b = forall f. Functor f     => (a -> f b) -> s -> f t
type Traversal s t a b = forall f. Applicative f => (a -> f b) -> s -> f t
-- etc.
Run Code Online (Sandbox Code Playgroud)

如果我们选择Monad作为约束,它是否以有意义的方式形成某种“光学”?

type Something s t a b = forall f. Monad f => (a -> f b) -> s -> f t
Run Code Online (Sandbox Code Playgroud)

我的直觉是,Monad约束可能过于严格,无法从这样的结构中获取任何值:由于Const函子不是 a Monad,我们无法通过专门化 …

haskell lenses haskell-optics

9
推荐指数
1
解决办法
87
查看次数

标签 统计

haskell ×1

haskell-optics ×1

lenses ×1