@@ -14,10 +14,10 @@ into a list before operating on it, and then turning it back into an array.
1414@docs fill, fromList, concat, set, updates, push
1515
1616# Taking Arrays Apart
17−@docs elements, indices, assocs, slice
17+@docs toList, toIndexedList, indices, slice
1818
1919# Mapping, folding, zipping
20−@docs map, assocMap, foldl, foldr, zip, zipWith
20+@docs map, indexMap, foldl, foldr, zip, zipWith
2121-}
2222
2323import Native.Array
@@ -41,10 +41,10 @@ fromList = List.foldl (Native.Array.push) Native.Array.empty
4141
4242{-| Create a list of elements from an array.
4343
44− elements (fromList [3,5,8]) == [3,5,8]
44+ toList (fromList [3,5,8]) == [3,5,8]
4545-}
46−elements : Array a -> [a]
47−elements = Native.Array.elements
46+toList : Array a -> [a]
47+toList = Native.Array.toList
4848
4949{-| Create a list of the possible indices of an array.
5050
@@ -53,12 +53,13 @@ elements = Native.Array.elements
5353indices : Array a -> [Int]
5454indices a = [0..Native.Array.length a - 1]
5555
56+-- TODO: make this a native function.
5657{-| Create a list of tuples (Index, Element) from an array.
5758
58− assocs (fromList [3,5,8]) == [(0,3), (1,5), (2,8)]
59+ toIndexedList (fromList [3,5,8]) == [(0,3), (1,5), (2,8)]
5960-}
60−assocs : Array a -> [(Int, a)]
61−assocs a = List.zip (indices a) (Native.Array.elements a)
61+toIndexedList : Array a -> [(Int, a)]
62+toIndexedList a = List.zip (indices a) (Native.Array.toList a)
6263
6364{-| Apply a function on every element in an array.
6465
@@ -67,12 +68,12 @@ assocs a = List.zip (indices a) (Native.Array.elements a)
6768map : (a -> b) -> Array a -> Array b
6869map = Native.Array.map
6970
70−{-| Apply a function with an index on every element in an array.
71+{-| Apply a function on every element with its index as first argument.
7172
72− assocMap (*) (fromList [5,5,5]) == fromList [0,5,10]
73+ indexedMap (*) (fromList [5,5,5]) == fromList [0,5,10]
7374-}
74−assocMap : (Int -> a -> b) -> Array a -> Array b
75−assocMap = Native.Array.assocMap
75+indexedMap : (Int -> a -> b) -> Array a -> Array b
76+indexedMap = Native.Array.indexedMap
7677
7778{-| Reduce an array from the left.
7879
@@ -103,7 +104,7 @@ is longer, the extra elements are dropped.
103104-}
104105zipWith : (a -> b -> c) -> Array a -> Array b -> Array c
105106zipWith f a b =
106− fromList <| List.zipWith f (Native.Array.elements a) (Native.Array.elements b)
107+ fromList <| List.zipWith f (Native.Array.toList a) (Native.Array.toList b)
107108
108109{-| Return an empty array.
109110
@@ -160,7 +161,7 @@ set = Native.Array.set
160161 updates [(1,7),(2,8)] (fill 3 1) == fromList [1,7,8]
161162-}
162163updates : [(Int, a)] -> Array a -> Array a
163−updates assocs array = List.foldl (uncurry Native.Array.set) array assocs
164+updates us array = List.foldl (uncurry Native.Array.set) array us
164165
165166{-| Slice an array given a range. The selection is inclusive, so the last
166167element in the selection will also be in the new array. This may change in the