code-conjure-0.3.0: conjure Haskell functions out of partial definitions
Copyright(c) 2021 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Conjure.Utils

Description

An internal module of Conjure. This exports List, Maybe, Function and a few other simple utitilites.

Synopsis

Documentation

module Data.List

module Data.Maybe

module Data.Tuple

count :: (a -> Bool) -> [a] -> Int Source #

nubOn :: Eq b => (a -> b) -> [a] -> [a] Source #

iterateUntil :: (a -> a -> Bool) -> (a -> a) -> a -> a Source #

mzip :: Monoid a => [a] -> [a] -> [a] Source #

groupOn :: Eq b => (a -> b) -> [a] -> [[a]] Source #

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

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 from lowest to highest, keeping duplicates in the order they appeared in the input.

>>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
[(1,"Hello"),(2,"world"),(4,"!")]

Since: base-4.8.0.0