better error message for "undefined"

the haskell prelude introduces the type undefined and contains a remark to the effect that compilers are expected to intrudocue a meaningful error message. GHC just prints 'Prelude undefined' which is not very informativ. 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. i searched the web, but found nothing. any suggestions? thanks a lot! andrew

Hello Andrew, Thursday, September 10, 2009, 4:02:27 PM, you 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.
error "my error 123" -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

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!
HTH, Martijn. 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.
participants (3)
-
Andrew U. Frank
-
Bulat Ziganshin
-
Martijn van Steenbergen