Skip to content

Utils

writeError

:: String -> IO ()

mapBoth

:: (a -> a) -> (a, a) -> (a, a)

mapPartTimes

:: (a -> a) -> ((a, a), (a, a)) -> ((a, a), (a, a))

mapFst

:: (a -> b) -> (a, c) -> (b, c)

mapSnd

:: (a -> b) -> (c, a) -> (c, b)

delta

:: Num a => (a, a) -> a

mid

:: Fractional a => (a, a) -> a

The midpoint of two values

removeCommon

:: Eq a => [a] -> [a] -> ([a], [a])

readMaybe

:: Read a => String -> Maybe a

(!!!)

:: [a] -> Int -> a

like !! selects nth element from xs, but wraps over at the end of xs

>>> map ((!!!) [1,3,5]) [0,1,2,3,4,5]
[1,3,5,1,3,5]

nth

:: Int -> [a] -> Maybe a

Safer version of !!

accumulate

:: Num t => [t] -> [t]

enumerate

:: [a] -> [(Int, a)]

enumerate a list of things

>>> enumerate ["foo","bar","baz"]
[(1,"foo"), (2,"bar"), (3,"baz")]

wordsBy

:: (a -> Bool) -> [a] -> [[a]]

split given list of a by given single a, e.g.

>>> wordsBy (== ':') "bd:3"
["bd", "3"]

matchMaybe

:: Maybe a -> Maybe a -> Maybe a

fromRight

:: b -> Either a b -> b