简体   繁体   English

Haskell单项证明

[英]Haskell monadic proof

For the mathematical experts (I am not, nor a Haskell expert): 对于数学专家(我不是,也不是Haskell专家):

m >> k = m >>= \_ -> k

This 'monad' typechecks and compiles. 此“ monad”进行类型检查和编译。 Is this to mathematically proof that m >> k (omitting a return value) and m >>= \\_ -> k (a monad with return, but a lambda without) are the same, or can I actually put values in? 这是从数学上证明m >> k (忽略返回值)和m >>= \\_ -> k (有返回值的monad,但没有返回值的lambda)是相同的,还是我可以实际输入值? Just being curious. 只是好奇。 Not a blocking issue. 不是阻塞问题。

This is definition of function >> in infix form. 这是函数>>定义,以infix形式。

It is equivalent to more usual (>>) mk = ... . 它等效于更常见的(>>) mk = ...

Brackets here is to explain Haskell that we use operator in prefix form. 这里的括号是解释Haskell我们以前缀形式使用运算符。

I a assume you are reading the following bit in the Prelude http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Base.html#%3E%3E 我假设您正在阅读Prelude http://hackage.haskell.org/package/base-4.12.0.0/docs/src/GHC.Base.html#%3E%3E中的以下内容

This is not a proof. 这不是证明。 This is more akin to the definition of a method in an OOP interface. 这更类似于OOP接口中方法的定义。

There in the definition of the class Monad (class in Haskell is more like an interface); class Monad类的定义中(Haskell中的class Monad更像是一个接口)。 it's defined that an operator >> should be defined. 它定义了一个运算符>>应该被定义。 And a default definition is supplied. 并且提供了默认定义。 The default definition is m >>= \\_ -> k . 默认定义为m >>= \\_ -> k

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM