Replaces some Prelude functions for enhanced error reporting

Latest on Hackage:0.1.2

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

GPL licensed and maintained by Ketil Malde


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


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.)


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

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


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
Depends on 1 package:
Used by 1 package:
comments powered byDisqus