| Copyright | Isaac Jones 2003-2004 Duncan Coutts 2007 |
|---|---|
| License | BSD3 |
| Maintainer | [email protected] |
| Portability | portable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Distribution.Simple.Flag
Description
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
- type Flag = Last
- pattern Flag :: a -> Last a
- pattern NoFlag :: Last 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.
fromFlag :: WithCallStack (Flag a -> a) Source #
fromFlagOrDefault :: a -> Flag a -> a Source #
flagToList :: Flag a -> [a] Source #
Converts a Flag value to a list.