【问题标题】:In which way do kinds associate in haskell?Haskell 中的种类以何种方式关联?
【发布时间】:2021-08-01 09:20:29
【问题描述】:

我的任务是给出一个类型构造函数的例子

* -> (* -> *)

但我找不到。

我的猜测是种类与右边相关联,因此上面给出的种类与

* -> * -> *

在这种情况下,Either 就是一个例子,不是吗?

【问题讨论】:

  • 只要记住(Type -> Type) -> Type不一样,是newtype Fix f = In (f (Fix f)的那种

标签: haskell functional-programming data-kinds type-kinds


【解决方案1】:

是的。

Prelude> :set -XKindSignatures 
Prelude> :k (Either :: * -> (* -> *))
(Either :: * -> (* -> *)) :: * -> * -> *

顺便说一句,* 符号将被弃用。现代版本称为Type

Either :: Type -> Type -> Type

【讨论】:

  • (你可能需要从 GHC.Types 导入)
  • 推荐从Data.Kind导入
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多