On 24 August 2015 at 21:18, Niall Douglas
On 24 Aug 2015 at 18:59, Sam Kellett wrote:
i've played with the idea in my head for the past half an hour and i think i would quite like boost::monad to be maybe a few customisation points: bind, return, fail, even >> and >>= (although i would imagine associativity and precedence would get in the way of the last two) that your own monadic-like classes could specialise and then use as first class monads. this is maybe getting a bit off topic now so i'll stop.
Monad has all those items you mention. See https://ned14.github.io/boost.monad/singletonboost_1_1monad_1_1basic__ monad.html under the section "Functional programming extensions (optional)".
You also get to customise them to your heart's content via the policy class infrastructure. After all, basic_future<> which subclasses basic_monad<> implements binds as continuations.
that does look good, don't get me wrong. but would i be able to use it to, say, provide monadic options to std::list? or io ala haskell? because if not i would wonder why not simply because it's called 'monad'. what if i wanted to use the >> operator on a boost::optional, could i do that with your monad type? i'm sure i'm being dense, but i couldn't find an example of the policy infrastructure so i couldn't answer those questions myself.