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