List package:dhall

List                                     ~  List
Decode a list.
>>> input (list natural) "[1, 2, 3]"
[1,2,3]
ListAppend x y                           ~  x # y
ListBuild                                ~  List/build
ListFold                                 ~  List/fold
ListHead                                 ~  List/head
ListIndexed                              ~  List/indexed
ListLast                                 ~  List/last
ListLength                               ~  List/length
ListLit (Just t ) []                     ~  [] : t
ListLit  Nothing  [x, y, z]              ~  [x, y, z]
Invariant: A non-empty list literal is always represented as ListLit Nothing xs. When an annotated, non-empty list literal is parsed, it is represented as
Annot (ListLit Nothing [x, y, z]) t      ~ [x, y, z] : t
ListReverse                              ~  List/reverse
List immediate dependencies as text, one per line
List all transitive dependencies as text, one per line
Return all key-value associations as a list
toList           empty  = []
toList (insert k v ctx) = (k, v) : toList ctx
Create a Map from a list of key-value pairs
>>> fromList [("B",1),("A",2)]  -- The map preserves order
fromList [("B",1),("A",2)]

>>> fromList [("A",1),("A",2)]  -- For duplicates, later values take precedence
fromList [("A",2)]
Note that this handling of duplicates means that fromList is not a monoid homomorphism:
>>> fromList [(1, True)] <> fromList [(1, False)]
fromList [(1,True)]

>>> fromList ([(1, True)] <> [(1, False)])
fromList [(1,False)]
Create a Map from a list of key-value pairs with a combining function.
>>> fromListWithKey (\k v1 v2 -> k ++ v1 ++ v2) [("B","v1"),("A","v2"),("B","v3")]
fromList [("B","Bv3v1"),("A","v2")]
Convert a Map to a list of key-value pairs in ascending order of keys
Convert a Map to a list of key-value pairs in the original order of keys
>>> toList (fromList [("B",1),("A",2)])
[("B",1),("A",2)]
Create a Map from a list of key-value pairs Any further operations on this map will not retain the order of the keys.
>>> unorderedFromList []
fromList []

>>> unorderedFromList [("B",1),("A",2)]  -- The map /doesn't/ preserve order
fromList [("A",2),("B",1)]

>>> unorderedFromList [("A",1),("A",2)]  -- For duplicates, later values take precedence
fromList [("A",2)]
Decode a HashSet from a List with distinct elements.
>>> input (hashSetFromDistinctList natural) "[1, 2, 3]"
fromList [1,2,3]
An error is thrown if the list contains duplicates.
>>> input (hashSetFromDistinctList natural) "[1, 1, 3]"
*** Exception: Error: Failed extraction

The expression type-checked successfully but the transformation to the target
type failed with the following error:

One duplicate element in the list: 1
>>> input (hashSetFromDistinctList natural) "[1, 1, 3, 3]"
*** Exception: Error: Failed extraction

The expression type-checked successfully but the transformation to the target
type failed with the following error:

2 duplicates were found in the list, including 1
Decode a Set from a List with distinct elements.
>>> input (setFromDistinctList natural) "[1, 2, 3]"
fromList [1,2,3]
An error is thrown if the list contains duplicates.
>>> input (setFromDistinctList natural) "[1, 1, 3]"
*** Exception: Error: Failed extraction

The expression type-checked successfully but the transformation to the target
type failed with the following error:

One duplicate element in the list: 1
>>> input (setFromDistinctList natural) "[1, 1, 3, 3]"
*** Exception: Error: Failed extraction

The expression type-checked successfully but the transformation to the target
type failed with the following error:

2 duplicates were found in the list, including 1
Parse the List built-in This corresponds to the List rule from the official grammar
Parse the List/build built-in This corresponds to the List-build rule from the official grammar