Your problem is not with fromMaybe
, but with fromNumber
(btw, pro tip: when you see a problem, never assume you know what the cause is; if you have a hypothesis for the cause, check it first, only then try to fix).
Once again, read the docs. Quote:
The number must already be an integer and fall within the valid range of values for the
Int
type otherwiseNothing
is returned.
Your number is not an integer, so fromNumber
returns Nothing
, just like it promised.
Judging by your expected output, what you probably actually want is floor
.