]> Git — Sourcephile - comptalang.git/blob - lib/Hcompta/Lib/Foldable.hs
Correction : Format.Ledger.Read.posting : permet des espaces.
[comptalang.git] / lib / Hcompta / Lib / Foldable.hs
1 module Hcompta.Lib.Foldable where
2
3 import Data.Maybe (listToMaybe, maybeToList)
4 import Data.Foldable (Foldable, concatMap)
5
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)