From 7be5db06389670d4266aca1e4845fc0e20ae1ff9 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Fri, 31 Jul 2026 19:04:26 -0400 Subject: utils: Update prelude --- fig-utils/src/Fig/Prelude.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 -- cgit v1.3.1