summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-07-31 19:04:26 -0400
committerLLLL Colonq <llll@colonq>2026-07-31 19:05:12 -0400
commit7be5db06389670d4266aca1e4845fc0e20ae1ff9 (patch)
tree0b72e57a1647dad6ffea6f5336963bbff81bb46b
parenta3bf461cfab5ccfac82ddd264654c9c1d2bfe14c (diff)
utils: Update prelude
-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