1 module Hcompta.Lib.Foldable where
3 import Data.Maybe (listToMaybe, maybeToList)
4 import Data.Foldable (Foldable, concatMap)
6 -- | Return the first non-'Nothing' returned by the given function
7 -- applied on the elements of a 'Foldable'.
8 find :: Foldable t => (a -> Maybe b) -> t a -> Maybe b
9 find f = listToMaybe . Data.Foldable.concatMap (maybeToList . f)