用于Haskell中类型表达式的Lambda? [英] Lambda for type expressions in Haskell?
问题描述
Haskell或特定的编译器是否有类型级的lambda表达式(如果这甚至是一个术语)?
详细说,假设我有一个参数化类型 Foo ab
并且希望 Foo _ b
是Functor的一个实例。是否有任何机制可以让我做类似于
pre $实例Functor(\ a - > Foo ab)其中
...
?
从TypeCompose:
newtype Flip(〜>)ba = Flip {unFlip :: a〜> b}
http://hackage.haskell.org/packages/archive/TypeCompose/0.6.3/doc/html/ Control-Compose.html#t:Flip
另外,如果在两个参数中有一个Functor,你可以使它成为双重函数:
http://hackage.haskell.org/packages/archive/category-extras/0.44.4/doc/html/Control-Bifunctor.html
(或者在以后的类别中,extras是更通用的版本: http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Functor.html#t: Bifunctor )
Does Haskell, or a specific compiler, have anything like type-level lambdas (if that's even a term)?
To elaborate, say I have a parametrized type Foo a b
and want Foo _ b
to be an instance of, say, Functor. Is there any mechanism that would let me do something akin to
instance Functor (\a -> Foo a b) where
...
?
From TypeCompose:
newtype Flip (~>) b a = Flip { unFlip :: a ~> b }
http://hackage.haskell.org/packages/archive/TypeCompose/0.6.3/doc/html/Control-Compose.html#t:Flip
Also, if something is a Functor in two arguments, you can make it a bifunctor:
http://hackage.haskell.org/packages/archive/category-extras/0.44.4/doc/html/Control-Bifunctor.html
(or, in a later category-extras, a more general version: http://hackage.haskell.org/packages/archive/category-extras/0.53.5/doc/html/Control-Functor.html#t:Bifunctor)
这篇关于用于Haskell中类型表达式的Lambda?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!