chr-data-0.1.0.1: Datatypes required for chr library

Safe HaskellSafe
LanguageHaskell2010

CHR.Utils

Contents

Description

Various utils. Relic of the past, requires adaption to newer general purpose libs

Synopsis

Documentation

maybeNull :: r -> ([a] -> r) -> [a] -> r Source #

maybeHd :: r -> (a -> r) -> [a] -> r Source #

splitPlaces Source #

Arguments

:: [Int]

places

-> [e] 
-> [[e]] 

Split at index places (inspired by/from split package). Places should be increasing, starting with an index >= 0. The number of sublists returned is one higher than the number of places.

Examples: >>> splitPlaces [2,3] [1,2,3,4,5,6,7] [[1,2],[3],[4,5,6,7]]

>>> splitPlaces [6,7] [1,2,3,4,5,6,7]
[[1,2,3,4,5,6],[7],[]]
>>> splitPlaces [0,7] [1,2,3,4,5,6,7]
[[],[1,2,3,4,5,6,7],[]]
>>> splitPlaces [0,1,2,3,4,5,6,7] [1,2,3,4,5,6,7]
[[],[1],[2],[3],[4],[5],[6],[7],[]]

combineToDistinguishedEltsBy :: (e -> e -> Bool) -> [[e]] -> [[e]] Source #

Combine [[x1..xn],..,[y1..ym]] to [[x1..y1],[x2..y1],..,[xn..ym]]. Each element [xi..yi] is distinct based on the the key k in xi==(k,_)

zipWithN :: ([x] -> y) -> [[x]] -> [y] Source #

orderingLexic :: Ordering -> Ordering -> Ordering Source #

Reduce compare results lexicographically using a continuation ordering

orderingLexicList :: [Ordering] -> Ordering Source #

Reduce compare results lexicographically to one compare result

panic :: [Char] -> a Source #

Error, with message

isSortedByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> Bool Source #

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

A slightly more lazy version of Data.List.sortOn. See also https://github.com/UU-ComputerScience/uhc-util/issues/5 .

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

sortByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [a] Source #

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

groupByOn :: (b -> b -> Bool) -> (a -> b) -> [a] -> [[a]] Source #

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

groupSortByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [[a]] Source #

Maybe