Safe Haskell | None |
---|---|

Language | Haskell2010 |

Miscellaneous helper functions

- debug :: Show a => a -> b -> b
- swap :: (a, b) -> (b, a)
- pairs :: [a] -> [(a, a)]
- pairsWith :: (a -> a -> b) -> [a] -> [b]
- sum' :: Num a => [a] -> a
- equating :: Eq b => (a -> b) -> a -> a -> Bool
- reverseOrdering :: Ordering -> Ordering
- reverseCompare :: Ord a => a -> a -> Ordering
- reverseSort :: Ord a => [a] -> [a]
- groupSortBy :: (Eq b, Ord b) => (a -> b) -> [a] -> [[a]]
- nubOrd :: Ord a => [a] -> [a]
- mapWithLast :: (Bool -> a -> b) -> [a] -> [b]
- mapWithFirst :: (Bool -> a -> b) -> [a] -> [b]
- mapWithFirstLast :: (Bool -> Bool -> a -> b) -> [a] -> [b]
- mkLinesUniformWidth :: [String] -> [String]
- mkBlocksUniformHeight :: [[String]] -> [[String]]
- mkUniformBlocks :: [[String]] -> [[String]]
- hConcatLines :: [[String]] -> [String]
- vConcatLines :: [[String]] -> [String]
- count :: Eq a => a -> [a] -> Int
- histogram :: (Eq a, Ord a) => [a] -> [(a, Int)]
- fromJust :: Maybe a -> a
- intToBool :: Int -> Bool
- boolToInt :: Bool -> Int
- nest :: Int -> (a -> a) -> a -> a
- unfold1 :: (a -> Maybe a) -> a -> [a]
- unfold :: (b -> (a, Maybe b)) -> b -> [a]
- unfoldEither :: (b -> Either c (b, a)) -> b -> (c, [a])
- unfoldM :: Monad m => (b -> m (a, Maybe b)) -> b -> m [a]
- mapAccumM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y])
- longZipWith :: a -> b -> (a -> b -> c) -> [a] -> [b] -> [c]

# debugging

# pairs

# lists

# equality and ordering

reverseCompare :: Ord a => a -> a -> Ordering Source

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

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

# first / last

mapWithLast :: (Bool -> a -> b) -> [a] -> [b] Source

The boolean argument will `True`

only for the last element

mapWithFirst :: (Bool -> a -> b) -> [a] -> [b] Source

mapWithFirstLast :: (Bool -> Bool -> a -> b) -> [a] -> [b] Source

# older helpers for ASCII drawing

mkLinesUniformWidth :: [String] -> [String] Source

extend lines with spaces so that they have the same line

mkBlocksUniformHeight :: [[String]] -> [[String]] Source

mkUniformBlocks :: [[String]] -> [[String]] Source

hConcatLines :: [[String]] -> [String] Source

vConcatLines :: [[String]] -> [String] Source

# counting

# maybe

# bool

# iteration

unfoldEither :: (b -> Either c (b, a)) -> b -> (c, [a]) Source

# long zipwith

longZipWith :: a -> b -> (a -> b -> c) -> [a] -> [b] -> [c] Source