Cabal-syntax-3.14.1.0: A library for working with .cabal files
Safe HaskellNone
LanguageHaskell2010

Distribution.Types.Flag

Synopsis

Package flag

data PackageFlag Source #

A flag can represent a feature to be included, or a way of linking a target against its dependencies, or in fact whatever you can think of.

Instances

Instances details
Structured PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

Binary PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

NFData PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

Methods

rnf :: PackageFlag -> () Source #

Data PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PackageFlag -> c PackageFlag #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c PackageFlag #

toConstr :: PackageFlag -> Constr #

dataTypeOf :: PackageFlag -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c PackageFlag) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PackageFlag) #

gmapT :: (forall b. Data b => b -> b) -> PackageFlag -> PackageFlag #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PackageFlag -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PackageFlag -> r #

gmapQ :: (forall d. Data d => d -> u) -> PackageFlag -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> PackageFlag -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> PackageFlag -> m PackageFlag #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PackageFlag -> m PackageFlag #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PackageFlag -> m PackageFlag #

Generic PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

Associated Types

type Rep PackageFlag 
Instance details

Defined in Distribution.Types.Flag

type Rep PackageFlag = D1 ('MetaData "PackageFlag" "Distribution.Types.Flag" "Cabal-syntax-3.14.1.0-e2ce" 'False) (C1 ('MetaCons "MkPackageFlag" 'PrefixI 'True) ((S1 ('MetaSel ('Just "flagName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FlagName) :*: S1 ('MetaSel ('Just "flagDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :*: (S1 ('MetaSel ('Just "flagDefault") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "flagManual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))
Show PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

Eq PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

type Rep PackageFlag Source # 
Instance details

Defined in Distribution.Types.Flag

type Rep PackageFlag = D1 ('MetaData "PackageFlag" "Distribution.Types.Flag" "Cabal-syntax-3.14.1.0-e2ce" 'False) (C1 ('MetaCons "MkPackageFlag" 'PrefixI 'True) ((S1 ('MetaSel ('Just "flagName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FlagName) :*: S1 ('MetaSel ('Just "flagDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :*: (S1 ('MetaSel ('Just "flagDefault") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "flagManual") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))

emptyFlag :: FlagName -> PackageFlag Source #

A PackageFlag initialized with default parameters.

Flag name

data FlagName Source #

A FlagName is the name of a user-defined configuration flag

Use mkFlagName and unFlagName to convert from/to a String.

This type is opaque since Cabal-2.0

Since: Cabal-syntax-2.0.0.2

Instances

Instances details
Parsec FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Pretty FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Structured FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Binary FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

NFData FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Methods

rnf :: FlagName -> () Source #

Data FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FlagName -> c FlagName #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c FlagName #

toConstr :: FlagName -> Constr #

dataTypeOf :: FlagName -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c FlagName) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c FlagName) #

gmapT :: (forall b. Data b => b -> b) -> FlagName -> FlagName #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FlagName -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FlagName -> r #

gmapQ :: (forall d. Data d => d -> u) -> FlagName -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> FlagName -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> FlagName -> m FlagName #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FlagName -> m FlagName #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FlagName -> m FlagName #

IsString FlagName Source #

mkFlagName

Since: Cabal-syntax-2.0.0.2

Instance details

Defined in Distribution.Types.Flag

Generic FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Associated Types

type Rep FlagName 
Instance details

Defined in Distribution.Types.Flag

type Rep FlagName = D1 ('MetaData "FlagName" "Distribution.Types.Flag" "Cabal-syntax-3.14.1.0-e2ce" 'True) (C1 ('MetaCons "FlagName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortText)))

Methods

from :: FlagName -> Rep FlagName x #

to :: Rep FlagName x -> FlagName #

Read FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Show FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Eq FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

Ord FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

type Rep FlagName Source # 
Instance details

Defined in Distribution.Types.Flag

type Rep FlagName = D1 ('MetaData "FlagName" "Distribution.Types.Flag" "Cabal-syntax-3.14.1.0-e2ce" 'True) (C1 ('MetaCons "FlagName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortText)))

mkFlagName :: String -> FlagName Source #

Construct a FlagName from a String

mkFlagName is the inverse to unFlagName

Note: No validations are performed to ensure that the resulting FlagName is valid

Since: Cabal-syntax-2.0.0.2

unFlagName :: FlagName -> String Source #

Convert FlagName to String

Since: Cabal-syntax-2.0.0.2

Flag assignment

data FlagAssignment Source #

A FlagAssignment is a total or partial mapping of FlagNames to Bool flag values. It represents the flags chosen by the user or discovered during configuration. For example --flags=foo --flags=-bar becomes [("foo", True), ("bar", False)]

TODO: Why we record the multiplicity of the flag?

Instances

Instances details
Parsec FlagAssignment Source #
>>> simpleParsec "" :: Maybe FlagAssignment
Just (fromList [])
>>> simpleParsec "+foo -bar" :: Maybe FlagAssignment
Just (fromList [(FlagName "bar",(1,False)),(FlagName "foo",(1,True))])
>>> simpleParsec "-none -any" :: Maybe FlagAssignment
Just (fromList [(FlagName "any",(1,False)),(FlagName "none",(1,False))])
>>> simpleParsec "+foo -foo +foo +foo" :: Maybe FlagAssignment
Just (fromList [(FlagName "foo",(4,True))])
>>> simpleParsec "+foo -bar baz" :: Maybe FlagAssignment
Nothing

Issue #7279 was fixed in Cabal-3.8

>>> explicitEitherParsec (parsecCommaList parsec) "+foo , -bar" :: Either String [FlagAssignment]
Right [fromList [(FlagName "foo",(1,True))],fromList [(FlagName "bar",(1,False))]]
>>> explicitEitherParsec (parsecCommaList parsecFlagAssignmentNonEmpty) "+foo , -bar" :: Either String [FlagAssignment]
Right [fromList [(FlagName "foo",(1,True))],fromList [(FlagName "bar",(1,False))]]
>>> simpleParsec "+foo+foo" :: Maybe FlagAssignment
Nothing

Since: Cabal-syntax-3.4.0.0

Instance details

Defined in Distribution.Types.Flag

Pretty FlagAssignment Source #

Since: Cabal-syntax-3.4.0.0

Instance details

Defined in Distribution.Types.Flag

Structured FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

Binary FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

NFData FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

Methods

rnf :: FlagAssignment -> () Source #

Monoid FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

Semigroup FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

Generic FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

Associated Types

type Rep FlagAssignment 
Instance details

Defined in Distribution.Types.Flag

type Rep FlagAssignment = D1 ('MetaData "FlagAssignment" "Distribution.Types.Flag" "Cabal-syntax-3.14.1.0-e2ce" 'True) (C1 ('MetaCons "FlagAssignment" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFlagAssignment") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map FlagName (Int, Bool)))))
Read FlagAssignment Source #

Since: Cabal-syntax-2.2.0

Instance details

Defined in Distribution.Types.Flag

Show FlagAssignment Source #

Since: Cabal-syntax-2.2.0

Instance details

Defined in Distribution.Types.Flag

Eq FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

Ord FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

type Rep FlagAssignment Source # 
Instance details

Defined in Distribution.Types.Flag

type Rep FlagAssignment = D1 ('MetaData "FlagAssignment" "Distribution.Types.Flag" "Cabal-syntax-3.14.1.0-e2ce" 'True) (C1 ('MetaCons "FlagAssignment" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFlagAssignment") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map FlagName (Int, Bool)))))

mkFlagAssignment :: [(FlagName, Bool)] -> FlagAssignment Source #

Construct a FlagAssignment from a list of flag/value pairs.

If duplicate flags occur in the input list, the later entries in the list will take precedence.

Since: Cabal-syntax-2.2.0

unFlagAssignment :: FlagAssignment -> [(FlagName, Bool)] Source #

Deconstruct a FlagAssignment into a list of flag/value pairs.

 null (findDuplicateFlagAssignments fa) ==> (mkFlagAssignment . unFlagAssignment) fa == fa

Since: Cabal-syntax-2.2.0

lookupFlagAssignment :: FlagName -> FlagAssignment -> Maybe Bool Source #

Lookup the value for a flag

Returns Nothing if the flag isn't contained in the FlagAssignment.

Since: Cabal-syntax-2.2.0

insertFlagAssignment :: FlagName -> Bool -> FlagAssignment -> FlagAssignment Source #

Insert or update the boolean value of a flag.

If the flag is already present in the FlagAssignment, the value will be updated and the fact that multiple values have been provided for that flag will be recorded so that a warning can be generated later on.

Since: Cabal-syntax-2.2.0

diffFlagAssignment :: FlagAssignment -> FlagAssignment -> FlagAssignment Source #

Remove all flag-assignments from the first FlagAssignment that are contained in the second FlagAssignment

NB/TODO: This currently only removes flag assignments which also match the value assignment! We should review the code which uses this operation to figure out if this it's not enough to only compare the flagnames without the values.

Since: Cabal-syntax-2.2.0

findDuplicateFlagAssignments :: FlagAssignment -> [FlagName] Source #

Find the FlagNames that have been listed more than once.

Since: Cabal-syntax-2.2.0

nullFlagAssignment :: FlagAssignment -> Bool Source #

Test whether FlagAssignment is empty.

Since: Cabal-syntax-2.2.0

showFlagValue :: (FlagName, Bool) -> String Source #

String representation of a flag-value pair.

dispFlagAssignment :: FlagAssignment -> Doc Source #

Pretty-prints a flag assignment.

showFlagAssignment :: FlagAssignment -> String Source #

Show flag assignment.

Since: Cabal-syntax-3.4.0.0

parsecFlagAssignment :: CabalParsing m => m FlagAssignment Source #

Parses a flag assignment.

parsecFlagAssignmentNonEmpty :: CabalParsing m => m FlagAssignment Source #

Parse a non-empty flag assignment

The flags have to explicitly start with minus or plus.

Since: Cabal-syntax-3.4.0.0

Legacy formats

legacyShowFlagAssignment :: FlagAssignment -> String Source #

We need this as far as we support custom setups older than 2.2.0.0

Since: Cabal-syntax-3.4.0.0

legacyShowFlagAssignment' :: FlagAssignment -> [String] Source #

Since: Cabal-syntax-3.4.0.0

legacyParsecFlagAssignment :: CabalParsing m => m FlagAssignment Source #

We need this as far as we support custom setups older than 2.2.0.0

Since: Cabal-syntax-3.4.0.0