| Safe Haskell | Safe-Inferred |
|---|
Game.Goatee.Common
Description
Common utilities used throughout the project.
- listDeleteIndex :: Int -> [a] -> [a]
- listReplace :: Eq a => a -> a -> [a] -> [a]
- listUpdate :: Show a => (a -> a) -> Int -> [a] -> [a]
- fromLeft :: Either a b -> a
- fromRight :: Either a b -> b
- onLeft :: (a -> c) -> Either a b -> Either c b
- onRight :: (b -> c) -> Either a b -> Either a c
- andEithers :: [Either a b] -> Either [a] [b]
- for :: [a] -> (a -> b) -> [b]
- mapTuple :: (a -> b) -> (a, a) -> (b, b)
- whenMaybe :: Monad m => Maybe a -> (a -> m ()) -> m ()
- cond :: a -> [(Bool, a)] -> a
- if' :: a -> a -> Bool -> a
- andM :: Monad m => [m Bool] -> m Bool
- forIndexM_ :: Monad m => [a] -> (Int -> a -> m ()) -> m ()
- whileM :: Monad m => m Bool -> m () -> m ()
- whileM' :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()
- doWhileM :: Monad m => a -> (a -> m (Either b a)) -> m b
- newtype Seq m = Seq (m ())
Documentation
listDeleteIndex :: Int -> [a] -> [a]Source
Drops the element at an index from a list. If the index is out of bounds then the list is returned unmodified.
listReplace :: Eq a => a -> a -> [a] -> [a]Source
listReplace old new list replaces all occurrences of old with new in
list.
listUpdate :: Show a => (a -> a) -> Int -> [a] -> [a]Source
Modifies the element at a specific index in a list.
onLeft :: (a -> c) -> Either a b -> Either c bSource
Transforms the left value of an Either, leaving a right value alone.
andEithers :: [Either a b] -> Either [a] [b]Source
whenMaybe :: Monad m => Maybe a -> (a -> m ()) -> m ()Source
Executes the monadic function if a Maybe contains a value.
cond :: a -> [(Bool, a)] -> aSource
Finds the first tuple whose first element is true, and returns its second
element. If all of the first values are false, then the first argument to
cond is returned instead.
andM :: Monad m => [m Bool] -> m BoolSource
and in a monad. Executes the actions in the list in order. If any
action returns false then the remaining actions are skipped and the result is
false. Otherwise all actions returned true, and the result is true. An
empty list returns true.
forIndexM_ :: Monad m => [a] -> (Int -> a -> m ()) -> m ()Source
forM_ that also passes in the index of each element.
whileM :: Monad m => m Bool -> m () -> m ()Source
whileM test body repeatedly evaluates test until it returns false.
Every time test returns true, body is executed once.