
Jason Dagit wrote:
On 11/23/06, Conor McBride
wrote: *Grr> ifM (Just True) (Just 3) Nothing Nothing
More care required!
Thank you. Now that you point this out I recall that I've made this mistake in the past
You and me both. It's really insidious and can hide for weeks, looking perfectly innocent and doing all sorts of mad stuff. Ross and I talk about this issue in our 'Applicative' paper. It's really what distinguishes monads from applicative functors. Monads let you use the value from one computation to choose which *computation* to run next; applicative functors fix the structure of computations but allow you to do what you like with the *values*. So, again, I know it's not going to happen in the immediate future, but I hope we will eventually adopt Ashley's Functor Hierarchy proposal, then shift the liftM family to the Applicative layer, where they belong. The fact that the above ifM can be typed with Applicative m, not just Monad m, is the clue to why it is broken. All the best Conor