Portability | portable |
---|---|

Stability | provisional |

Maintainer | julian.fleischer@fu-berlin.de |

Safe Haskell | Safe |

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

.

- exhaustively :: Eq a => (a -> a) -> a -> a
- exhaustivelyBy :: (a -> a -> Bool) -> (a -> a) -> a -> a
- exhaustivelyM :: (Eq a, Monad m) => (a -> m a) -> a -> m a
- exhaustivelyByM :: Monad m => (a -> a -> Bool) -> (a -> m a) -> a -> m a
- uniqSort :: Ord a => [a] -> [a]
- aggregateBy :: (a -> a -> Ordering) -> [a] -> [[a]]
- aggregate :: Ord a => [a] -> [[a]]
- aggregateAL :: Ord a => [(a, b)] -> [(a, [b])]
- tr :: Eq a => a -> a -> [a] -> [a]
- count4 :: [[[[a]]]] -> Int
- count3 :: [[[a]]] -> Int
- count2 :: [[a]] -> Int
- count1 :: [a] -> Int
- segment3 :: Int -> [[[a]]] -> [[a]]
- segment2 :: Int -> [[a]] -> [[a]]
- breakLast :: [a] -> ([a], a)
- uneither :: Either a a -> a

# 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

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.

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.