为什么我们需要Control.Lens.Reified? [英] Why do we need Control.Lens.Reified?
问题描述
为什么我们需要 Control.Lens.Reified ?有什么理由不能将 Lens
直接放入容器中?什么是 reify
意味着什么?
Why do we need Control.Lens.Reified? Is there some reason I can't place a Lens
directly into a container? What does reify
mean anyway?
推荐答案
因为Haskell's类型系统是预测性的。我不知道技术细节究竟是什么意思,但它禁止类型像
We need reified lenses because Haskell's type system is predicative. I don't know the technical details of exactly what that means, but it prohibits types like
[Lens s t a b]
出于某些目的,可以使用
For some purposes, it's acceptable to use
Functor f => [(a -> f b) -> s -> f t]
来代替,但是当您进入该范围时,您不会收到镜头
;你得到一个专门用于某个仿函数或另一个函数的 LensLike
。 ReifiedBlah
newtypes可以让你保持完整的多态性。
instead, but when you reach into that, you don't get a Lens
; you get a LensLike
specialized to some functor or another. The ReifiedBlah
newtypes let you hang on to the full polymorphism.
在操作上, [ReifiedLens stab]
是一个函数列表,每个函数都需要一个 Functor f
字典,而 forall f。 Functor f => [LensLike fstab]
是一个函数,它接收 Functor f
字典并返回一个列表。
Operationally, [ReifiedLens s t a b]
is a list of functions each of which takes a Functor f
dictionary, while forall f . Functor f => [LensLike f s t a b]
is a function that takes a Functor f
dictionary and returns a list.
至于reify是什么意思,那么字典会说些什么,这似乎转化为Haskell中相当惊人的各种具体含义。所以没有评论。
As for what "reify" means, well, the dictionary will say something, and that seems to translate into a rather stunning variety of specific meanings in Haskell. So no comment on that.
这篇关于为什么我们需要Control.Lens.Reified?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!