data-ordlist 0.4.6 → 0.4.6.1
raw patch · 3 files changed
+22/−6 lines, 3 files
Files
- CHANGES.md +9/−0
- Data/List/Ordered.hs +11/−4
- data-ordlist.cabal +2/−2
CHANGES.md view
@@ -1,3 +1,12 @@+Version 0.4.6.1: (2014-04-19)++ * Added strictness annotations inside of sortOn and nubSortOn++ * Tweaked documentation of nubSort++ * Conditionally reexport sortOn from Data.List when available.+ (See [GHC commit 44512e3c](https://ghc.haskell.org/trac/ghc/changeset/44512e3c855d8fb36ab6580f4f97f842ebcf4c6c/ghc))+ Version 0.4.6: (2014-02-15) * Generalized type signature of `isectBy`, `minusBy`, and `minusBy'`,
Data/List/Ordered.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ ----------------------------------------------------------------------------- -- | -- Module : Data.List.Ordered@@ -66,6 +68,9 @@ ) where import Data.List(sort,sortBy,intersect)+#if MIN_VERSION_base(4,7,1)+import Data.List(sortOn)+#endif -- | The 'isSorted' predicate returns 'True' if the elements of a list occur -- in non-descending order, equivalent to @'isSortedBy' ('<=')@.@@ -354,10 +359,12 @@ sortBy cmp = foldt (mergeBy cmp) [] . map (\x -> [x]) -} +#if !MIN_VERSION_base(4,7,1) -- | The 'sortOn' function provides the decorate-sort-undecorate idiom, -- also known as the \"Schwartzian transform\". sortOn :: Ord b => (a -> b) -> [a] -> [a]-sortOn f = map snd . sortOn' fst . map (\x -> (f x, x))+sortOn f = map snd . sortOn' fst . map (\x -> let y = f x in y `seq` (y, x))+#endif -- | This variant of 'sortOn' recomputes the sorting key every comparison. -- This can be better for functions that are cheap to compute.@@ -371,8 +378,8 @@ -- that duplicates are removed as it sorts. It is essentially the same -- implementation as @Data.List.sort@, with 'merge' replaced by 'union'. -- Thus the performance of 'nubSort' should better than or nearly equal--- to 'sort' alone. It is faster than @'nub' '.' 'sort'@ when the--- input contains significant quantities of duplicated elements.+-- to 'sort' alone. It is faster than both 'sort' and @'nub' '.' 'sort'@+-- when the input contains significant quantities of duplicated elements. nubSort :: Ord a => [a] -> [a] nubSort = nubSortBy compare @@ -408,7 +415,7 @@ -- | The 'nubSortOn' function provides decorate-sort-undecorate for 'nubSort'. nubSortOn :: Ord b => (a -> b) -> [a] -> [a]-nubSortOn f = map snd . nubSortOn' fst . map (\x -> (f x, x))+nubSortOn f = map snd . nubSortOn' fst . map (\x -> let y = f x in y `seq` (y, x)) -- | This variant of 'nubSortOn' recomputes the sorting key for each comparison nubSortOn' :: Ord b => (a -> b) -> [a] -> [a]
data-ordlist.cabal view
@@ -1,5 +1,5 @@ Name: data-ordlist-Version: 0.4.6+Version: 0.4.6.1 Description: This module provides set and multiset operations on ordered lists. License: BSD3@@ -23,4 +23,4 @@ source-repository this type: darcs location: http://hub.darcs.net/lpsmith/data-ordlist- tag: 0.4.6+ tag: 0.4.6.1