[Haskell-cafe] Printing call site for partial functions
Henk-Jan van Tuyl
hjgtuyl at chello.nl
Mon Apr 30 11:33:54 CEST 2012
On Mon, 30 Apr 2012 10:31:01 +0200, Ketil Malde <ketil at malde.org> wrote:
> One half-baked quasi-solution is to use:
>
> #define head (\xs -> case xs of { (x:_) -> x ; _ -> error("head: empty
> list at"++__FILE__++show __LINE__)})
>
> Downsides are that it depends on CPP, and, CPP being a C preprocessor,
> it doesn't blend well with lines with single apostrophes on them (e.g.:
> head x')
>
> -k
There is a Haskell solution: cpphs[0], you can invoke this preprocessor by
specifying the flags
-cpp -pgmPcpphs -optP--cpp
for GHC.
Regards,
Henk-Jan van Tuyl
[0] http://hackage.haskell.org/package/cpphs
--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
Haskell programming
--
More information about the Haskell-Cafe
mailing list