[Haskell-beginners] unwanted Fractional constraint

M Douglas McIlroy m.douglas.mcilroy at dartmouth.edu
Fri Dec 11 13:03:03 UTC 2020


For rational functions that take on integer values at integer
arguments, for example n*(n+1)/2, is there a way to doctor the
corresponding Haskell definition

    f n = n*(n+1)/2

so that the type signature becomes

    f :: Num a => a -> a

rather than

    f :: Fractional a => a -> a

Doug McIlroy


More information about the Beginners mailing list