{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Distribution.FieldGrammar.Class (
FieldGrammar (..),
uniqueField,
optionalField,
optionalFieldDef,
monoidalField,
defaultFreeTextFieldDefST,
) where
import Distribution.Compat.Lens
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.CabalSpecVersion (CabalSpecVersion)
import Distribution.Compat.Newtype (Newtype)
import Distribution.FieldGrammar.Newtypes
import Distribution.Fields.Field
import Distribution.Utils.ShortText
class
( c SpecVersion, c TestedWith, c SpecLicense, c Token, c Token', c FilePathNT
)
=> FieldGrammar c g | g -> c
where
blurFieldGrammar :: ALens' a b -> g b d -> g a d
uniqueFieldAla
:: (c b, Newtype a b)
=> FieldName
-> (a -> b)
-> ALens' s a
-> g s a
booleanFieldDef
:: FieldName
-> ALens' s Bool
-> Bool
-> g s Bool
optionalFieldAla
:: (c b, Newtype a b)
=> FieldName
-> (a -> b)
-> ALens' s (Maybe a)
-> g s (Maybe a)
optionalFieldDefAla
:: (c b, Newtype a b, Eq a)
=> FieldName
-> (a -> b)
-> ALens' s a
-> a
-> g s a
freeTextField
:: FieldName
-> ALens' s (Maybe String)
-> g s (Maybe String)
freeTextFieldDef
:: FieldName
-> ALens' s String
-> g s String
freeTextFieldDefST
:: FieldName
-> ALens' s ShortText
-> g s ShortText
monoidalFieldAla
:: (c b, Monoid a, Newtype a b)
=> FieldName
-> (a -> b)
-> ALens' s a
-> g s a
prefixedFields
:: FieldName
-> ALens' s [(String, String)]
-> g s [(String, String)]
knownField :: FieldName -> g s ()
hiddenField :: g s a -> g s a
deprecatedSince
:: CabalSpecVersion
-> String
-> g s a
-> g s a
removedIn
:: CabalSpecVersion
-> String
-> g s a
-> g s a
availableSince
:: CabalSpecVersion
-> a
-> g s a
-> g s a
availableSinceWarn
:: CabalSpecVersion
-> g s a
-> g s a
availableSinceWarn CabalSpecVersion
_ = forall a. a -> a
id
uniqueField
:: (FieldGrammar c g, c (Identity a))
=> FieldName
-> ALens' s a
-> g s a
uniqueField :: forall (c :: * -> Constraint) (g :: * -> * -> *) a s.
(FieldGrammar c g, c (Identity a)) =>
FieldName -> ALens' s a -> g s a
uniqueField FieldName
fn ALens' s a
l = forall (c :: * -> Constraint) (g :: * -> * -> *) b a s.
(FieldGrammar c g, c b, Newtype a b) =>
FieldName -> (a -> b) -> ALens' s a -> g s a
uniqueFieldAla FieldName
fn forall a. a -> Identity a
Identity ALens' s a
l
optionalField
:: (FieldGrammar c g, c (Identity a))
=> FieldName
-> ALens' s (Maybe a)
-> g s (Maybe a)
optionalField :: forall (c :: * -> Constraint) (g :: * -> * -> *) a s.
(FieldGrammar c g, c (Identity a)) =>
FieldName -> ALens' s (Maybe a) -> g s (Maybe a)
optionalField FieldName
fn ALens' s (Maybe a)
l = forall (c :: * -> Constraint) (g :: * -> * -> *) b a s.
(FieldGrammar c g, c b, Newtype a b) =>
FieldName -> (a -> b) -> ALens' s (Maybe a) -> g s (Maybe a)
optionalFieldAla FieldName
fn forall a. a -> Identity a
Identity ALens' s (Maybe a)
l
optionalFieldDef
:: (FieldGrammar c g, Functor (g s), c (Identity a), Eq a)
=> FieldName
-> ALens' s a
-> a
-> g s a
optionalFieldDef :: forall (c :: * -> Constraint) (g :: * -> * -> *) s a.
(FieldGrammar c g, Functor (g s), c (Identity a), Eq a) =>
FieldName -> ALens' s a -> a -> g s a
optionalFieldDef FieldName
fn ALens' s a
l a
x = forall (c :: * -> Constraint) (g :: * -> * -> *) b a s.
(FieldGrammar c g, c b, Newtype a b, Eq a) =>
FieldName -> (a -> b) -> ALens' s a -> a -> g s a
optionalFieldDefAla FieldName
fn forall a. a -> Identity a
Identity ALens' s a
l a
x
monoidalField
:: (FieldGrammar c g, c (Identity a), Monoid a)
=> FieldName
-> ALens' s a
-> g s a
monoidalField :: forall (c :: * -> Constraint) (g :: * -> * -> *) a s.
(FieldGrammar c g, c (Identity a), Monoid a) =>
FieldName -> ALens' s a -> g s a
monoidalField FieldName
fn ALens' s a
l = forall (c :: * -> Constraint) (g :: * -> * -> *) b a s.
(FieldGrammar c g, c b, Monoid a, Newtype a b) =>
FieldName -> (a -> b) -> ALens' s a -> g s a
monoidalFieldAla FieldName
fn forall a. a -> Identity a
Identity ALens' s a
l
defaultFreeTextFieldDefST
:: (Functor (g s), FieldGrammar c g)
=> FieldName
-> ALens' s ShortText
-> g s ShortText
defaultFreeTextFieldDefST :: forall (g :: * -> * -> *) s (c :: * -> Constraint).
(Functor (g s), FieldGrammar c g) =>
FieldName -> ALens' s ShortText -> g s ShortText
defaultFreeTextFieldDefST FieldName
fn ALens' s ShortText
l =
String -> ShortText
toShortText forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (c :: * -> Constraint) (g :: * -> * -> *) s.
FieldGrammar c g =>
FieldName -> ALens' s String -> g s String
freeTextFieldDef FieldName
fn (forall (f :: * -> *) s t a b.
Functor f =>
ALens s t a b -> LensLike f s t a b
cloneLens ALens' s ShortText
l forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lens' ShortText String
st)
where
st :: Lens' ShortText String
st :: Lens' ShortText String
st String -> f String
f ShortText
s = String -> ShortText
toShortText forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> f String
f (ShortText -> String
fromShortText ShortText
s)