[Haskell-cafe] Add IsNumeric (similar to IsString and IsList)

Michael Baikov manpacket at gmail.com
Fri Jun 12 07:04:52 UTC 2015


Hi Cafe!

Now that we have OverloadedList and OverloadedStrings extensions it
might make sense to add something similar for numerals - right now if
you want to be able to specify some items as numbers
you have to implement Num instance, unfortunately not everything that
can be represented as number can have sensible operations required by
Num: negation makes no sense for set  of natural numbers for example,
multiplication for some applications of currency values which results
in Num instance full of (*) = error "No multipication for Foos", (+) =
error "No addition for Foos".

I don't have any statistics from hackage or github, but in codebase
I'm working with there are 3 such instances.

Proposal: add OverloadedNumerals language pragma, IsNumeric typeclass
and some methods to make that class useful with behavior similar to
Lists and Strings.


More information about the Haskell-Cafe mailing list