Copyright | Isaac Jones 2003-2004 Duncan Coutts 2007 |
---|---|
License | BSD3 |
Maintainer | cabal-devel@haskell.org |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Defines the Flag
type and it's Monoid
instance, see
http://www.haskell.org/pipermail/cabal-devel/2007-December/001509.html
for an explanation.
Split off from Distribution.Simple.Setup to break import cycles.
Synopsis
- data Flag a
- allFlags :: [Flag Bool] -> Flag Bool
- toFlag :: a -> Flag a
- fromFlag :: WithCallStack (Flag a -> a)
- fromFlagOrDefault :: a -> Flag a -> a
- flagElim :: b -> (a -> b) -> Flag a -> b
- flagToMaybe :: Flag a -> Maybe a
- flagToList :: Flag a -> [a]
- maybeToFlag :: Maybe a -> Flag a
- mergeListFlag :: Flag [a] -> Flag [a] -> Flag [a]
- class BooleanFlag a where
Documentation
All flags are monoids, they come in two flavours:
- list flags eg
--ghc-option=foo --ghc-option=bar
gives us all the values ["foo", "bar"]
- singular value flags, eg:
--enable-foo --disable-foo
gives us Just False
So, this Flag
type is for the latter singular kind of flag.
Its monoid instance gives us the behaviour where it starts out as
NoFlag
and later flags override earlier ones.
Isomorphic to Maybe
a.
Instances
Foldable Flag Source # | |
Defined in Distribution.Simple.Flag fold :: Monoid m => Flag m -> m # foldMap :: Monoid m => (a -> m) -> Flag a -> m # foldMap' :: Monoid m => (a -> m) -> Flag a -> m # foldr :: (a -> b -> b) -> b -> Flag a -> b # foldr' :: (a -> b -> b) -> b -> Flag a -> b # foldl :: (b -> a -> b) -> b -> Flag a -> b # foldl' :: (b -> a -> b) -> b -> Flag a -> b # foldr1 :: (a -> a -> a) -> Flag a -> a # foldl1 :: (a -> a -> a) -> Flag a -> a # elem :: Eq a => a -> Flag a -> Bool # maximum :: Ord a => Flag a -> a # | |
Traversable Flag Source # | |
Applicative Flag Source # | |
Functor Flag Source # | |
Structured a => Structured (Flag a) Source # | |
Defined in Distribution.Simple.Flag structure :: Proxy (Flag a) -> Structure structureHash' :: Tagged (Flag a) MD5 | |
Monoid (Flag a) Source # | |
Semigroup (Flag a) Source # | |
Bounded a => Bounded (Flag a) Source # | |
Enum a => Enum (Flag a) Source # | |
Defined in Distribution.Simple.Flag | |
Generic (Flag a) Source # | |
Read a => Read (Flag a) Source # | |
Show a => Show (Flag a) Source # | |
Binary a => Binary (Flag a) Source # | |
Eq a => Eq (Flag a) Source # | |
type Rep (Flag a) Source # | |
Defined in Distribution.Simple.Flag type Rep (Flag a) = D1 ('MetaData "Flag" "Distribution.Simple.Flag" "Cabal-3.14.0.0-inplace" 'False) (C1 ('MetaCons "Flag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: C1 ('MetaCons "NoFlag" 'PrefixI 'False) (U1 :: Type -> Type)) |
fromFlag :: WithCallStack (Flag a -> a) Source #
fromFlagOrDefault :: a -> Flag a -> a Source #
flagToList :: Flag a -> [a] Source #
Converts a Flag
value to a list.