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@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.