Distribution.Simple.Flag

Cabal-2.4.0.1: A framework for packaging Haskell software

Copyright | Isaac Jones 2003-2004 Duncan Coutts 2007
License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | None
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

- data Flag a
  - = Flag a
  - | NoFlag
- allFlags :: [Flag Bool] -> Flag Bool
- toFlag :: a -> Flag a
- fromFlag :: WithCallStack (Flag a -> a)
- fromFlagOrDefault :: a -> Flag a -> a
- flagToMaybe :: Flag a -> Maybe a
- flagToList :: Flag a -> [a]
- maybeToFlag :: Maybe a -> Flag a
- class BooleanFlag a where
  - asBool :: a -> Bool

# Documentation

data Flag a #

All flags are monoids, they come in two flavours:

1. list flags eg

    --ghc-option=foo --ghc-option=bar

gives us all the values ["foo", "bar"]

1. 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.

Constructors

Flag a |
NoFlag |

Instances

Functor Flag # |
Instance details Defined in Distribution.Simple.Flag Methods fmap :: (a -> b) -> Flag a -> Flag b Source # (<$) :: a -> Flag b -> Flag a Source #
Applicative Flag # |
Instance details Defined in Distribution.Simple.Flag Methods pure :: a -> Flag a Source # (<*>) :: Flag (a -> b) -> Flag a -> Flag b Source # liftA2 :: (a -> b -> c) -> Flag a -> Flag b -> Flag c Source # (*>) :: Flag a -> Flag b -> Flag b Source # (<*) :: Flag a -> Flag b -> Flag a Source #
Bounded a => Bounded (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods minBound :: Flag a Source # maxBound :: Flag a Source #
Enum a => Enum (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods succ :: Flag a -> Flag a Source # pred :: Flag a -> Flag a Source # toEnum :: Int -> Flag a Source # fromEnum :: Flag a -> Int Source # enumFrom :: Flag a -> [Flag a] Source # enumFromThen :: Flag a -> Flag a -> [Flag a] Source # enumFromTo :: Flag a -> Flag a -> [Flag a] Source # enumFromThenTo :: Flag a -> Flag a -> Flag a -> [Flag a] Source #
Eq a => Eq (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods (==) :: Flag a -> Flag a -> Bool # (/=) :: Flag a -> Flag a -> Bool #
Read a => Read (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods readsPrec :: Int -> ReadS (Flag a) Source # readList :: ReadS [Flag a] Source # readPrec :: ReadPrec (Flag a) Source # readListPrec :: ReadPrec [Flag a] Source #
Show a => Show (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods showsPrec :: Int -> Flag a -> ShowS Source # show :: Flag a -> String Source # showList :: [Flag a] -> ShowS Source #
Generic (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Associated Types type Rep (Flag a) :: Type -> Type Source # Methods from :: Flag a -> Rep (Flag a) x Source # to :: Rep (Flag a) x -> Flag a Source #
Semigroup (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods (<>) :: Flag a -> Flag a -> Flag a Source # sconcat :: NonEmpty (Flag a) -> Flag a Source # stimes :: Integral b => b -> Flag a -> Flag a Source #
Monoid (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods mempty :: Flag a Source # mappend :: Flag a -> Flag a -> Flag a Source # mconcat :: [Flag a] -> Flag a Source #
Binary a => Binary (Flag a) # |
Instance details Defined in Distribution.Simple.Flag Methods put :: Flag a -> Put Source # get :: Get (Flag a) Source # putList :: [Flag a] -> Put Source #
type Rep (Flag a) # |
Instance details Defined in Distribution.Simple.Flag type Rep (Flag a) = D1 (MetaData "Flag" "Distribution.Simple.Flag" "Cabal-2.4.0.1" False) (C1 (MetaCons "Flag" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)) :+: C1 (MetaCons "NoFlag" PrefixI False) (U1 :: Type -> Type))

allFlags :: [Flag Bool] -> Flag Bool #

toFlag :: a -> Flag a #

fromFlag :: WithCallStack (Flag a -> a) #

fromFlagOrDefault :: a -> Flag a -> a #

flagToMaybe :: Flag a -> Maybe a #

flagToList :: Flag a -> [a] #

maybeToFlag :: Maybe a -> Flag a #

class BooleanFlag a where #

Types that represent boolean flags.

Methods

asBool :: a -> Bool #

Instances

BooleanFlag Bool # |
Instance details Defined in Distribution.Simple.Flag Methods asBool :: Bool -> Bool #