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

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Mon Jun 15 04:41:41 UTC 2015


On 12 June 2015 at 17:04, Michael Baikov <manpacket at gmail.com> wrote:
> 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.

Is this strictly to replace/augment fromInteger or are you proposing
one for fromRational as well?

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list