dhall-nix-lib/Map/values.dhall

30 lines
731 B
Text

--| Get all of the values of a `Map` as a `List`
let Map = ./Type.dhall
let Entry = ./Entry.dhall
let List/map = ../List/map.dhall
let values
: ∀(k : Type) → ∀(v : Type) → Map k v → List v
= λ(k : Type) →
λ(v : Type) →
List/map (Entry k v) v (λ(x : Entry k v) → x.mapValue)
let example0 =
assert
: values
Text
Natural
[ { mapKey = "A", mapValue = 2 }
, { mapKey = "B", mapValue = 3 }
, { mapKey = "C", mapValue = 5 }
]
≡ [ 2, 3, 5 ]
let example1 =
assert
: values Text Natural ([] : List { mapKey : Text, mapValue : Natural })
≡ ([] : List Natural)
in values