Extracting constructor name

Henning Thielemann schlepptop at henning-thielemann.de
Tue Sep 27 21:31:08 CEST 2011


Gracjan Polak schrieb:
> Hi all,
> 
> To get a bit better error reporting and debugging I'd like to report constructor
> names misused. Example:
> 
> 
> data X = A | B Int | C String
> 
> 
> magic A = doSomething
> magic x = error $ "magic can only be used on A, you supplied " ++ constrName x

Maybe it is better then to have three distinct types A, B, C and provide
a type class like Magic for the functionality that is only provided by A.




More information about the Libraries mailing list