[Haskell-cafe] better error message for "undefined"

Martijn van Steenbergen martijn at van.steenbergen.nl
Thu Sep 10 08:08:48 EDT 2009

You can use the error function. It accepts a string that is displayed 
when the error is evaluated:

> GHCi, version 6.10.1: http://www.haskell.org/ghc/  :? for help
> Loading package ghc-prim ... linking ... done.
> Loading package integer ... linking ... done.
> Loading package base ... linking ... done.
> Prelude> error "hi!"
> *** Exception: hi!



Andrew U. Frank wrote:
> is there a way to have different kinds of undefined? such that i get a message 
> which one was hit. something like writing in the code 'unefined 'my error 123' 
> which prints 'undefined - my error 123' when it is accidentally hit.

More information about the Haskell-Cafe mailing list