@hackage interlude0.1.2

Replaces some Prelude functions for enhanced error reporting

SYNOPSIS

Interlude is an include file and a module to use instead of the (often implicit) Prelude import. It replaces some partial functions (i.e. functions that may fail on correctly typed input) with pattern matches, so that a sensible error message that includes location can be printed out.

E.g. using the Prelude, "head []" results in

*** Exception: Prelude.head: empty list

With Interlude, you instead get:

*** Exception: Program error - 'head' failed: empty list. Location: test.hs line: 7

INSTALLATION

As per the usual cabal incantations:

./Setup.hs configure
./Setup.hs build
sudo ./Setup.hs install

(Or add --user to configure in lieu of the sudo for install if you don't have or want to use the privileges.)

USAGE

Replace any implicit or explicit import of the Prelude with

#include <interlude.h> import Interlude

Make sure you compile with CPP, adding the {-# OPTIONS -cpp #-} pragma or -cpp to the command line works for GHC, in addition :s -cpp works for GHCi.

You may also #define a MESSAGE macro with a string to print after any error. Useful to point out the address to contact for support, for intstance.

BUGS

You will not be able to hide or qualify the functions replaced by the Interlude. As the names will be expanded in the imports, expect some messy error messages if you try.

The C preprocessor doesn't care much for macro expansion in the presence of primes used as variable names, and using these replacement functions on the same line as single quotes will usually not work. See the file example.hs for an example