[Haskell-cafe] Type of divMod

Bernardo Sulzbach mafagafogigante at gmail.com
Wed Sep 28 15:28:24 UTC 2016


On 09/28/2016 04:05 AM, Todd Wilson wrote:
> Why is the type of divMod not
>
>     (Integral a, Integral b) => a -> b -> (a,b)?
>
> It would seem to make sense that if b is a size-limited Integral type
> (like Int), then since the remainder of a division is always smaller
> than the divisor, it could be given the same size-limited type.
>

The absolute value of the remainder of a division is always smaller than 
the absolute value of the divisor, right?

--

Similar reasoning could be transferred to mod. I don't know why it isn't 
as you suggested. However, I find the current way simpler and easier to 
understand.

If someone knows why we have [divMod :: a -> a -> (a, a)], please 
comment on it.

-- 
Bernardo Sulzbach
http://www.mafagafogigante.org/
mafagafogigante at mafagafogigante.org


More information about the Haskell-Cafe mailing list