Skip to content

Monad laws in terms of fishes (>=>)

Present monad laws with Kleisli composition (fish operator)

  return >=> g
= g

  g >=> return 
= g

  (f >=> g) >=> h
= f >=> (g >=> h)

instead of bind:

  return a >>= k
= k a

  m >>= return
= m

  m >>= (\x -> k x >>= h)
= (m >>= k) >>= h

Even though >>= is a method of Monad this is so much clearer that I think it's worth it, started as ticket:12672#comment:125771


Fun mention: QuickSpec doesn't generate lambda terms so it will not discover (xs >>= f) >>= g = xs >>= (\x -> f x >>= g) so it needs to be in terms of >=>.

Trac metadata
Trac field Value
Version 8.0.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Documentation
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information