If you want to perform fractional division, you can convert from any Integral
type using fromIntegral
, or fromInteger
to convert only from Integer
specifically.
There are similar functions relating to other numeric type classes: toRational
, fromRational
, realToFrac
, etc. And of course you can convert fractional types back to integral types using round
, floor
, ceiling
, or such.
And finally, on the off chance that you actually wanted integer division, instead of fractional division with rounding afterwards, there's the div
and quot
functions (depending on what truncation behavior you want).
Also, you probably should write your function as something like posToXY a b = round $ a / b
. The unnecessary do
and multiple lines makes it harder to read.