[Haskell-cafe] haskell programming guidelines

John Meacham john at repetae.net
Mon Feb 20 23:36:06 EST 2006

There is a more straightforward way to get localized error messages
rather than using 'maybe' and hand-writing an appropriate error, and
that is to rely on irrefutable bindings.

f x = ... y ... where
        Just y = Map.lookup x theMap

now if the lookup fails you automatically get an error message pointing
to the exact line number of the failure. or if the failure message of
the routine is more important than the source location you can do

f x = ... y ... where
        Identity y = Map.lookup x theMap

it is anoying you have to make a choice between these two possibilities,
but this can be mitigated with CPP magic or the SRCLOC_ANNOTATE pragma.


John Meacham - ⑆repetae.net⑆john⑈

More information about the Haskell-Cafe mailing list