hx-0.4: Haskell extras (missing utility functions).

Portabilityportable
Stabilityprovisional
Maintainerjulian.fleischer@fu-berlin.de
Safe HaskellSafe

Haskell.X

Description

Haskell extra utility functions. Best imported by import qualified Haskell.X as X.

Synopsis

Documentation

exhaustively :: Eq a => (a -> a) -> a -> aSource

Apply a function exhaustively.

exhaustivelyBy :: (a -> a -> Bool) -> (a -> a) -> a -> aSource

Apply a function exhaustively.

exhaustivelyM :: (Eq a, Monad m) => (a -> m a) -> a -> m aSource

Apply a monadic function exhaustively.

exhaustivelyByM :: Monad m => (a -> a -> Bool) -> (a -> m a) -> a -> m aSource

Apply a monadic function exhaustively.

uniqSort :: Ord a => [a] -> [a]Source

Sort a list and leave out duplicates. Like nub . sort but faster.

aggregateBy :: (a -> a -> Ordering) -> [a] -> [[a]]Source

Sort, then group

aggregate :: Ord a => [a] -> [[a]]Source

Sort, then group

aggregateAL :: Ord a => [(a, b)] -> [(a, [b])]Source

Aggregate an association list, such that keys become unique.

(c)

tr :: Eq a => a -> a -> [a] -> [a]Source

Replace all occurences of a specific thing in a list of things another thing.

count4 :: [[[[a]]]] -> IntSource

Counts how many elements there are in a 4 levels deep list.

count3 :: [[[a]]] -> IntSource

Counts how many elements there are in a 3 levels deep list.

count2 :: [[a]] -> IntSource

Counts how many elements there are in a 2 levels deep list.

count1 :: [a] -> IntSource

Counts how many elements there are in a 1 level deep list.

segment3 :: Int -> [[[a]]] -> [[a]]Source

Segments the elements of a 3 levels deep list such that the segments contain at least the specified amount of elements, without breaking apart any subsegments.

segment2 :: Int -> [[a]] -> [[a]]Source

Segments the elements of a 2 levels deep list such that the segments contain at least the specified amount of elements, without breaking apart any subsegments.

breakLast :: [a] -> ([a], a)Source

breakLast xs == (init xs, last xs)

uneither :: Either a a -> aSource

If an Either contains the same types in Left and Right, unify it by dropping the Either wrapper.