aboutsummaryrefslogtreecommitdiff
path: root/Utils.hs
blob: d058c1c57478c41f7b4e5aad6696ee5c9c4d4b14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

module Utils where
import Data.Maybe (isJust)
import Data.List.Extra (stripSuffix)
import Control.Monad.IO.Class

-- | 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