Elm Exactly
Results / elm-core /

DictTupleListKeyTest

elm-0.19.1 passelm-0.19.2 passelm-0.19.3 passlamdera-1.5.0 pass
A `Dict` keyed by `( Int, List Int )` orders a key with an empty list before
keys with non-empty lists, and can look that key up.

`compare` orders tuples field by field and lists element by element, with a
shorter prefix first, so `( 0, [] ) < ( 0, [ 1 ] ) < ( 0, [ 2 ] )`. The test
inserts the three keys out of order, logs `Dict.keys`, and checks that
`Dict.member` and `Dict.get` find the `( 0, [] )` entry.

Results

elm-0.19.1

passran in 66 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
keys: [(0,[]),(0,[1]),(0,[2])]
hasEmpty: True
emptyValue: Just "e"

elm-0.19.2

passran in 73 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets.
keys: [(0,[]),(0,[1]),(0,[2])]
hasEmpty: True
emptyValue: Just "e"

elm-0.19.3

passran in 68 ms
Output
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets.
emptyValue: Just "e"
hasEmpty: True
keys: [(0,[]),(0,[1]),(0,[2])]

lamdera-1.5.0

passran in 38 ms
Output
emptyValue: Just "e"
hasEmpty: True
keys: [(0,[]),(0,[1]),(0,[2])]

Discussions

Discuss this test·Search the discussions on GitHub

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

Source

The -- CHECK: lines give the expected output.

module DictTupleListKeyTest exposing (main)
{-| A `Dict` keyed by `( Int, List Int )` orders a key with an empty list before
keys with non-empty lists, and can look that key up.
`compare` orders tuples field by field and lists element by element, with a
shorter prefix first, so `( 0, [] ) < ( 0, [ 1 ] ) < ( 0, [ 2 ] )`. The test
inserts the three keys out of order, logs `Dict.keys`, and checks that
`Dict.member` and `Dict.get` find the `( 0, [] )` entry.
-}
-- CHECK: keys: [(0,[]),(0,[1]),(0,[2])]
-- CHECK: hasEmpty: True
-- CHECK: emptyValue: Just "e"
import Dict exposing (Dict)
import Html exposing (text)
main =
let
emptyL : List Int
emptyL = []
d : Dict ( Int, List Int ) String
d =
Dict.fromList
[ ( ( 0, [ 1 ] ), "a" )
, ( ( 0, emptyL ), "e" )
, ( ( 0, [ 2 ] ), "b" )
]
_ = Debug.log "keys" (Dict.keys d)
_ = Debug.log "hasEmpty" (Dict.member ( 0, emptyL ) d)
_ = Debug.log "emptyValue" (Dict.get ( 0, emptyL ) d)
in
text "done"