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.Fields.Field
import Distribution.Parsec (Parsec)
import Distribution.Pretty (Pretty)
import Distribution.Utils.ShortText
class FieldGrammar g where
blurFieldGrammar :: ALens' a b -> g b c -> g a c
uniqueFieldAla
:: (Parsec b, Pretty b, Newtype a b)
=> FieldName
-> (a -> b)
-> ALens' s a
-> g s a
booleanFieldDef
:: FieldName
-> ALens' s Bool
-> Bool
-> g s Bool
optionalFieldAla
:: (Parsec b, Pretty b, Newtype a b)
=> FieldName
-> (a -> b)
-> ALens' s (Maybe a)
-> g s (Maybe a)
optionalFieldDefAla
:: (Parsec b, Pretty 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
:: (Parsec b, Pretty 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
uniqueField
:: (FieldGrammar g, Parsec a, Pretty a)
=> FieldName
-> ALens' s a
-> g s a
uniqueField :: FieldName -> ALens' s a -> g s a
uniqueField FieldName
fn = FieldName -> (a -> Identity a) -> ALens' s a -> g s a
forall (g :: * -> * -> *) b a s.
(FieldGrammar g, Parsec b, Pretty b, Newtype a b) =>
FieldName -> (a -> b) -> ALens' s a -> g s a
uniqueFieldAla FieldName
fn a -> Identity a
forall a. a -> Identity a
Identity
optionalField
:: (FieldGrammar g, Parsec a, Pretty a)
=> FieldName
-> ALens' s (Maybe a)
-> g s (Maybe a)
optionalField :: FieldName -> ALens' s (Maybe a) -> g s (Maybe a)
optionalField FieldName
fn = FieldName
-> (a -> Identity a) -> ALens' s (Maybe a) -> g s (Maybe a)
forall (g :: * -> * -> *) b a s.
(FieldGrammar g, Parsec b, Pretty b, Newtype a b) =>
FieldName -> (a -> b) -> ALens' s (Maybe a) -> g s (Maybe a)
optionalFieldAla FieldName
fn a -> Identity a
forall a. a -> Identity a
Identity
optionalFieldDef
:: (FieldGrammar g, Functor (g s), Parsec a, Pretty a, Eq a)
=> FieldName
-> ALens' s a
-> a
-> g s a
optionalFieldDef :: FieldName -> ALens' s a -> a -> g s a
optionalFieldDef FieldName
fn = FieldName -> (a -> Identity a) -> ALens' s a -> a -> g s a
forall (g :: * -> * -> *) b a s.
(FieldGrammar g, Parsec b, Pretty b, Newtype a b, Eq a) =>
FieldName -> (a -> b) -> ALens' s a -> a -> g s a
optionalFieldDefAla FieldName
fn a -> Identity a
forall a. a -> Identity a
Identity
monoidalField
:: (FieldGrammar g, Parsec a, Pretty a, Monoid a)
=> FieldName
-> ALens' s a
-> g s a
monoidalField :: FieldName -> ALens' s a -> g s a
monoidalField FieldName
fn = FieldName -> (a -> Identity a) -> ALens' s a -> g s a
forall (g :: * -> * -> *) b a s.
(FieldGrammar g, Parsec b, Pretty b, Monoid a, Newtype a b) =>
FieldName -> (a -> b) -> ALens' s a -> g s a
monoidalFieldAla FieldName
fn a -> Identity a
forall a. a -> Identity a
Identity
defaultFreeTextFieldDefST
:: (Functor (g s), FieldGrammar g)
=> FieldName
-> ALens' s ShortText
-> g s ShortText
defaultFreeTextFieldDefST :: FieldName -> ALens' s ShortText -> g s ShortText
defaultFreeTextFieldDefST FieldName
fn ALens' s ShortText
l =
String -> ShortText
toShortText (String -> ShortText) -> g s String -> g s ShortText
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FieldName -> ALens' s String -> g s String
forall (g :: * -> * -> *) s.
FieldGrammar g =>
FieldName -> ALens' s String -> g s String
freeTextFieldDef FieldName
fn (ALens' s ShortText
-> LensLike (Pretext String String) s s ShortText ShortText
forall (f :: * -> *) s t a b.
Functor f =>
ALens s t a b -> LensLike f s t a b
cloneLens ALens' s ShortText
l LensLike (Pretext String String) s s ShortText ShortText
-> ((String -> Pretext String String String)
-> ShortText -> Pretext String String ShortText)
-> ALens' s String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Pretext String String String)
-> ShortText -> Pretext String String ShortText
Lens' ShortText String
st)
where
st :: Lens' ShortText String
st :: LensLike f ShortText ShortText String String
st String -> f String
f ShortText
s = String -> ShortText
toShortText (String -> ShortText) -> f String -> f ShortText
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> f String
f (ShortText -> String
fromShortText ShortText
s)