For the mathematical experts (I am not, nor a Haskell expert):
m >> k = m >>= \_ -> k
This 'monad' typechecks and compiles. 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? Just being curious. Not a blocking issue.
This is definition of function >>
in infix form.
It is equivalent to more usual (>>) mk = ...
.
Brackets here is to explain Haskell that we use operator in prefix form.
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
This is not a proof. This is more akin to the definition of a method in an OOP interface.
There in the definition of the class Monad
(class in Haskell is more like an interface); it's defined that an operator >>
should be defined. And a default definition is supplied. The default definition is m >>= \\_ -> k
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.