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

Carter Schonwald carter.schonwald at gmail.com
Mon Jun 15 05:04:59 UTC 2015


have you tried  using rebindable syntax + noImplicitPrelude?  That *should*
allow you to model this by just having a distinguished fromInteger function
in scope during desugaring/type checking.
At the very least, its worth experimenting with.



On Mon, Jun 15, 2015 at 12:56 AM, Michael Baikov <manpacket at gmail.com>
wrote:

> I guess we can have something similar for rationals as well, I haven't
> considered those.
>
> On Mon, Jun 15, 2015 at 12:41 PM, Ivan Lazar Miljenovic
> <ivan.miljenovic at gmail.com> wrote:
> > 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
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150615/9d55c214/attachment.html>


More information about the Haskell-Cafe mailing list