summaryrefslogtreecommitdiff
path: root/fig-utils/src/Fig/Prelude.hs
diff options
context:
space:
mode:
Diffstat (limited to 'fig-utils/src/Fig/Prelude.hs')
-rw-r--r--fig-utils/src/Fig/Prelude.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/fig-utils/src/Fig/Prelude.hs b/fig-utils/src/Fig/Prelude.hs
index 63ae360..5deb001 100644
--- a/fig-utils/src/Fig/Prelude.hs
+++ b/fig-utils/src/Fig/Prelude.hs
@@ -43,7 +43,7 @@ module Fig.Prelude
, module Control.Exception.Safe
, tshow
- , headMay, atMay
+ , headMay, lastMay, atMay
, hush
, throwLeft
, eitherToMaybe
@@ -107,6 +107,11 @@ headMay :: [a] -> Maybe a
headMay [] = Nothing
headMay (x:_) = Just x
+lastMay :: [a] -> Maybe a
+lastMay [] = Nothing
+lastMay [x] = Just x
+lastMay (_:xs) = lastMay xs
+
atMay :: [a] -> Int -> Maybe a
atMay [] _ = Nothing
atMay (x:_) 0 = Just x