Cabal
CopyrightIsaac Jones 2003-2004
Duncan Coutts 2007
LicenseBSD3
Maintainercabal-devel@haskell.org
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Documentation

type Flag = Last Source #

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.

Isomorphic to Maybe a.

pattern Flag :: a -> Last a Source #

pattern NoFlag :: Last a Source #

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

Returns True only if every Flag Bool value is Flag True, else False.

toFlag :: a -> Flag a Source #

Wraps a value in Flag.

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

Extracts a value from a Flag, and throws an exception on NoFlag.

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

Extracts a value from a Flag, and returns the default value on NoFlag.

flagElim :: b -> (a -> b) -> Flag a -> b Source #

Pushes a function through a Flag value, and returns a default if the Flag value is NoFlag.

Since: 3.4.0.0

flagToMaybe :: Flag a -> Maybe a Source #

Converts a Flag value to a Maybe value.

flagToList :: Flag a -> [a] Source #

Converts a Flag value to a list.

maybeToFlag :: Maybe a -> Flag a Source #

Converts a Maybe value to a Flag value.

mergeListFlag :: Flag [a] -> Flag [a] -> Flag [a] Source #

Merge the elements of a list Flag with another list Flag.

class BooleanFlag a where Source #

Types that represent boolean flags.

Methods

asBool :: a -> Bool Source #

Instances

Instances details
BooleanFlag Bool Source # 
Instance details

Defined in Distribution.Simple.Flag

Methods

asBool :: Bool -> Bool Source #