Elm Exactly
Results / elm-bytes /

DecodeMapTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
Bytes.Decode.map applies a function to the value a decoder produces.

A single unsigned byte 42 is decoded through `map (\x -> x * 2)`, so the logged
result is 84. A failed decode would log -1.

Results

elm-0.19.1

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

elm-0.19.2

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

elm-0.19.3

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

lamdera-1.5.0

passran in 61 ms
Output
DecodeMapTest: 84

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module DecodeMapTest exposing (main)
{-| Bytes.Decode.map applies a function to the value a decoder produces.
A single unsigned byte 42 is decoded through `map (\x -> x * 2)`, so the logged
result is 84. A failed decode would log -1.
-}
-- CHECK: DecodeMapTest: 84
import Bytes exposing (Bytes)
import Bytes.Decode as D
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode (E.unsignedInt8 42)
decoder =
D.map (\x -> x * 2) D.unsignedInt8
result =
D.decode decoder bytes
|> Maybe.withDefault -1
_ =
Debug.log "DecodeMapTest" result
in
text (String.fromInt result)