[Haskell-cafe] Documenting the impossible

Henning Thielemann lemming at henning-thielemann.de
Sat Jun 14 17:40:25 EDT 2008

On Sat, 14 Jun 2008, Neil Mitchell wrote:

> Hi
>>> * error - inserted by the compiler
>>  Example?
> Pattern-match errors.

Calling a function with patterns it cannot process is a programming error.

>>> * abort - deliberate aborting because the user made some mistake.
>>  This is an exception. The signature of a function must reflect this by a
>> Maybe, Either type etc.
> Disagree. I mean more like:
> when (Delete `elem` flags && Keep `elem` flags) $
>   abort "User cannot pick both keep and delete on the command line"
> Think "die" in Perl world.

I wouldn't use such a function, because it does not scale. E.g. I cannot 
code a loop which lets the user enter flags until they match the 
conditions. Thus instead of 'abort' I would throw an exception - which is 
equivalent to the use of an exceptional value like Nothing or Left in 
Haskell (maybe wrapped in ErrorT).

More information about the Haskell-Cafe mailing list