Elm Exactly
Results / elm-core /

MaybeMapTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
`Maybe.map` applies a function inside `Just` and leaves `Nothing` unchanged.

Doubling `Just 42` gives `Just 84`; doubling `Nothing` gives `Nothing`.

Results

elm-0.19.1

passran in 59 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
map1: Just 84
map2: Nothing

elm-0.19.2

passran in 91 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
map1: Just 84
map2: Nothing

elm-0.19.3

passran in 49 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
map1: Just 84
map2: Nothing

lamdera-1.5.0

passran in 88 ms
Output
map1: Just 84
map2: Nothing

Discussions

Discuss this test·Search the discussions on GitHub

Discussions are on GitHub; one about this test has [t:elm-core/MaybeMapTest] in its title.

Source

The -- CHECK: lines give the expected output.

module MaybeMapTest exposing (main)
{-| `Maybe.map` applies a function inside `Just` and leaves `Nothing` unchanged.
Doubling `Just 42` gives `Just 84`; doubling `Nothing` gives `Nothing`.
-}
-- CHECK: map1: Just 84
-- CHECK: map2: Nothing
import Html exposing (text)
main =
let
_ = Debug.log "map1" (Maybe.map (\x -> x * 2) (Just 42))
_ = Debug.log "map2" (Maybe.map (\x -> x * 2) Nothing)
in
text "done"