为什么“绑定”在Haskell Monads中写为>> =? [英] Why is "bind" written as >>= in Haskell Monads?

查看:141
本文介绍了为什么“绑定”在Haskell Monads中写为>> =?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Haskell Monads中语法>> =和>>的起源是什么?我不是在寻找Monad如何工作的解释,而是为什么语言设计者选择了这种语法。对我而言,>> =和>>似乎有些随意,从来没有直观的意义。有没有人有一个直观的解释?是语法来自类别理论吗?

What are the origins of the syntax ">>=" and ">>" in Haskell Monads? I'm not looking for a explanation of how Monads work but instead why the language designers chose that syntax. To me, ">>=" and ">>" seems kind of arbitrary and never made intuitive sense. Does anyone have a intuitive explanation? Is it syntax that comes from category theory?

推荐答案

m>>> = k 建议将计算结果 m 提供给函数 k ; m>> n 建议运行 m 计算,然后执行 n 计算。

m >>= k suggests "feed the result of computation m to the function k"; m >> n suggests "run the m computation and then the n computation".

这篇关于为什么“绑定”在Haskell Monads中写为>> =?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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