From cb85036ca25cd9e13e4e959e105b88bb73dbf9e5 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Sat, 7 Mar 2026 23:41:50 -0500 Subject: Refactor, use app tokens --- fig-utils/src/Fig/Prelude.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fig-utils/src/Fig/Prelude.hs') diff --git a/fig-utils/src/Fig/Prelude.hs b/fig-utils/src/Fig/Prelude.hs index fbbd31c..63ae360 100644 --- a/fig-utils/src/Fig/Prelude.hs +++ b/fig-utils/src/Fig/Prelude.hs @@ -44,6 +44,7 @@ module Fig.Prelude , tshow , headMay, atMay + , hush , throwLeft , eitherToMaybe , log @@ -111,6 +112,10 @@ atMay [] _ = Nothing atMay (x:_) 0 = Just x atMay (_:xs) n = atMay xs $ n - 1 +hush :: Either a b -> Maybe b +hush (Left _) = Nothing +hush (Right x) = Just x + throwLeft :: (Exception e, MonadThrow m) => (b -> e) -> Either b a -> m a throwLeft f (Left x) = throwM $ f x throwLeft _ (Right x) = pure x -- cgit v1.2.3