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

Chris Wong lambda.fairy at gmail.com
Mon Jun 15 08:05:59 UTC 2015


On Fri, Jun 12, 2015 at 7:04 PM, 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.

As for naming: it should be named IsInteger/fromInteger by analogy
with IsString/fromString and IsList/fromList.

I don't otherwise have an opinion.

-- 
https://lambda.xyz


More information about the Haskell-Cafe mailing list