fromList -package:ghc

Converts a normal list to a NonEmpty stream. Raises an error if given an empty list.
The fromList function constructs the structure l from the given list of Item l
Create a map from a list of key/value pairs.
fromList [] == empty
fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
Create a set from a list of integers.
Build a map from a list of key/value pairs. See also fromAscList. If the list contains more than one value for the same key, the last value for the key is retained. If the keys are in non-decreasing order, this function takes <math> time.
fromList [] == empty
fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
Create a sequence from a finite list of elements. There is a function toList in the opposite direction for all instances of the Foldable class, including Seq.
Create a set from a list of elements. If the elements are in non-decreasing order, this function takes <math> time.
Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
>>> fromList [("a", 'x'), ("a", 'y')]
fromList [("a",'y')]
O(n) Convert a list to a vector. During the operation, the vector’s capacity will be doubling until the list's contents are in the vector. Depending on the list’s size, up to half of the vector’s capacity might be empty. If you’d rather avoid this, you can use fromListN, which will provide the exact space the list requires but will prevent list fusion, or force . fromList, which will create the vector and then copy it without the superfluous space.
Create a Bundle from a list
Convert a list to a Bundle
O(n) Convert a list to a vector. During the operation, the vector’s capacity will be doubling until the list's contents are in the vector. Depending on the list’s size, up to half of the vector’s capacity might be empty. If you’d rather avoid this, you can use fromListN, which will provide the exact space the list requires but will prevent list fusion, or force . fromList, which will create the vector and then copy it without the superfluous space.
O(n) Convert a list to a vector. During the operation, the vector’s capacity will be doubling until the list's contents are in the vector. Depending on the list’s size, up to half of the vector’s capacity might be empty. If you’d rather avoid this, you can use fromListN, which will provide the exact space the list requires but will prevent list fusion, or force . fromList, which will create the vector and then copy it without the superfluous space.
O(n) Convert a list to a vector. During the operation, the vector’s capacity will be doubling until the list's contents are in the vector. Depending on the list’s size, up to half of the vector’s capacity might be empty. If you’d rather avoid this, you can use fromListN, which will provide the exact space the list requires but will prevent list fusion, or force . fromList, which will create the vector and then copy it without the superfluous space.
O(n) Convert a list to a vector. During the operation, the vector’s capacity will be doubling until the list's contents are in the vector. Depending on the list’s size, up to half of the vector’s capacity might be empty. If you’d rather avoid this, you can use fromListN, which will provide the exact space the list requires but will prevent list fusion, or force . fromList, which will create the vector and then copy it without the superfluous space.
Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
Construct a set from a list of elements.
O(n) amortized. Construct a Deque from a list of values.
>>> fromList [1,2]
BD 1 [1] 1 [2]
Build an index out of a bunch of packages. If there are duplicates by UnitId then later ones mask earlier ones.
fromList xs is a DList representing the list xs. fromList obeys the laws:
toList . fromList = id
fromList . toList = id
This function is implemented with ++. Repeated uses of fromList are just as inefficient as repeated uses of ++. If you find yourself doing some form of the following (possibly indirectly), you may not be taking advantage of the DList representation and library:
fromList . f . toList
More likely, you will convert from a list, perform some operation on the DList, and convert back to a list:
toList . g . fromList
fromList xs is a DNonEmpty representing the list xs. If xs is empty, an error is raised. fromList obeys the law:
fromList xs = fromNonEmpty (fromList xs)