
16 Dec
2013
16 Dec
'13
8:12 a.m.
* Ivan Lazar Miljenovic
On 16 December 2013 22:15, Roman Cheplyaka
wrote: * Herbert Valerio Riedel
[2013-12-16 10:53:21+0100] Why not simply use the existing `fail :: String -> IO a` method instead?
The purpose of 'fail' is to handle monadic pattern-match failures. I consider explicit use of 'fail' in user code a hack.
Or for use with parser-combinator libraries (though I suppose this could be seen as a pattern-match failure...)?
I'd consider that an abuse, too. E.g. Parsec provides a parserFail function that you can call instead. I treat 'fail' as a semi-private method of the Monad class. I may override it, but I should never call it. It only exists for the compiler. Roman