diff options
Diffstat (limited to 'fig-utils/src/Fig/Prelude.hs')
| -rw-r--r-- | fig-utils/src/Fig/Prelude.hs | 5 |
1 files changed, 5 insertions, 0 deletions
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 |
