[英]What mean type `a -> m b` in Haskell?
Example - function runKleisli
from Haskell base module 示例-Haskell基本模块中的功能runKleisli
newtype Kleisli m a b = Kleisli { runKleisli :: a -> m b }
That means runKleisli
have 1 argument with type a
and must return function m
, which have 1 argument b
? 这意味着runKleisli
具有1个类型为a
参数,并且必须返回具有1个参数b
函数m
?
It means m
is a type of kind * -> *
; 这意味着m
是一种类型的种 * -> *
; that is, m
is a type constructor that accepts a single argument, like Maybe
or Either String
. 也就是说, m
是一个接受单个参数的类型构造函数,例如Maybe
或Either String
。 When you instantiate Kleisli
and perform the substitution yourself, you can see how this works out. 当实例化Kleisli
并自己执行替换时,您可以看到它是如何工作的。
For example, consider something like Kleisli Maybe String Integer
. 例如,考虑类似Kleisli Maybe String Integer
东西。 The substituted type of runKleisli
would be String -> Maybe Integer
, and you can see how the m
is being used as a type constructor. runKleisli
的替换类型为runKleisli
String -> Maybe Integer
,您可以看到m
是如何用作类型构造函数的。
For more information about kinds in Haskell, see What exactly is the kind "*" in Haskell? 有关Haskell中种类的更多信息,请参见Haskell中种类“ *”到底是什么? . 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.