[Haskell-cafe] Documenting the impossible

Neil Mitchell ndmitchell at gmail.com
Sat Jun 14 16:29:09 EDT 2008


>  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
* impossible - the programmer knows this can't occur
* abort - deliberate aborting because the user made some mistake.

The safe library provides abort already.



More information about the Haskell-Cafe mailing list