MaybeMapTypeMismatchTest
`Maybe.map` with a function whose result type (Bool) differs from its argument type (Float), applied with `|>`, returns the mapped Bool. Mapping `\x -> x > 0` over `Just 1.0` gives `Just True`, and over `Just -1.0` gives `Just False`.
Results
elm-0.19.1
passran in 87 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. r1: Just True r2: Just False
elm-0.19.2
passran in 76 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. r1: Just True r2: Just False
elm-0.19.3
passran in 43 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. r2: Just False r1: Just True
lamdera-1.5.0
passran in 109 msOutput
r2: Just False r1: Just True
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-core/MaybeMapTypeMismatchTest] in its title.
Source
The -- CHECK: lines give the expected output.
module MaybeMapTypeMismatchTest exposing (main)
{-| `Maybe.map` with a function whose result type (Bool) differs from its argument type (Float), applied with `|>`, returns the mapped Bool.
Mapping `\x -> x > 0` over `Just 1.0` gives `Just True`, and over `Just -1.0`
gives `Just False`.
-}
-- CHECK: r1: Just True
-- CHECK: r2: Just False
import Html exposing (text)
main =
let
r1 =
Just 1.0
|> Maybe.map (\x -> x > 0)
r2 =
Just -1.0
|> Maybe.map (\x -> x > 0)
_ = Debug.log "r1" r1
_ = Debug.log "r2" r2
in
text "done"