
30 Nov
2015
30 Nov
'15
5:36 p.m.
On Mon, 30 Nov 2015 14:25:49 -0800
Jeffrey Brown
I've written a monadic function which in a Maybe context produces a Nothing when it fails (as intended), but in an Either context produces an Exception rather than a Left.
The Monad instance for (Either e) uses the default definition of 'fail', which is to throw an exception: instance Monad (Either e) where return = Right Left l >>= _ = Left l Right r >>= k = k r In general, 'Left' can't be used because that would only type check for (Either String), but the Monad instance is more general than that. -- Michael Walker (http://www.barrucadu.co.uk)