One of the patterns that Elm 0.19 prevents, that formerly worked in 0.18 is illustrated by the following:
toJson : Maybe Float -> Json.Encode.Value
toJson maybeNumber =
case maybeNumber of
Just 1 ->
Json.Encode.bool True
Just n ->
Json.Encode.float n
Nothing ->
Json.Encode.bool False
I can see preventing this is a good thing as pattern matching floats against literal integers can be risky because of rounding errors.
Yet, the following is accepted by the compiler:
toJson : Maybe Float -> Json.Encode.Value
toJson maybeNumber =
case maybeNumber of
Just n ->
if n == 1 then
Json.Encode.bool True
else
Json.Encode.float n
Nothing ->
Json.Encode.bool False
Is comparing with the == operator any less risky than pattern matching via case...of?