mark System.IO.openTempFile as non-portable in haddocks
[haskell-directory.git] / Data / List.hs
index f9a1226..b6a847b 100644 (file)
@@ -93,8 +93,6 @@ module Data.List
    , span              -- :: (a -> Bool) -> [a] -> ([a], [a])
    , break             -- :: (a -> Bool) -> [a] -> ([a], [a])
 
-   , split             -- :: Eq a => a -> [a] -> [[a]]
-
    , group             -- :: Eq a => [a] -> [[a]]
 
    , inits             -- :: [a] -> [[a]]
@@ -170,6 +168,10 @@ module Data.List
    -- ** The \"@By@\" operations
    -- | By convention, overloaded functions have a non-overloaded
    -- counterpart whose name is suffixed with \`@By@\'.
+   --
+   -- It is often convenient to use these functions together with
+   -- 'Data.Function.on', for instance @'sortBy' ('compare'
+   -- \`on\` 'fst')@.
 
    -- *** User-supplied equality (replacing an @Eq@ context)
    -- | The predicate is assumed to define an equivalence.
@@ -677,19 +679,6 @@ unzip7             =  foldr (\(a,b,c,d,e,f,g) ~(as,bs,cs,ds,es,fs,gs) ->
 deleteFirstsBy          :: (a -> a -> Bool) -> [a] -> [a] -> [a]
 deleteFirstsBy eq       =  foldl (flip (deleteBy eq))
 
--- | 'split' @x xs@ divides the list @xs@ at every occurrence of @x@ and
--- removes those occurrences.
---
--- Example:
---
--- > split 'i' "mississippi" -> ["m","ss","ss","pp",""]
--- > split 'i' [] -> [""]
-split :: Eq a => a -> [a] -> [[a]]
-split x xs = let (f,r) = break (==x) xs
-             in f : case r of
-                      [] -> []
-                      (_:ys) -> split x ys
-
 -- | The 'group' function takes a list and returns a list of lists such
 -- that the concatenation of the result is equal to the argument.  Moreover,
 -- each sublist in the result contains only equal elements.  For example,
@@ -866,7 +855,12 @@ rqpart cmp x (y:ys) rle rgt r =
 --
 -- > f' (f x y) = Just (x,y)
 -- > f' z       = Nothing
-
+--
+-- A simple use of unfoldr:
+--
+-- > unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10
+-- >  [10,9,8,7,6,5,4,3,2,1]
+--
 unfoldr      :: (b -> Maybe (a, b)) -> b -> [a]
 unfoldr f b  =
   case f b of