Warn against using 'fail' directly in user-code

Andreas Abel andreas.abel at ifi.lmu.de
Mon Dec 16 20:08:32 UTC 2013

On 16.12.2013 18:37, Niklas Hambüchen wrote:
>> (Fwiw, I've tested attaching such a warning to `fail` in GHC HEAD's
>> libraries/base/GHC/Base.lhs and it seems to work just fine so far... so
>> if there's consensus, we could add that for GHC 7.8)
> That sounds great!
> And as far as I remember, we will have MonadFail, as Malcolm mentioned,
> soon.
> On 16/12/13 13:54, Andreas Abel wrote
>>    fail :: String -> m a
>>    Fail with a message. This operation is not part of the mathematical
>>   definition of a monad, but is invoked on pattern-match failure in a do
>> expression.
> This seems to go well with your change.

Above I was just quoting the current documentation.  It should be 
formulated sharper, to say explicitly "do not use `fail' to throw your 
own errors!"

Andreas Abel  <><      Du bist der geliebte Mensch.

Theoretical Computer Science, University of Munich
Oettingenstr. 67, D-80538 Munich, GERMANY

andreas.abel at ifi.lmu.de

More information about the Libraries mailing list