
30 Apr
2012
30 Apr
'12
5:33 a.m.
On Mon, 30 Apr 2012 10:31:01 +0200, Ketil Malde
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 --