[Haskell-cafe] AT solution: rebinding >>= for restricted monads

Jacques Carette carette at mcmaster.ca
Tue Dec 19 13:19:16 EST 2006

First, I believe that this paper
is intimately related to WitnessMonad.

David Roundy wrote:
> Rebinding the do notation is at least reasonably clean, it's just that we
> don't want to lose the ability to mix with ordinary monads.  
This inability is what made me suggest an experimental syntax extension 
rather than rebinding.

> I'm not sure that syntax extensions are very often a good idea...
I view syntax extensions as a proof-of-concept mechanism: you show that 
your new idea, if it had proper syntactic support, can make some kinds 
of programming a lot easier and clearer.  Then hopefully the extension 
gets incorporated into official syntax.  If not, then the extension 
should in time disappear.

The main advantage is to make experiments (for new syntax) possible.  
Right now, the barriers to surmount for syntactic matters is quite 
high.  I agree that it is rare that a syntax extension is really a 
"good" idea.

> data Witness a b
> instance Monad m => WitnessMonad m where
>     W m = Witness () ()
>     (>>=) = Prelude.(>>=)
>     (>>) = Prelude.(>>)
>     return = Prelude.return
>     fail = Prelude.fail
> which I think is quite pretty.  It allows the Monadlike object to have kind
> * -> *, while still allowing us to hide extra witness types inside and pull
> them out using the W function.
Yes, if you can make that work, that is quite pretty. 


More information about the Haskell-Cafe mailing list