ptal / expected

What did you expect?
113 stars 18 forks source link

[Monads] Add Monad mdo operation with its default implementation #51

Closed viboes closed 10 years ago

viboes commented 10 years ago

Haskell has a default implementation for this operation using mbind.

  template <class M, class T, class U>
  apply<M,U> operator>>(apply<M,T>&& m1, apply<M,U>&& m2)
  {
    return mbind(m1, [&](T& ) { return m2; });
  }

The operator >> is used in other EDSL as sequencing operator.

viboes commented 10 years ago

https://github.com/ptal/Boost.Expected/commit/3ea9d7115a530305d99b2161455ff03ee7a9efea

viboes commented 10 years ago

https://github.com/ptal/Boost.Expected/commit/549c4ac6d33140cdaa7cbd7d7d40cabbf69401f9