    module Data.Bitmask (foldFlags) where

    import Prelude hiding (foldl)

    import Data.Bits
    import Data.Foldable

    foldFlags :: (Bits b, Foldable f, Num b) => (flag -> b) -> f flag -> b
    foldFlags :: forall b (f :: Type -> Type) flag.
    (Bits b, Foldable f, Num b) =>
    (flag -> b) -> f flag -> b
    foldFlags flag -> b
    f = (b -> flag -> b) -> b -> f flag -> b
    forall b a. (b -> a -> b) -> b -> f a -> b
    forall (t :: Type -> Type) b a.
    Foldable t =>
    (b -> a -> b) -> b -> t a -> b
    foldl (\b
    a flag
    b -> b
    a b -> b -> b
    forall a. Bits a => a -> a -> a
    .|. flag -> b
    f flag
    b) b
    0