diff options
author | Oleg Grenrus <oleg.grenrus@iki.fi> | 2019-11-20 22:38:36 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-02-11 05:07:30 -0500 |
commit | 375b3c45be0e5de673d03097ebbad442c85c89eb (patch) | |
tree | f079d11bc1c935a4abf03b314c835e142dbb9a70 | |
parent | 5670881d7779ecd7eee8c969dab66ee343298532 (diff) | |
download | haskell-375b3c45be0e5de673d03097ebbad442c85c89eb.tar.gz |
Add singleton to Data.OldList
-rw-r--r-- | libraries/base/Data/OldList.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libraries/base/Data/OldList.hs b/libraries/base/Data/OldList.hs index ac5cbddb58..6110a4de31 100644 --- a/libraries/base/Data/OldList.hs +++ b/libraries/base/Data/OldList.hs @@ -26,6 +26,7 @@ module Data.OldList , tail , init , uncons + , singleton , null , length @@ -1269,6 +1270,16 @@ sortOn :: Ord b => (a -> b) -> [a] -> [a] sortOn f = map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x)) +-- | Produce singleton list. +-- +-- >>> singleton True +-- [True] +-- +-- @since 4.14.0.0 +-- +singleton :: a -> [a] +singleton x = [x] + -- | The 'unfoldr' function is a \`dual\' to 'foldr': while 'foldr' -- reduces a list to a summary value, 'unfoldr' builds a list from -- a seed value. The function takes the element and returns 'Nothing' |