Hoogle Search

Within LTS Haskell 24.4 (ghc-9.10.2)

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

  1. sortOn :: Ord b => (a -> b) -> Seq a -> Seq a

    containers Data.Sequence

    sortOn sorts the specified Seq by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (compare `on` 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. An example of using sortOn might be to sort a Seq of strings according to their length:

    sortOn length (fromList ["alligator", "monkey", "zebra"]) == fromList ["zebra", "monkey", "alligator"]
    
    If, instead, sortBy had been used, length would be evaluated on every comparison, giving <math> evaluations, rather than <math>. If f is very cheap (for example a record selector, or fst), sortBy (compare `on` f) will be faster than sortOn f.

  2. sortBy :: (a -> a -> Ordering) -> Seq a -> Seq a

    containers Data.Sequence.Internal.Sorting

    sortBy sorts the specified Seq according to the specified comparator. The sort is stable. If stability is not required, unstableSortBy can be slightly faster.

  3. sortOn :: Ord b => (a -> b) -> Seq a -> Seq a

    containers Data.Sequence.Internal.Sorting

    sortOn sorts the specified Seq by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (compare `on` 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. An example of using sortOn might be to sort a Seq of strings according to their length:

    sortOn length (fromList ["alligator", "monkey", "zebra"]) == fromList ["zebra", "monkey", "alligator"]
    
    If, instead, sortBy had been used, length would be evaluated on every comparison, giving <math> evaluations, rather than <math>. If f is very cheap (for example a record selector, or fst), sortBy (compare `on` f) will be faster than sortOn f.

  4. sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a

    base-compat Data.List.NonEmpty.Compat

    sortBy for NonEmpty, behaves the same as sortBy

  5. sortOn :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty a

    base-compat Data.List.NonEmpty.Compat

    Sort a NonEmpty on a user-supplied projection of its elements. See sortOn for more detailed information.

    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)]
    
    sortWith is an alias for `sortBy . comparing`.

  6. sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a

    base-compat Data.List.NonEmpty.Compat

    sortWith for NonEmpty, behaves the same as:

    sortBy . comparing
    

  7. sortOn :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty a

    extra Data.List.NonEmpty.Extra

    Sort a NonEmpty on a user-supplied projection of its elements. See sortOn for more detailed information.

    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)]
    
    sortWith is an alias for `sortBy . comparing`.

  8. sortPair :: Ord a => (a, a) -> (a, a)

    utility-ht Data.Tuple.HT

    This is convenient for quick hacks but I suggest that you better define a type for an ordered pair for your application at hand. This way, you can clearly see from the type that a pair is ordered.

  9. sortQuantVars :: [Var] -> [Var]

    ghc GHC.Core.Make

    Sort the variables, putting type and covars first, in scoped order, and then other Ids It is a deterministic sort, meaning it doesn't look at the values of Uniques. For explanation why it's important See Note [Unique Determinism] in GHC.Types.Unique.

  10. sORTKind_maybe :: Kind -> Maybe (TypeOrConstraint, Type)

    ghc GHC.Core.Type

    No documentation available.

Page 15 of many | Previous | Next