Commit 920d6a98 authored by Oleg Grenrus's avatar Oleg Grenrus

Make FieldGrammar c g | g -> c fundep

This makes type-signatures awful, but using _ one can infer them.
Parsing performance doesn't seem to be affected.

Also move Newtypes to Distribution.FieldGrammar.Newtypes as that is
more correct place.
parent b5b70101
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.QuickCheck.Instances.Cabal () where
......@@ -11,8 +11,8 @@ import Test.QuickCheck
import Distribution.CabalSpecVersion
import Distribution.Compiler
import Distribution.FieldGrammar.Newtypes
import Distribution.ModuleName
import Distribution.Parsec.Newtypes
import Distribution.Simple.Flag (Flag (..))
import Distribution.SPDX
import Distribution.System
......
......@@ -528,6 +528,7 @@ library
Distribution.FieldGrammar.Class
Distribution.FieldGrammar.Described
Distribution.FieldGrammar.FieldDescrs
Distribution.FieldGrammar.Newtypes
Distribution.FieldGrammar.Parsec
Distribution.FieldGrammar.Pretty
Distribution.PackageDescription.FieldGrammar
......@@ -535,7 +536,6 @@ library
Distribution.PackageDescription.Quirks
Distribution.Parsec
Distribution.Parsec.Error
Distribution.Parsec.Newtypes
Distribution.Parsec.Position
Distribution.Parsec.Warning
Distribution.Parsec.FieldLineStream
......
......@@ -26,6 +26,8 @@ module Distribution.FieldGrammar (
runFieldParser,
runFieldParser',
defaultFreeTextFieldDefST,
-- * Newtypes
module Distribution.FieldGrammar.Newtypes,
) where
import Distribution.Compat.Prelude
......@@ -34,10 +36,11 @@ import Prelude ()
import qualified Data.Map.Strict as Map
import Distribution.FieldGrammar.Class
import Distribution.FieldGrammar.Newtypes
import Distribution.FieldGrammar.Parsec
import Distribution.FieldGrammar.Pretty
import Distribution.Fields.Field
import Distribution.Utils.Generic (spanMaybe)
import Distribution.Utils.Generic (spanMaybe)
type ParsecFieldGrammar' a = ParsecFieldGrammar a a
type PrettyFieldGrammar' a = PrettyFieldGrammar a a
......
{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
#if __GLASGOW_HASKELL__ >= 800
{-# LANGUAGE UndecidableSuperClasses #-}
#else
{-# LANGUAGE UndecidableInstances #-}
#endif
module Distribution.FieldGrammar.Class (
FieldGrammar (..),
uniqueField,
......@@ -5,15 +15,15 @@ module Distribution.FieldGrammar.Class (
optionalFieldDef,
monoidalField,
defaultFreeTextFieldDefST,
) where
) where
import Distribution.Compat.Lens
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.CabalSpecVersion (CabalSpecVersion)
import Distribution.Compat.Newtype (Newtype)
import Distribution.FieldGrammar.Described (Described)
import Distribution.CabalSpecVersion (CabalSpecVersion)
import Distribution.Compat.Newtype (Newtype)
import Distribution.FieldGrammar.Newtypes
import Distribution.Fields.Field
import Distribution.Utils.ShortText
......@@ -26,13 +36,17 @@ import Distribution.Utils.ShortText
--
-- /Note:/ We'd like to have @forall s. Applicative (f s)@ context.
--
class FieldGrammar g where
class
( c SpecVersion, c TestedWith, c SpecLicense, c Token, c Token', c FilePathNT
)
=> FieldGrammar c g | g -> c
where
-- | Unfocus, zoom out, /blur/ 'FieldGrammar'.
blurFieldGrammar :: ALens' a b -> g b c -> g a c
blurFieldGrammar :: ALens' a b -> g b d -> g a d
-- | Field which should be defined, exactly once.
uniqueFieldAla
:: (Described b, Newtype a b)
:: (c b, Newtype a b)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'Newtype' pack
-> ALens' s a -- ^ lens into the field
......@@ -47,7 +61,7 @@ class FieldGrammar g where
-- | Optional field.
optionalFieldAla
:: (Described b, Newtype a b)
:: (c b, Newtype a b)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'pack'
-> ALens' s (Maybe a) -- ^ lens into the field
......@@ -55,7 +69,7 @@ class FieldGrammar g where
-- | Optional field with default value.
optionalFieldDefAla
:: (Described b, Newtype a b, Eq a)
:: (c b, Newtype a b, Eq a)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'Newtype' pack
-> ALens' s a -- ^ @'Lens'' s a@: lens into the field
......@@ -93,7 +107,7 @@ class FieldGrammar g where
-- /Note:/ 'optionalFieldAla' is a @monoidalField@ with 'Last' monoid.
--
monoidalFieldAla
:: (Described b, Monoid a, Newtype a b)
:: (c b, Monoid a, Newtype a b)
=> FieldName -- ^ field name
-> (a -> b) -- ^ 'pack'
-> ALens' s a -- ^ lens into the field
......@@ -134,40 +148,40 @@ class FieldGrammar g where
-- | Field which can be defined at most once.
uniqueField
:: (FieldGrammar g, Described a)
:: (FieldGrammar c g, c (Identity a))
=> FieldName -- ^ field name
-> ALens' s a -- ^ lens into the field
-> g s a
uniqueField fn = uniqueFieldAla fn Identity
uniqueField fn l = uniqueFieldAla fn Identity l
-- | Field which can be defined at most once.
optionalField
:: (FieldGrammar g, Described a)
:: (FieldGrammar c g, c (Identity a))
=> FieldName -- ^ field name
-> ALens' s (Maybe a) -- ^ lens into the field
-> g s (Maybe a)
optionalField fn = optionalFieldAla fn Identity
optionalField fn l = optionalFieldAla fn Identity l
-- | Optional field with default value.
optionalFieldDef
:: (FieldGrammar g, Functor (g s), Described a, Eq a)
:: (FieldGrammar c g, Functor (g s), c (Identity a), Eq a)
=> FieldName -- ^ field name
-> ALens' s a -- ^ @'Lens'' s a@: lens into the field
-> a -- ^ default value
-> g s a
optionalFieldDef fn = optionalFieldDefAla fn Identity
optionalFieldDef fn l x = optionalFieldDefAla fn Identity l x
-- | Field which can be define multiple times, and the results are @mappend@ed.
monoidalField
:: (FieldGrammar g, Described a, Monoid a)
:: (FieldGrammar c g, c (Identity a), Monoid a)
=> FieldName -- ^ field name
-> ALens' s a -- ^ lens into the field
-> g s a
monoidalField fn = monoidalFieldAla fn Identity
monoidalField fn l = monoidalFieldAla fn Identity l
-- | Default implementation for 'freeTextFieldDefST'.
defaultFreeTextFieldDefST
:: (Functor (g s), FieldGrammar g)
:: (Functor (g s), FieldGrammar c g)
=> FieldName
-> ALens' s ShortText -- ^ lens into the field
-> g s ShortText
......
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
module Distribution.FieldGrammar.FieldDescrs (
FieldDescrs,
fieldDescrPretty,
......@@ -14,7 +17,7 @@ import Data.List (dropWhileEnd)
import Distribution.Compat.Lens (aview, cloneLens)
import Distribution.Compat.Newtype
import Distribution.FieldGrammar
import Distribution.Pretty (pretty, showFreeText)
import Distribution.Pretty (Pretty (..), showFreeText)
import qualified Data.Map as Map
import qualified Distribution.Compat.CharParsing as C
......@@ -55,7 +58,7 @@ fieldDescrsToList = map mk . Map.toList . runF where
mk (name, SP ppr parse) = (name, ppr, parse)
-- | /Note:/ default values are printed.
instance FieldGrammar FieldDescrs where
instance FieldGrammar ParsecPretty FieldDescrs where
blurFieldGrammar l (F m) = F (fmap blur m) where
blur (SP f g) = SP (f . aview l) (cloneLens l g)
......@@ -113,3 +116,6 @@ parsecFreeText = dropDotLines <$ C.spaces <*> many C.anyChar
trim :: String -> String
trim = dropWhile isSpace . dropWhileEnd isSpace
class (P.Parsec a, Pretty a) => ParsecPretty a
instance (P.Parsec a, Pretty a) => ParsecPretty a
......@@ -5,7 +5,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- | This module provides @newtype@ wrappers to be used with "Distribution.FieldGrammar".
module Distribution.Parsec.Newtypes (
module Distribution.FieldGrammar.Newtypes (
-- * List
alaList,
alaList',
......
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- | This module provides a 'FieldGrammarParser', one way to parse
-- @.cabal@ -like files.
--
......@@ -151,7 +152,7 @@ warnMultipleSingularFields fn (x : xs) = do
parseWarning pos PWTMultipleSingularField $
"The field " <> show fn <> " is specified more than once at positions " ++ intercalate ", " (map showPos (pos : poss))
instance FieldGrammar ParsecFieldGrammar where
instance FieldGrammar Parsec ParsecFieldGrammar where
blurFieldGrammar _ (ParsecFG s s' parser) = ParsecFG s s' parser
uniqueFieldAla fn _pack _extract = ParsecFG (Set.singleton fn) Set.empty parser
......
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Distribution.FieldGrammar.Pretty (
PrettyFieldGrammar,
prettyFieldGrammar,
......@@ -33,7 +34,7 @@ instance Applicative (PrettyFieldGrammar s) where
prettyFieldGrammar :: CabalSpecVersion -> PrettyFieldGrammar s a -> s -> [PrettyField ()]
prettyFieldGrammar = flip fieldGrammarPretty
instance FieldGrammar PrettyFieldGrammar where
instance FieldGrammar Pretty PrettyFieldGrammar where
blurFieldGrammar f (PrettyFG pp) = PrettyFG (\v -> pp v . aview f)
uniqueFieldAla fn _pack l = PrettyFG $ \_v s ->
......
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE OverloadedStrings #-}
-- | 'GenericPackageDescription' Field descriptions
module Distribution.PackageDescription.FieldGrammar (
......@@ -47,6 +48,7 @@ module Distribution.PackageDescription.FieldGrammar (
buildInfoFieldGrammar,
) where
import Distribution.Compat.Lens
import Distribution.Compat.Prelude
import Language.Haskell.Extension
......@@ -55,19 +57,23 @@ import Prelude ()
import Distribution.CabalSpecVersion
import Distribution.Compiler (CompilerFlavor (..), PerCompilerFlavor (..))
import Distribution.FieldGrammar
import Distribution.Fields
import Distribution.ModuleName (ModuleName)
import Distribution.Package
import Distribution.PackageDescription
import Distribution.Parsec
import Distribution.Parsec.Newtypes
import Distribution.Fields
import Distribution.Pretty (prettyShow)
import Distribution.Types.ExecutableScope
import Distribution.Types.ExeDependency (ExeDependency)
import Distribution.Types.ForeignLib
import Distribution.Types.ForeignLibOption (ForeignLibOption)
import Distribution.Types.ForeignLibType
import Distribution.Types.LibraryVisibility
import Distribution.Types.Mixin
import Distribution.Types.LegacyExeDependency (LegacyExeDependency)
import Distribution.Types.LibraryVisibility (LibraryVisibility (..))
import Distribution.Types.Mixin (Mixin)
import Distribution.Types.PkgconfigDependency (PkgconfigDependency)
import Distribution.Types.UnqualComponentName
import Distribution.Version (Version, VersionRange)
import qualified Distribution.SPDX as SPDX
......@@ -78,7 +84,17 @@ import qualified Distribution.Types.Lens as L
-------------------------------------------------------------------------------
packageDescriptionFieldGrammar
:: (FieldGrammar g, Applicative (g PackageDescription), Applicative (g PackageIdentifier))
:: ( FieldGrammar c g, Applicative (g PackageDescription), Applicative (g PackageIdentifier)
, c (Identity BuildType)
, c (Identity PackageName)
, c (Identity Version)
, c (List FSep FilePathNT String)
, c (List FSep TestedWith (CompilerFlavor, VersionRange))
, c (List VCat FilePathNT String)
, c FilePathNT
, c SpecLicense
, c SpecVersion
)
=> g PackageDescription PackageDescription
packageDescriptionFieldGrammar = PackageDescription
<$> optionalFieldDefAla "cabal-version" SpecVersion L.specVersion CabalSpecV1_0
......@@ -131,7 +147,24 @@ packageDescriptionFieldGrammar = PackageDescription
-------------------------------------------------------------------------------
libraryFieldGrammar
:: (FieldGrammar g, Applicative (g Library), Applicative (g BuildInfo))
:: ( FieldGrammar c g, Applicative (g Library), Applicative (g BuildInfo)
, c (Identity LibraryVisibility)
, c (List CommaFSep (Identity ExeDependency) ExeDependency)
, c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)
, c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)
, c (List CommaVCat (Identity Dependency) Dependency)
, c (List CommaVCat (Identity Mixin) Mixin)
, c (List CommaVCat (Identity ModuleReexport) ModuleReexport)
, c (List FSep (MQuoted Extension) Extension)
, c (List FSep (MQuoted Language) Language)
, c (List FSep FilePathNT String)
, c (List FSep Token String)
, c (List NoCommaFSep Token' String)
, c (List VCat (MQuoted ModuleName) ModuleName)
, c (List VCat FilePathNT String)
, c (List VCat Token String)
, c (MQuoted Language)
)
=> LibraryName
-> g Library Library
libraryFieldGrammar n = Library n
......@@ -159,7 +192,25 @@ libraryFieldGrammar n = Library n
-------------------------------------------------------------------------------
foreignLibFieldGrammar
:: (FieldGrammar g, Applicative (g ForeignLib), Applicative (g BuildInfo))
:: ( FieldGrammar c g, Applicative (g ForeignLib), Applicative (g BuildInfo)
, c (Identity ForeignLibType)
, c (Identity LibVersionInfo)
, c (Identity Version)
, c (List CommaFSep (Identity ExeDependency) ExeDependency)
, c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)
, c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)
, c (List CommaVCat (Identity Dependency) Dependency)
, c (List CommaVCat (Identity Mixin) Mixin)
, c (List FSep (Identity ForeignLibOption) ForeignLibOption)
, c (List FSep (MQuoted Extension) Extension)
, c (List FSep (MQuoted Language) Language)
, c (List FSep FilePathNT String)
, c (List FSep Token String)
, c (List NoCommaFSep Token' String)
, c (List VCat (MQuoted ModuleName) ModuleName)
, c (List VCat FilePathNT String), c (List VCat Token String)
, c (MQuoted Language)
)
=> UnqualComponentName -> g ForeignLib ForeignLib
foreignLibFieldGrammar n = ForeignLib n
<$> optionalFieldDef "type" L.foreignLibType ForeignLibTypeUnknown
......@@ -176,7 +227,23 @@ foreignLibFieldGrammar n = ForeignLib n
-------------------------------------------------------------------------------
executableFieldGrammar
:: (FieldGrammar g, Applicative (g Executable), Applicative (g BuildInfo))
:: ( FieldGrammar c g, Applicative (g Executable), Applicative (g BuildInfo)
, c (Identity ExecutableScope),
c (List CommaFSep (Identity ExeDependency) ExeDependency),
c (List
CommaFSep (Identity LegacyExeDependency) LegacyExeDependency),
c (List
CommaFSep (Identity PkgconfigDependency) PkgconfigDependency),
c (List CommaVCat (Identity Dependency) Dependency),
c (List CommaVCat (Identity Mixin) Mixin),
c (List FSep (MQuoted Extension) Extension),
c (List FSep (MQuoted Language) Language),
c (List FSep FilePathNT String), c (List FSep Token String),
c (List NoCommaFSep Token' String),
c (List VCat (MQuoted ModuleName) ModuleName),
c (List VCat FilePathNT String), c (List VCat Token String),
c (MQuoted Language)
)
=> UnqualComponentName -> g Executable Executable
executableFieldGrammar n = Executable n
-- main-is is optional as conditional blocks don't have it
......@@ -220,7 +287,24 @@ testStanzaBuildInfo f s = fmap (\x -> s { _testStanzaBuildInfo = x }) (f (_testS
{-# INLINE testStanzaBuildInfo #-}
testSuiteFieldGrammar
:: (FieldGrammar g, Applicative (g TestSuiteStanza), Applicative (g BuildInfo))
:: ( FieldGrammar c g, Applicative (g TestSuiteStanza), Applicative (g BuildInfo)
, c (Identity ModuleName)
, c (Identity TestType)
, c (List CommaFSep (Identity ExeDependency) ExeDependency)
, c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)
, c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)
, c (List CommaVCat (Identity Dependency) Dependency)
, c (List CommaVCat (Identity Mixin) Mixin)
, c (List FSep (MQuoted Extension) Extension)
, c (List FSep (MQuoted Language) Language)
, c (List FSep FilePathNT String)
, c (List FSep Token String)
, c (List NoCommaFSep Token' String)
, c (List VCat (MQuoted ModuleName) ModuleName)
, c (List VCat FilePathNT String)
, c (List VCat Token String)
, c (MQuoted Language)
)
=> g TestSuiteStanza TestSuiteStanza
testSuiteFieldGrammar = TestSuiteStanza
<$> optionalField "type" testStanzaTestType
......@@ -322,7 +406,24 @@ benchmarkStanzaBuildInfo f s = fmap (\x -> s { _benchmarkStanzaBuildInfo = x })
{-# INLINE benchmarkStanzaBuildInfo #-}
benchmarkFieldGrammar
:: (FieldGrammar g, Applicative (g BenchmarkStanza), Applicative (g BuildInfo))
:: ( FieldGrammar c g, Applicative (g BenchmarkStanza), Applicative (g BuildInfo)
, c (Identity BenchmarkType)
, c (Identity ModuleName)
, c (List CommaFSep (Identity ExeDependency) ExeDependency)
, c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)
, c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)
, c (List CommaVCat (Identity Dependency) Dependency)
, c (List CommaVCat (Identity Mixin) Mixin)
, c (List FSep (MQuoted Extension) Extension)
, c (List FSep (MQuoted Language) Language)
, c (List FSep FilePathNT String)
, c (List FSep Token String)
, c (List NoCommaFSep Token' String)
, c (List VCat (MQuoted ModuleName) ModuleName)
, c (List VCat FilePathNT String)
, c (List VCat Token String)
, c (MQuoted Language)
)
=> g BenchmarkStanza BenchmarkStanza
benchmarkFieldGrammar = BenchmarkStanza
<$> optionalField "type" benchmarkStanzaBenchmarkType
......@@ -382,7 +483,22 @@ unvalidateBenchmark b = BenchmarkStanza
-------------------------------------------------------------------------------
buildInfoFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
:: ( FieldGrammar c g, Applicative (g BuildInfo)
, c (List CommaFSep (Identity ExeDependency) ExeDependency)
, c (List CommaFSep (Identity LegacyExeDependency) LegacyExeDependency)
, c (List CommaFSep (Identity PkgconfigDependency) PkgconfigDependency)
, c (List CommaVCat (Identity Dependency) Dependency)
, c (List CommaVCat (Identity Mixin) Mixin)
, c (List FSep (MQuoted Extension) Extension)
, c (List FSep (MQuoted Language) Language)
, c (List FSep FilePathNT String)
, c (List FSep Token String)
, c (List NoCommaFSep Token' String)
, c (List VCat (MQuoted ModuleName) ModuleName)
, c (List VCat FilePathNT String)
, c (List VCat Token String)
, c (MQuoted Language)
)
=> g BuildInfo BuildInfo
buildInfoFieldGrammar = BuildInfo
<$> booleanFieldDef "buildable" L.buildable True
......@@ -455,7 +571,7 @@ buildInfoFieldGrammar = BuildInfo
{-# SPECIALIZE buildInfoFieldGrammar :: PrettyFieldGrammar' BuildInfo #-}
hsSourceDirsGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
:: (FieldGrammar c g, Applicative (g BuildInfo), c (List FSep FilePathNT FilePath))
=> g BuildInfo [FilePath]
hsSourceDirsGrammar = (++)
<$> monoidalFieldAla "hs-source-dirs" formatHsSourceDirs L.hsSourceDirs
......@@ -469,7 +585,7 @@ hsSourceDirsGrammar = (++)
wrongLens f bi = (\fps -> set L.hsSourceDirs fps bi) <$> f []
optionsFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
:: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))
=> g BuildInfo (PerCompilerFlavor [String])
optionsFieldGrammar = PerCompilerFlavor
<$> monoidalFieldAla "ghc-options" (alaList' NoCommaFSep Token') (extract GHC)
......@@ -485,7 +601,7 @@ optionsFieldGrammar = PerCompilerFlavor
extract flavor = L.options . lookupLens flavor
profOptionsFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
:: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))
=> g BuildInfo (PerCompilerFlavor [String])
profOptionsFieldGrammar = PerCompilerFlavor
<$> monoidalFieldAla "ghc-prof-options" (alaList' NoCommaFSep Token') (extract GHC)
......@@ -495,7 +611,7 @@ profOptionsFieldGrammar = PerCompilerFlavor
extract flavor = L.profOptions . lookupLens flavor
sharedOptionsFieldGrammar
:: (FieldGrammar g, Applicative (g BuildInfo))
:: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))
=> g BuildInfo (PerCompilerFlavor [String])
sharedOptionsFieldGrammar = PerCompilerFlavor
<$> monoidalFieldAla "ghc-shared-options" (alaList' NoCommaFSep Token') (extract GHC)
......@@ -515,7 +631,7 @@ lookupLens k f p@(PerCompilerFlavor ghc ghcjs)
-------------------------------------------------------------------------------
flagFieldGrammar
:: (FieldGrammar g, Applicative (g PackageFlag))
:: (FieldGrammar c g, Applicative (g PackageFlag))
=> FlagName -> g PackageFlag PackageFlag
flagFieldGrammar name = MkPackageFlag name
<$> freeTextFieldDef "description" L.flagDescription
......@@ -529,7 +645,7 @@ flagFieldGrammar name = MkPackageFlag name
-------------------------------------------------------------------------------
sourceRepoFieldGrammar
:: (FieldGrammar g, Applicative (g SourceRepo))
:: (FieldGrammar c g, Applicative (g SourceRepo), c (Identity RepoType), c Token, c FilePathNT)
=> RepoKind -> g SourceRepo SourceRepo
sourceRepoFieldGrammar kind = SourceRepo kind
<$> optionalField "type" L.repoType
......@@ -539,19 +655,19 @@ sourceRepoFieldGrammar kind = SourceRepo kind
<*> optionalFieldAla "tag" Token L.repoTag
<*> optionalFieldAla "subdir" FilePathNT L.repoSubdir
{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind -> ParsecFieldGrammar' SourceRepo #-}
{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind ->PrettyFieldGrammar' SourceRepo #-}
{-# SPECIALIZE sourceRepoFieldGrammar :: RepoKind -> PrettyFieldGrammar' SourceRepo #-}
-------------------------------------------------------------------------------
-- SetupBuildInfo
-------------------------------------------------------------------------------
setupBInfoFieldGrammar
:: (FieldGrammar g, Functor (g SetupBuildInfo))
:: (FieldGrammar c g, Functor (g SetupBuildInfo), c (List CommaVCat (Identity Dependency) Dependency))
=> Bool -> g SetupBuildInfo SetupBuildInfo
setupBInfoFieldGrammar def = flip SetupBuildInfo def
<$> monoidalFieldAla "setup-depends" (alaList CommaVCat) L.setupDepends
{-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> ParsecFieldGrammar' SetupBuildInfo #-}
{-# SPECIALIZE setupBInfoFieldGrammar :: Bool ->PrettyFieldGrammar' SetupBuildInfo #-}
{-# SPECIALIZE setupBInfoFieldGrammar :: Bool -> PrettyFieldGrammar' SetupBuildInfo #-}
-------------------------------------------------------------------------------
-- Define how field values should be formatted for 'pretty'.
......
......@@ -56,7 +56,6 @@ import Distribution.PackageDescription.FieldGrammar
import Distribution.PackageDescription.Quirks (patchQuirks)
import Distribution.Parsec (parsec, simpleParsecBS)
import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS)
import Distribution.Parsec.Newtypes (CommaFSep, List, SpecVersion (..), Token)
import Distribution.Parsec.Position (Position (..), zeroPos)
import Distribution.Parsec.Warning (PWarnType (..))
import Distribution.Pretty (prettyShow)
......
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
......@@ -20,7 +21,6 @@ import Distribution.License
import Distribution.ModuleName
import Distribution.Package
import Distribution.Parsec
import Distribution.Parsec.Newtypes
import Distribution.Pretty
import Distribution.Types.LibraryName
import Distribution.Types.LibraryVisibility
......@@ -54,7 +54,24 @@ f <+> x = f <*> x
{-# NOINLINE (<+>) #-}
ipiFieldGrammar
:: (FieldGrammar g, Applicative (g InstalledPackageInfo), Applicative (g Basic))
:: ( FieldGrammar c g, Applicative (g InstalledPackageInfo), Applicative (g Basic)
, c (Identity AbiHash)
, c (Identity LibraryVisibility)
, c (Identity PackageName)
, c (Identity UnitId)
, c (Identity UnqualComponentName)
, c (List FSep (Identity AbiDependency) AbiDependency)
, c (List FSep (Identity UnitId) UnitId)
, c (List FSep (MQuoted ModuleName) ModuleName)
, c (List FSep FilePathNT String)
, c (List FSep Token String)
, c (MQuoted MungedPackageName)
, c (MQuoted Version)
, c CompatPackageKey
, c ExposedModules
, c InstWith
, c SpecLicenseLenient
)
=> g InstalledPackageInfo InstalledPackageInfo
ipiFieldGrammar = mkInstalledPackageInfo
-- Deprecated fields
......@@ -68,15 +85,15 @@ ipiFieldGrammar = mkInstalledPackageInfo
<+> optionalFieldDefAla "instantiated-with" InstWith L.instantiatedWith []
<+> optionalFieldDefAla "key" CompatPackageKey L.compatPackageKey ""
<+> optionalFieldDefAla "license" SpecLicenseLenient L.license (Left SPDX.NONE)
<+> freeTextFieldDefST "copyright" L.copyright
<+> freeTextFieldDefST "maintainer" L.maintainer
<+> freeTextFieldDefST "author" L.author
<+> freeTextFieldDefST "stability" L.stability
<+> freeTextFieldDefST "homepage" L.homepage
<+> freeTextFieldDefST "package-url" L.pkgUrl
<+> freeTextFieldDefST "synopsis" L.synopsis
<+> freeTextFieldDefST "description" L.description
<+> freeTextFieldDefST "category" L.category
<+> freeTextFieldDefST "copyright" L.copyright
<+> freeTextFieldDefST "maintainer" L.maintainer
<+> freeTextFieldDefST "author" L.author
<+> freeTextFieldDefST "stability" L.stability
<+> freeTextFieldDefST "homepage" L.homepage