diff -rN -u old-base/Data/List.hs new-base/Data/List.hs
--- old-base/Data/List.hs 2012-01-16 17:47:21.114090246 +0000
+++ new-base/Data/List.hs 2012-01-16 17:47:21.174090246 +0000
@@ -126,6 +126,7 @@
-- with indices ranging from 0 to @'length' xs - 1@.
, (!!) -- :: [a] -> Int -> a
+ , at -- :: [a] -> Int -> Maybe a
, elemIndex -- :: (Eq a) => a -> [a] -> Maybe Int
, elemIndices -- :: (Eq a) => a -> [a] -> [Int]
@@ -241,6 +242,13 @@
| x == y = stripPrefix xs ys
stripPrefix _ _ = Nothing
+-- | The 'at' function returns 'Just' the list element at the
+-- index given, or 'Nothing' if the index is out of the list's bounds.
+-- It is an instance of the more general 'Data.List.genericAt',
+-- which takes an index of any integral type.
+at :: [a] -> Int -> Maybe a
+at = genericAt
+
-- | The 'elemIndex' function returns the index of the first element
-- in the given list which is equal (by '==') to the query element,
-- or 'Nothing' if there is no such element.
@@ -625,6 +633,11 @@
| otherwise = error "List.genericIndex: negative argument."
genericIndex _ _ = error "List.genericIndex: index too large."
+-- | The 'genericAt' function is an overloaded version of 'at', which
+-- accepts any 'Integral' value as the index.
+genericAt :: (Integral a) => [b] -> a -> Maybe b
+genericAt xs n = listToMaybe (drop n xs)
+
-- | The 'genericReplicate' function is an overloaded version of 'replicate',
-- which accepts any 'Integral' value as the number of repetitions to make.
genericReplicate :: (Integral i) => i -> a -> [a]