本文介绍了如何在haskell中使用箭头运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道


$ b

< - 是 do 中的语法糖,块,其中 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中使用箭头运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 10:12
查看更多