After using toMap
, it’s no longer possible to compare the keys. Though you can merge all the values, for example if your association list only contains the a
key, then this could work:
let Prelude = https://prelude.dhall-lang.org/package.dhall
let --| The nub function removes duplicate elements from a list.
nub =
let elem =
\(x : Natural) ->
\(xs : List Natural) ->
Prelude.List.any Natural (Prelude.Natural.equal x) xs
in \(list : List Natural) ->
Prelude.List.fold
Natural
list
(List Natural)
( \(item : Natural) ->
\(acc : List Natural) ->
if elem item acc then acc else [ item ] # acc
)
(Prelude.List.empty Natural)
let foo = toMap { a = [ 1, 2 ] }
let bar = toMap { a = [ 2, 3 ] }
let Entry = Prelude.Map.Entry Text (List Natural)
in nub
( Prelude.List.fold
Entry
(foo # bar)
(List Natural)
(\(item : Entry) -> \(acc : List Natural) -> item.mapValue # acc)
(Prelude.List.empty Natural)
)
Results in [1, 2, 3]
.