[Haskell] Numeric programming on toy problems in Haskell

Philip K.F. Hölzenspies p.k.f.holzenspies at utwente.nl
Mon Sep 10 16:39:50 EDT 2007

Dear Tomi, all,

I agree with everyone on this list that there is a good reason for
being picky about numeric types. However, when you're simply trying to
understand a small problem or puzzle, the rather intricate numeric
part of the type system can be prohibitively complex. I'm no Haskell
guru, but I don't consider myself a novice anymore. Still, I tend to
waste time on numeric stuff when trying to understand a simple and
small problem.

To avoid this, I wrote a Number module that provides a type Number
that is of all of the standard numeric type classes. Especially for
toy problems - I keep repeating this, because my Number module is NOT
FIT for production code - it is the lazy man's solution to all the
fuss about numbers. I'm lazy, me like.

You can have a look at the Number module here:


Now, whenever I've hacked together a small program, it nearly always
works. When it doesn't, it generally complains about some numeric
value somewhere. I just stick a "toNumber" in front, et voilà! :D


I know, people will want to kill me for putting all numbers back
together in a sluggish single type, but in my defense: aren't we all a
tiny bit lazy every once in a while?

More information about the Haskell mailing list