[Haskell-cafe] "Natural" polymorphism for n*(n+1)/2

David Feuer david.feuer at gmail.com
Wed Dec 16 21:57:12 UTC 2020


I very much doubt that Num a is sufficient. That's not even enough to check
whether a number is even. You can certainly perform the calculation with
`Integral a`, but you'll have to apply some external reasoning to see that
the result is correct.

On Wed, Dec 16, 2020, 4:45 PM M Douglas McIlroy <
m.douglas.mcilroy at dartmouth.edu> wrote:

> Some nominally rational functions, e.g n*(n+1)/2,
> yield integer values for integer arguments. I seek
> either a way to wrap such a function so it has type
> Num a => a->a or a convincing argument that it can't
> be done.
>
> Doug
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201216/5cb45c61/attachment.html>


More information about the Haskell-Cafe mailing list