| Copyright | (c) Justin Le 2018 | 
|---|---|
| License | BSD3 | 
| Maintainer | justin@jle.im | 
| Stability | experimental | 
| Portability | non-portable | 
| Safe Haskell | None | 
| Language | Haskell2010 | 
AOC.Util
Description
Assorted utility functions and orphans used for solutions.
Synopsis
- strip :: String -> String
- stripNewline :: String -> String
- eitherToMaybe :: Alternative m => Either e a -> m a
- firstJust :: Foldable t => (a -> Maybe b) -> t a -> Maybe b
- maybeToEither :: MonadError e m => e -> Maybe a -> m a
- maybeAlt :: Alternative m => Maybe a -> m a
- traceShowIdMsg :: Show a => String -> a -> a
- traceShowMsg :: Show a => String -> a -> b -> b
Documentation
stripNewline :: String -> String Source #
Strip trailing newline
eitherToMaybe :: Alternative m => Either e a -> m a Source #
Convert an Either into a Maybe, or any Alternative instance,
 forgetting the error value.
firstJust :: Foldable t => (a -> Maybe b) -> t a -> Maybe b Source #
Like find, but instead of taking an a -> Bool, takes an a ->
 Maybe b and returns the first success.
maybeToEither :: MonadError e m => e -> Maybe a -> m a Source #
Convert a Maybe into an Either, or any MonadError instance, by
 providing an error value in case Nothing was given.
maybeAlt :: Alternative m => Maybe a -> m a Source #
Generalize a Maybe to any Alternative
traceShowIdMsg :: Show a => String -> a -> a Source #
Like traceShowId but with an extra message