[commit: ghc] master: Add some complexities to Data.List documentation (#15003) (07e02d5)
git at git.haskell.org
git at git.haskell.org
Sat Dec 8 04:28:43 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/07e02d578538248aa12bd3f5a77c76ccfdc9e0db/ghc
>---------------------------------------------------------------
commit 07e02d578538248aa12bd3f5a77c76ccfdc9e0db
Author: Sven Tennie <sven.tennie at gmail.com>
Date: Sun Dec 2 18:02:18 2018 +0100
Add some complexities to Data.List documentation (#15003)
Namely for:
- head
- uncons
- tail
- last
- init
- null
>---------------------------------------------------------------
07e02d578538248aa12bd3f5a77c76ccfdc9e0db
libraries/base/GHC/List.hs | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/libraries/base/GHC/List.hs b/libraries/base/GHC/List.hs
index 63144ce..6b86b1f 100644
--- a/libraries/base/GHC/List.hs
+++ b/libraries/base/GHC/List.hs
@@ -44,7 +44,7 @@ infix 4 `elem`, `notElem`
-- List-manipulation functions
--------------------------------------------------------------
--- | Extract the first element of a list, which must be non-empty.
+-- | /O(1)/. Extract the first element of a list, which must be non-empty.
head :: [a] -> a
head (x:_) = x
head [] = badHead
@@ -62,7 +62,7 @@ badHead = errorEmptyList "head"
head (augment g xs) = g (\x _ -> x) (head xs)
#-}
--- | Decompose a list into its head and tail. If the list is empty,
+-- | /O(1)/. Decompose a list into its head and tail. If the list is empty,
-- returns 'Nothing'. If the list is non-empty, returns @'Just' (x, xs)@,
-- where @x@ is the head of the list and @xs@ its tail.
--
@@ -71,12 +71,14 @@ uncons :: [a] -> Maybe (a, [a])
uncons [] = Nothing
uncons (x:xs) = Just (x, xs)
--- | Extract the elements after the head of a list, which must be non-empty.
+-- | /O(1)/. Extract the elements after the head of a list, which must be
+-- non-empty.
tail :: [a] -> [a]
tail (_:xs) = xs
tail [] = errorEmptyList "tail"
--- | Extract the last element of a list, which must be finite and non-empty.
+-- | /O(n)/. Extract the last element of a list, which must be finite and
+-- non-empty.
last :: [a] -> a
#if defined(USE_REPORT_PRELUDE)
last [x] = x
@@ -94,7 +96,7 @@ lastError :: a
lastError = errorEmptyList "last"
#endif
--- | Return all the elements of a list except the last one.
+-- | /O(n)/. Return all the elements of a list except the last one.
-- The list must be non-empty.
init :: [a] -> [a]
#if defined(USE_REPORT_PRELUDE)
@@ -109,7 +111,7 @@ init (x:xs) = init' x xs
init' y (z:zs) = y : init' z zs
#endif
--- | Test whether a list is empty.
+-- | /O(1)/. Test whether a list is empty.
null :: [a] -> Bool
null [] = True
null (_:_) = False
More information about the ghc-commits
mailing list