module Utils where import Control.Monad.IO.Class import Data.List.Extra (stripSuffix) import Data.Maybe (isJust) -- | A shortcut for `liftIO`. io :: MonadIO m => IO a -> m a io = liftIO -- | A helper for throwing an error if something is `Nothing` just :: String -> Maybe a -> a just _ (Just val) = val just err Nothing = error ("Missing: " ++ err) -- | Test for whether something listy has a suffix hasSuffix :: Eq a => [a] -> [a] -> Bool hasSuffix s = isJust . stripSuffix s -- | The same second as from arrows et al. second :: (a -> b) -> (c, a) -> (c, b) second f (a, b) = (a, f b)