如何在haskell中使用箭头运算符 [英] How to use arrow operators in haskell
问题描述
我想知道
- >
,> > =
和< -
在haskell中以及如何使用它们? b 是函数类型。它描述了一个函数,它使用 a
类型并返回一个类型 b
。
>> =
是一元绑定函数。它的类型是 Monad m => m a - > (a - > m b) - > m b
。如果你需要了解这一点,我建议阅读了解你对Haskell的益处。
$ b
< -
是 do {a< - b; c}
翻译为 b>>> = \ a - > c
,即它基本上是编写>> =
的更好方法。
I want to know the difference between
->
, >>=
and <-
in haskell and how to use them?
a -> b
is the function type. It describes a function that takes a type a
and returns a type b
.
>>=
is the monadic bind function. It is of type Monad m => m a -> (a -> m b) -> m b
. If you need to understand this, I recommend reading Learn You a Haskell for Great Good.
<-
is syntactic sugar in a do
block, where do {a <- b; c}
translates as b >>= \a -> c
, i.e, it's basically a nicer way of writing >>=
.
这篇关于如何在haskell中使用箭头运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!