如何在haskell中使用箭头运算符 [英] How to use arrow operators in haskell

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

问题描述

我想知道

- > > > = < -



在haskell中以及如何使用它们? b 是函数类型。它描述了一个函数,它使用 a 类型并返回一个类型 b



>> = 是一元绑定函数。它的类型是 Monad m => m a - > (a - > m b) - > m b 。如果你需要了解这一点,我建议阅读了解你对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中使用箭头运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆