Cabal-syntax-3.9.0.0: A library for working with .cabal files
Safe HaskellSafe-Inferred
LanguageHaskell2010

Distribution.FieldGrammar.Newtypes

Description

This module provides newtype wrappers to be used with Distribution.FieldGrammar.

Synopsis

List

alaList :: sep -> [a] -> List sep (Identity a) a Source #

alaList and alaList' are simply List, with additional phantom arguments to constrain the resulting type

>>> :t alaList VCat
alaList VCat :: [a] -> List VCat (Identity a) a
>>> :t alaList' FSep Token
alaList' FSep Token :: [String] -> List FSep Token String

alaList' :: sep -> (a -> b) -> [a] -> List sep b a Source #

More general version of alaList.

Modifiers

data CommaVCat Source #

Vertical list with commas. Displayed with vcat

Constructors

CommaVCat 

Instances

Instances details
Sep CommaVCat Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

data CommaFSep Source #

Paragraph fill list with commas. Displayed with fsep

Constructors

CommaFSep 

Instances

Instances details
Sep CommaFSep Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

data VCat Source #

Vertical list with optional commas. Displayed with vcat.

Constructors

VCat 

Instances

Instances details
Sep VCat Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

prettySep :: Proxy VCat -> [Doc] -> Doc Source #

parseSep :: CabalParsing m => Proxy VCat -> m a -> m [a] Source #

parseSepNE :: CabalParsing m => Proxy VCat -> m a -> m (NonEmpty a) Source #

data FSep Source #

Paragraph fill list with optional commas. Displayed with fsep.

Constructors

FSep 

Instances

Instances details
Sep FSep Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

prettySep :: Proxy FSep -> [Doc] -> Doc Source #

parseSep :: CabalParsing m => Proxy FSep -> m a -> m [a] Source #

parseSepNE :: CabalParsing m => Proxy FSep -> m a -> m (NonEmpty a) Source #

data NoCommaFSep Source #

Paragraph fill list without commas. Displayed with fsep.

Constructors

NoCommaFSep 

Instances

Instances details
Sep NoCommaFSep Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

class Sep sep where Source #

Methods

prettySep :: Proxy sep -> [Doc] -> Doc Source #

parseSep :: CabalParsing m => Proxy sep -> m a -> m [a] Source #

parseSepNE :: CabalParsing m => Proxy sep -> m a -> m (NonEmpty a) Source #

Instances

Instances details
Sep CommaFSep Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Sep CommaVCat Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Sep FSep Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

prettySep :: Proxy FSep -> [Doc] -> Doc Source #

parseSep :: CabalParsing m => Proxy FSep -> m a -> m [a] Source #

parseSepNE :: CabalParsing m => Proxy FSep -> m a -> m (NonEmpty a) Source #

Sep NoCommaFSep Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Sep VCat Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

prettySep :: Proxy VCat -> [Doc] -> Doc Source #

parseSep :: CabalParsing m => Proxy VCat -> m a -> m [a] Source #

parseSepNE :: CabalParsing m => Proxy VCat -> m a -> m (NonEmpty a) Source #

Type

data List sep b a Source #

List separated with optional commas. Displayed with sep, arguments of type a are parsed and pretty-printed as b.

Instances

Instances details
Newtype [a] (List sep wrapper a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

pack :: [a] -> List sep wrapper a Source #

unpack :: List sep wrapper a -> [a] Source #

(Newtype a b, Sep sep, Parsec b) => Parsec (List sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (List sep b a) Source #

(Newtype a b, Sep sep, Pretty b) => Pretty (List sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

pretty :: List sep b a -> Doc Source #

prettyVersioned :: CabalSpecVersion -> List sep b a -> Doc Source #

Set

alaSet :: sep -> Set a -> Set' sep (Identity a) a Source #

alaSet and alaSet' are simply Set' constructor, with additional phantom arguments to constrain the resulting type

>>> :t alaSet VCat
alaSet VCat :: Set a -> Set' VCat (Identity a) a
>>> :t alaSet' FSep Token
alaSet' FSep Token :: Set String -> Set' FSep Token String
>>> unpack' (alaSet' FSep Token) <$> eitherParsec "foo bar foo"
Right (fromList ["bar","foo"])

Since: Cabal-syntax-3.2.0.0

alaSet' :: sep -> (a -> b) -> Set a -> Set' sep b a Source #

More general version of alaSet.

Since: Cabal-syntax-3.2.0.0

data Set' sep b a Source #

Like List, but for Set.

Since: Cabal-syntax-3.2.0.0

Instances

Instances details
Newtype (Set a) (Set' sep wrapper a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

pack :: Set a -> Set' sep wrapper a Source #

unpack :: Set' sep wrapper a -> Set a Source #

(Newtype a b, Ord a, Sep sep, Parsec b) => Parsec (Set' sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (Set' sep b a) Source #

(Newtype a b, Sep sep, Pretty b) => Pretty (Set' sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

pretty :: Set' sep b a -> Doc Source #

prettyVersioned :: CabalSpecVersion -> Set' sep b a -> Doc Source #

NonEmpty

alaNonEmpty :: sep -> NonEmpty a -> NonEmpty' sep (Identity a) a Source #

alaNonEmpty and alaNonEmpty' are simply NonEmpty' constructor, with additional phantom arguments to constrain the resulting type

>>> :t alaNonEmpty VCat
alaNonEmpty VCat :: NonEmpty a -> NonEmpty' VCat (Identity a) a
>>> unpack' (alaNonEmpty' FSep Token) <$> eitherParsec "foo bar foo"
Right ("foo" :| ["bar","foo"])

Since: Cabal-syntax-3.2.0.0

alaNonEmpty' :: sep -> (a -> b) -> NonEmpty a -> NonEmpty' sep b a Source #

More general version of alaNonEmpty.

Since: Cabal-syntax-3.2.0.0

data NonEmpty' sep b a Source #

Like List, but for NonEmpty.

Since: Cabal-syntax-3.2.0.0

Instances

Instances details
Newtype (NonEmpty a) (NonEmpty' sep wrapper a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

pack :: NonEmpty a -> NonEmpty' sep wrapper a Source #

unpack :: NonEmpty' sep wrapper a -> NonEmpty a Source #

(Newtype a b, Sep sep, Parsec b) => Parsec (NonEmpty' sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (NonEmpty' sep b a) Source #

(Newtype a b, Sep sep, Pretty b) => Pretty (NonEmpty' sep b a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Version & License

newtype SpecVersion Source #

Version range or just version, i.e. cabal-version field.

There are few things to consider:

We have this newtype, as writing Parsec and Pretty instances for CabalSpecVersion would cause cycle in modules: Version -> CabalSpecVersion -> Parsec -> ...

Identifiers

newtype Token Source #

Haskell string or [^ ,]+

Constructors

Token 

Fields

Instances

Instances details
Parsec Token Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m Token Source #

Pretty Token Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Newtype String Token Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

newtype Token' Source #

Haskell string or [^ ]+

Constructors

Token' 

Fields

newtype MQuoted a Source #

Either "quoted" or un-quoted.

Constructors

MQuoted 

Fields

Instances

Instances details
Newtype a (MQuoted a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

pack :: a -> MQuoted a Source #

unpack :: MQuoted a -> a Source #

Parsec a => Parsec (MQuoted a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

Methods

parsec :: CabalParsing m => m (MQuoted a) Source #

Pretty a => Pretty (MQuoted a) Source # 
Instance details

Defined in Distribution.FieldGrammar.Newtypes

newtype FilePathNT Source #

Filepath are parsed as Token.

Constructors

FilePathNT