You have to convert the operands to floats first and then divide, otherwise you’ll perform an integer division (no decimal places).
Laconic solution (requires Data.Function
)
foo = (/) `on` fromIntegral
which is short for
foo a b = (fromIntegral a) / (fromIntegral b)
with
foo :: Int -> Int -> Float