Hoogle Search

Within LTS Haskell 24.6 (ghc-9.10.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. sortBy :: (a -> a -> Ordering) -> [a] -> [a]

    data-ordlist Data.List.Ordered

    The sortBy function is the non-overloaded version of sort. The argument must be finite. The supplied comparison relation is supposed to be reflexive and antisymmetric, otherwise, e. g., for _ _ -> GT, the ordered list simply does not exist. The relation is also expected to be transitive: if it is not then sortBy might fail to find an ordered permutation, even if it exists.

    Examples

    >>> sortBy (\(a,_) (b,_) -> compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
    [(1,"Hello"),(2,"world"),(4,"!")]
    

  2. sortOn :: Ord b => (a -> b) -> [a] -> [a]

    data-ordlist Data.List.Ordered

    Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (comparing f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform. Elements are arranged from lowest to highest, keeping duplicates in the order they appeared in the input. The argument must be finite.

    Examples

    >>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
    [(1,"Hello"),(2,"world"),(4,"!")]
    
    >>> sortOn length ["jim", "creed", "pam", "michael", "dwight", "kevin"]
    ["jim","pam","creed","kevin","dwight","michael"]
    

    Performance notes

    This function minimises the projections performed, by materialising the projections in an intermediate list. For trivial projections, you should prefer using sortBy with comparing, for example:
    >>> sortBy (comparing fst) [(3, 1), (2, 2), (1, 3)]
    [(1,3),(2,2),(3,1)]
    
    Or, for the exact same API as sortOn, you can use `sortBy . comparing`:
    >>> (sortBy . comparing) fst [(3, 1), (2, 2), (1, 3)]
    [(1,3),(2,2),(3,1)]
    

  3. sortOn' :: Ord b => (a -> b) -> [a] -> [a]

    data-ordlist Data.List.Ordered

    This variant of sortOn recomputes the sorting key every comparison. This can be better for functions that are cheap to compute. This is definitely better for projections, as the decorate-sort-undecorate saves nothing and adds two traversals of the list and extra memory allocation.

  4. sortDir :: Ord a => DirTree a -> DirTree a

    directory-tree System.Directory.Tree

    Recursively sort a directory tree according to the Ord instance

  5. sortDirShape :: DirTree a -> DirTree a

    directory-tree System.Directory.Tree

    Recursively sort a tree as in sortDir but ignore the file contents of a File constructor

  6. sortEvents :: [Event] -> [Event]

    ghc-events GHC.RTS.Events

    No documentation available.

  7. sortErrors :: Result GQLError a -> Result GQLError a

    morpheus-graphql-app Data.Morpheus.App.Internal.Resolving

    No documentation available.

  8. package sorted-list

    Type-enforced sorted lists and related functions. Type-enforced sorted lists and related functions. These are useful for:

    • Constraining the argument of a function to be a sorted list by stating in your type that the input list is a sorted list.
    • Avoiding sorting a list twice.
    • Creating a list that is sorted from the moment of its construction, so it doesn't have to be sorted later.
    • Performing list operations keeping the input list sorted.
    • Improving those list operations that can be benefited from the ordering of its elements.
    • Creating infinite lists that are sorted!
    • And more!
    If you are missing a feature, do not hesitate to ask by opening an issue at the bug-tracker.

  9. sortOn :: Ord b => (a -> b) -> [a] -> [a]

    speculate Test.Speculate.Utils

    Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (comparing f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform. Elements are arranged from lowest to highest, keeping duplicates in the order they appeared in the input. The argument must be finite.

    Examples

    >>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
    [(1,"Hello"),(2,"world"),(4,"!")]
    
    >>> sortOn length ["jim", "creed", "pam", "michael", "dwight", "kevin"]
    ["jim","pam","creed","kevin","dwight","michael"]
    

    Performance notes

    This function minimises the projections performed, by materialising the projections in an intermediate list. For trivial projections, you should prefer using sortBy with comparing, for example:
    >>> sortBy (comparing fst) [(3, 1), (2, 2), (1, 3)]
    [(1,3),(2,2),(3,1)]
    
    Or, for the exact same API as sortOn, you can use `sortBy . comparing`:
    >>> (sortBy . comparing) fst [(3, 1), (2, 2), (1, 3)]
    [(1,3),(2,2),(3,1)]
    

  10. sortedSubForests :: forall (p :: TreeOrder) (v :: Type -> Type) a . Forest p v a -> [Vector Int]

    ForestStructures Data.Forest.Static

    Returns the list of all sorted subsets of subforests in the forest. If the forest is given in pre-order, then The subsets are returned in reversed pre-order. TODO turn this into newtype vectors that enforce size >= 1.

Page 30 of many | Previous | Next