[Haskell-cafe] Documenting the impossible
Henning Thielemann
lemming at henning-thielemann.de
Sat Jun 14 17:01:28 EDT 2008
On Sat, 14 Jun 2008, Neil Mitchell wrote:
> Hi
>
>> How about a {-# IMPOSSIBLE #-} pragma that documents the fact that a
>> particular point in the program *should* be unreachable?
>
> Why not make it a function taking a string and returning a value of
> any type. Then we can keep our language and not break various
> parsing/type checking properties and rules on pragmas. We can even
> define it:
>
> impossible = error
>
> Now you can use tools like Catch and Reach to ensure it is impossible.
>
> I think it would be nice to distinguish between:
>
> * error - inserted by the compiler
Example?
> * impossible - the programmer knows this can't occur
This is an error. However the programmer adds a message because he might
be wrong.
> * 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.
http://www.haskell.org/haskellwiki/Exception
http://www.haskell.org/haskellwiki/Error
More information about the Haskell-Cafe
mailing list