aboutsummaryrefslogtreecommitdiff
path: root/Utils.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2023-05-24 23:43:33 +0200
committerMirek Kratochvil <exa.exa@gmail.com>2023-05-24 23:43:33 +0200
commit66fb2f5f08a2dab465784c55ff694c08736b7d3e (patch)
tree78f7f253ee975a862cf3afacc3f178640b256141 /Utils.hs
parent1a24212ec42c9ae93baa13fe30000f5e47176b62 (diff)
downloadreploy-66fb2f5f08a2dab465784c55ff694c08736b7d3e.tar.gz
reploy-66fb2f5f08a2dab465784c55ff694c08736b7d3e.tar.bz2
render, install files
Diffstat (limited to 'Utils.hs')
-rw-r--r--Utils.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/Utils.hs b/Utils.hs
new file mode 100644
index 0000000..d058c1c
--- /dev/null
+++ b/Utils.hs
@@ -0,0 +1,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