{-# LANGUAGE UndecidableSuperClasses #-}
module Lorentz.Annotation
( AnnOptions (..)
, defaultAnnOptions
, dropPrefixThen
, appendTo
, toCamel
, toPascal
, toSnake
, ctorNameToAnnWithOptions
, FollowEntrypointFlag (..)
, GenerateFieldAnnFlag (..)
, HasAnnotation (..)
, GHasAnnotation (..)
, gGetAnnotationNoField
, insertTypeAnn
) where
import Data.Char (isUpper)
import qualified Data.Text as T
import Data.Text.Manipulate (toCamel, toPascal, toSnake)
import qualified GHC.Generics as G
import Named (NamedF)
import Michelson.Text
import Michelson.Typed
(BigMap, ContractRef(..), EpAddress, KnownIsoT, Notes(..), Operation, ToT, insertTypeAnn,
starNotes)
import Michelson.Typed.Haskell.Value (GValueType)
import Michelson.Untyped (FieldAnn, TypeAnn, VarAnn, ann, noAnn)
import Tezos.Address
import Tezos.Core
import Tezos.Crypto
import Util.Text
import Util.TypeLits
data AnnOptions = AnnOptions
{ AnnOptions -> Text -> Text
fieldAnnModifier :: Text -> Text
}
defaultAnnOptions :: AnnOptions
defaultAnnOptions :: AnnOptions
defaultAnnOptions = (Text -> Text) -> AnnOptions
AnnOptions Text -> Text
forall a. a -> a
id
dropPrefixThen :: (Text -> Text) -> Text -> Text
dropPrefixThen :: (Text -> Text) -> Text -> Text
dropPrefixThen f :: Text -> Text
f = Text -> Text
f (Text -> Text) -> (Text -> Text) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> Text
T.dropWhile (Bool -> Bool
Prelude.not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
isUpper)
appendTo :: Text -> [Text] -> Text -> Text
appendTo :: Text -> [Text] -> Text -> Text
appendTo suffix :: Text
suffix fields :: [Text]
fields field :: Text
field
| Text
Element [Text]
field Element [Text] -> [Text] -> Bool
forall t. (Container t, Eq (Element t)) => Element t -> t -> Bool
`elem` [Text]
fields = Text
field Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
suffix
| Bool
otherwise = Text
field
ctorNameToAnnWithOptions :: forall ctor. (KnownSymbol ctor, HasCallStack) => AnnOptions -> FieldAnn
ctorNameToAnnWithOptions :: AnnOptions -> FieldAnn
ctorNameToAnnWithOptions o :: AnnOptions
o = Text -> FieldAnn
forall k (a :: k). HasCallStack => Text -> Annotation a
ann (Text -> FieldAnn) -> (Text -> Text) -> Text -> FieldAnn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnnOptions -> Text -> Text
fieldAnnModifier AnnOptions
o (Text -> FieldAnn) -> Text -> FieldAnn
forall a b. (a -> b) -> a -> b
$ HasCallStack => Text -> Text
Text -> Text
headToLower (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$ (KnownSymbol ctor => Text
forall (s :: Symbol). KnownSymbol s => Text
symbolValT' @ctor)
data FollowEntrypointFlag = FollowEntrypoint | NotFollowEntrypoint
data GenerateFieldAnnFlag = GenerateFieldAnn | NotGenerateFieldAnn
gGetAnnotationNoField
:: forall a. (GHasAnnotation (G.Rep a), GValueType (G.Rep a) ~ ToT a)
=> FollowEntrypointFlag -> Notes (ToT a)
gGetAnnotationNoField :: FollowEntrypointFlag -> Notes (ToT a)
gGetAnnotationNoField = \_ -> AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (Rep a)), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @(G.Rep a) AnnOptions
defaultAnnOptions FollowEntrypointFlag
NotFollowEntrypoint GenerateFieldAnnFlag
NotGenerateFieldAnn (Notes (ToT a), FieldAnn, Annotation VarTag)
-> Getting
(Notes (ToT a))
(Notes (ToT a), FieldAnn, Annotation VarTag)
(Notes (ToT a))
-> Notes (ToT a)
forall s a. s -> Getting a s a -> a
^. Getting
(Notes (ToT a))
(Notes (ToT a), FieldAnn, Annotation VarTag)
(Notes (ToT a))
forall s t a b. Field1 s t a b => Lens s t a b
_1
class HasAnnotation a where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT a)
default getAnnotation
:: (GHasAnnotation (G.Rep a), GValueType (G.Rep a) ~ ToT a)
=> FollowEntrypointFlag
-> Notes (ToT a)
getAnnotation b :: FollowEntrypointFlag
b = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (Rep a)), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @(G.Rep a) (HasAnnotation a => AnnOptions
forall a. HasAnnotation a => AnnOptions
annOptions @a) FollowEntrypointFlag
b GenerateFieldAnnFlag
GenerateFieldAnn (Notes (ToT a), FieldAnn, Annotation VarTag)
-> Getting
(Notes (ToT a))
(Notes (ToT a), FieldAnn, Annotation VarTag)
(Notes (ToT a))
-> Notes (ToT a)
forall s a. s -> Getting a s a -> a
^. Getting
(Notes (ToT a))
(Notes (ToT a), FieldAnn, Annotation VarTag)
(Notes (ToT a))
forall s t a b. Field1 s t a b => Lens s t a b
_1
annOptions :: AnnOptions
default annOptions :: AnnOptions
annOptions = AnnOptions
defaultAnnOptions
instance (HasAnnotation a, KnownSymbol name)
=> HasAnnotation (NamedF Identity a name) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (NamedF Identity a name))
getAnnotation b :: FollowEntrypointFlag
b = TypeAnn -> Notes (ToT a) -> Notes (ToT a)
forall (b :: T). TypeAnn -> Notes b -> Notes b
insertTypeAnn (KnownSymbol name => TypeAnn
forall (s :: Symbol). KnownSymbol s => TypeAnn
symbolAnn @name) (Notes (ToT a) -> Notes (ToT (NamedF Identity a name)))
-> Notes (ToT a) -> Notes (ToT (NamedF Identity a name))
forall a b. (a -> b) -> a -> b
$
FollowEntrypointFlag -> Notes (ToT a)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @a FollowEntrypointFlag
b
where
symbolAnn :: forall s. KnownSymbol s => TypeAnn
symbolAnn :: TypeAnn
symbolAnn = Text -> TypeAnn
forall k (a :: k). HasCallStack => Text -> Annotation a
ann (Text -> TypeAnn) -> Text -> TypeAnn
forall a b. (a -> b) -> a -> b
$ KnownSymbol s => Text
forall (s :: Symbol). KnownSymbol s => Text
symbolValT' @s
instance (HasAnnotation (Maybe a), KnownSymbol name)
=> HasAnnotation (NamedF Maybe a name) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (NamedF Maybe a name))
getAnnotation b :: FollowEntrypointFlag
b = FollowEntrypointFlag
-> Notes (ToT (NamedF Identity (Maybe a) name))
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @(NamedF Identity (Maybe a) name) FollowEntrypointFlag
b
instance (HasAnnotation a) => HasAnnotation (Maybe a) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (Maybe a))
getAnnotation _ = TypeAnn -> Notes (ToT a) -> Notes ('TOption (ToT a))
forall (t1 :: T). TypeAnn -> Notes t1 -> Notes ('TOption t1)
NTOption TypeAnn
forall k (a :: k). Annotation a
noAnn (FollowEntrypointFlag -> Notes (ToT a)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @a FollowEntrypointFlag
NotFollowEntrypoint)
instance HasAnnotation ()
instance HasAnnotation Integer where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Integer)
getAnnotation _ = Notes (ToT Integer)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation Natural where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Natural)
getAnnotation _ = Notes (ToT Natural)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation MText where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT MText)
getAnnotation _ = Notes (ToT MText)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation Bool where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Bool)
getAnnotation _ = Notes (ToT Bool)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation ByteString where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT ByteString)
getAnnotation _ = Notes (ToT ByteString)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation Mutez where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Mutez)
getAnnotation _ = Notes (ToT Mutez)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation Address where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Address)
getAnnotation _ = Notes (ToT Address)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation EpAddress where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT EpAddress)
getAnnotation _ = Notes (ToT EpAddress)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation KeyHash where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT KeyHash)
getAnnotation _ = Notes (ToT KeyHash)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation Timestamp where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Timestamp)
getAnnotation _ = Notes (ToT Timestamp)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation PublicKey where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT PublicKey)
getAnnotation _ = Notes (ToT PublicKey)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation Signature where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Signature)
getAnnotation _ = Notes (ToT Signature)
forall (t :: T). SingI t => Notes t
starNotes
instance HasAnnotation ChainId where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT ChainId)
getAnnotation _ = Notes (ToT ChainId)
forall (t :: T). SingI t => Notes t
starNotes
instance (HasAnnotation a) => HasAnnotation (ContractRef a) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (ContractRef a))
getAnnotation _ = TypeAnn -> Notes (ToT a) -> Notes ('TContract (ToT a))
forall (t1 :: T). TypeAnn -> Notes t1 -> Notes ('TContract t1)
NTContract TypeAnn
forall k (a :: k). Annotation a
noAnn (FollowEntrypointFlag -> Notes (ToT a)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @a FollowEntrypointFlag
NotFollowEntrypoint)
instance (HasAnnotation k, HasAnnotation v) => HasAnnotation (Map k v) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (Map k v))
getAnnotation _ = TypeAnn
-> Notes (ToT k) -> Notes (ToT v) -> Notes ('TMap (ToT k) (ToT v))
forall (k :: T) (v :: T).
TypeAnn -> Notes k -> Notes v -> Notes ('TMap k v)
NTMap TypeAnn
forall k (a :: k). Annotation a
noAnn (FollowEntrypointFlag -> Notes (ToT k)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @k FollowEntrypointFlag
NotFollowEntrypoint) (FollowEntrypointFlag -> Notes (ToT v)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @v FollowEntrypointFlag
NotFollowEntrypoint)
instance (HasAnnotation k, HasAnnotation v) => HasAnnotation (BigMap k v) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (BigMap k v))
getAnnotation _ = TypeAnn
-> Notes (ToT k)
-> Notes (ToT v)
-> Notes ('TBigMap (ToT k) (ToT v))
forall (k :: T) (v :: T).
TypeAnn -> Notes k -> Notes v -> Notes ('TBigMap k v)
NTBigMap TypeAnn
forall k (a :: k). Annotation a
noAnn (FollowEntrypointFlag -> Notes (ToT k)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @k FollowEntrypointFlag
NotFollowEntrypoint) (FollowEntrypointFlag -> Notes (ToT v)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @v FollowEntrypointFlag
NotFollowEntrypoint)
instance (KnownIsoT v) => HasAnnotation (Set v) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (Set v))
getAnnotation _ = Notes (ToT (Set v))
forall (t :: T). SingI t => Notes t
starNotes
instance (HasAnnotation a) => HasAnnotation [a] where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT [a])
getAnnotation _ = TypeAnn -> Notes (ToT a) -> Notes ('TList (ToT a))
forall (t1 :: T). TypeAnn -> Notes t1 -> Notes ('TList t1)
NTList TypeAnn
forall k (a :: k). Annotation a
noAnn (FollowEntrypointFlag -> Notes (ToT a)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @a FollowEntrypointFlag
NotFollowEntrypoint)
instance HasAnnotation Operation where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT Operation)
getAnnotation _ = Notes (ToT Operation)
forall (t :: T). SingI t => Notes t
starNotes
instance (HasAnnotation a, HasAnnotation b) => HasAnnotation (Either a b)
instance (HasAnnotation a, HasAnnotation b) => HasAnnotation (a, b)
instance (HasAnnotation a, HasAnnotation b, HasAnnotation c) => HasAnnotation (a, b, c)
instance (HasAnnotation a, HasAnnotation b, HasAnnotation c, HasAnnotation d) => HasAnnotation (a, b, c, d)
instance (HasAnnotation a, HasAnnotation b, HasAnnotation c, HasAnnotation d, HasAnnotation e)
=> HasAnnotation (a, b, c, d, e)
instance (HasAnnotation a, HasAnnotation b, HasAnnotation c, HasAnnotation d, HasAnnotation e, HasAnnotation f)
=> HasAnnotation (a, b, c, d, e, f)
instance
( HasAnnotation a, HasAnnotation b, HasAnnotation c, HasAnnotation d, HasAnnotation e
, HasAnnotation f, HasAnnotation g)
=> HasAnnotation (a, b, c, d, e, f, g)
class GHasAnnotation a where
gGetAnnotation :: AnnOptions -> FollowEntrypointFlag -> GenerateFieldAnnFlag -> (Notes (GValueType a), FieldAnn, VarAnn)
instance GHasAnnotation G.U1 where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType U1), FieldAnn, Annotation VarTag)
gGetAnnotation _ _ _ = (Notes (GValueType U1)
forall (t :: T). SingI t => Notes t
starNotes, FieldAnn
forall k (a :: k). Annotation a
noAnn, Annotation VarTag
forall k (a :: k). Annotation a
noAnn)
instance (GHasAnnotation x)
=> GHasAnnotation (G.M1 G.S ('G.MetaSel 'Nothing b c d) x)
where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (M1 S ('MetaSel 'Nothing b c d) x)),
FieldAnn, Annotation VarTag)
gGetAnnotation o :: AnnOptions
o b :: FollowEntrypointFlag
b b2 :: GenerateFieldAnnFlag
b2 = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
b GenerateFieldAnnFlag
b2
instance (GHasAnnotation x, KnownSymbol a)
=> GHasAnnotation (G.M1 G.S ('G.MetaSel ('Just a) b c d) x)
where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (M1 S ('MetaSel ('Just a) b c d) x)),
FieldAnn, Annotation VarTag)
gGetAnnotation o :: AnnOptions
o b :: FollowEntrypointFlag
b b2 :: GenerateFieldAnnFlag
b2 = case GenerateFieldAnnFlag
b2 of
GenerateFieldAnn -> (AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
b GenerateFieldAnnFlag
b2 (Notes (GValueType x), FieldAnn, Annotation VarTag)
-> Getting
(Notes (GValueType x))
(Notes (GValueType x), FieldAnn, Annotation VarTag)
(Notes (GValueType x))
-> Notes (GValueType x)
forall s a. s -> Getting a s a -> a
^. Getting
(Notes (GValueType x))
(Notes (GValueType x), FieldAnn, Annotation VarTag)
(Notes (GValueType x))
forall s t a b. Field1 s t a b => Lens s t a b
_1, AnnOptions -> FieldAnn
forall (ctor :: Symbol).
(KnownSymbol ctor, HasCallStack) =>
AnnOptions -> FieldAnn
ctorNameToAnnWithOptions @a AnnOptions
o, Annotation VarTag
forall k (a :: k). Annotation a
noAnn)
NotGenerateFieldAnn -> (AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
b GenerateFieldAnnFlag
b2 (Notes (GValueType x), FieldAnn, Annotation VarTag)
-> Getting
(Notes (GValueType x))
(Notes (GValueType x), FieldAnn, Annotation VarTag)
(Notes (GValueType x))
-> Notes (GValueType x)
forall s a. s -> Getting a s a -> a
^. Getting
(Notes (GValueType x))
(Notes (GValueType x), FieldAnn, Annotation VarTag)
(Notes (GValueType x))
forall s t a b. Field1 s t a b => Lens s t a b
_1, FieldAnn
forall k (a :: k). Annotation a
noAnn, Annotation VarTag
forall k (a :: k). Annotation a
noAnn)
instance (GHasAnnotation x, KnownSymbol a) => GHasAnnotation (G.M1 G.C ('G.MetaCons a _p _f) x) where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (M1 C ('MetaCons a _p _f) x)), FieldAnn,
Annotation VarTag)
gGetAnnotation o :: AnnOptions
o b :: FollowEntrypointFlag
b b2 :: GenerateFieldAnnFlag
b2 =
( AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
b GenerateFieldAnnFlag
b2 (Notes (GValueType x), FieldAnn, Annotation VarTag)
-> Getting
(Notes (GValueType x))
(Notes (GValueType x), FieldAnn, Annotation VarTag)
(Notes (GValueType x))
-> Notes (GValueType x)
forall s a. s -> Getting a s a -> a
^. Getting
(Notes (GValueType x))
(Notes (GValueType x), FieldAnn, Annotation VarTag)
(Notes (GValueType x))
forall s t a b. Field1 s t a b => Lens s t a b
_1
, AnnOptions -> FieldAnn
forall (ctor :: Symbol).
(KnownSymbol ctor, HasCallStack) =>
AnnOptions -> FieldAnn
ctorNameToAnnWithOptions @a AnnOptions
o
, Annotation VarTag
forall k (a :: k). Annotation a
noAnn
)
instance (GHasAnnotation x) => GHasAnnotation (G.M1 G.D i1 x) where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (M1 D i1 x)), FieldAnn, Annotation VarTag)
gGetAnnotation o :: AnnOptions
o b :: FollowEntrypointFlag
b b2 :: GenerateFieldAnnFlag
b2 = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
b GenerateFieldAnnFlag
b2
instance
( GHasAnnotation x
, GHasAnnotation y
)
=>
GHasAnnotation (x G.:+: y)
where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (x :+: y)), FieldAnn, Annotation VarTag)
gGetAnnotation o :: AnnOptions
o followEntrypointFlag :: FollowEntrypointFlag
followEntrypointFlag generateAnnFlag :: GenerateFieldAnnFlag
generateAnnFlag =
let (xTypeAnn :: Notes (GValueType x)
xTypeAnn, xFieldAnn :: FieldAnn
xFieldAnn, xVarAnn :: Annotation VarTag
xVarAnn) = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
followEntrypointFlag GenerateFieldAnnFlag
generateAnnFlag
(yTypeAnn :: Notes (GValueType y)
yTypeAnn, yFieldAnn :: FieldAnn
yFieldAnn, yVarAnn :: Annotation VarTag
yVarAnn) = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType y), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @y AnnOptions
o FollowEntrypointFlag
followEntrypointFlag GenerateFieldAnnFlag
generateAnnFlag
in case (FollowEntrypointFlag
followEntrypointFlag, GenerateFieldAnnFlag
generateAnnFlag) of
(NotFollowEntrypoint, GenerateFieldAnn) ->
( TypeAnn
-> FieldAnn
-> FieldAnn
-> Notes (GValueType x)
-> Notes (GValueType y)
-> Notes ('TOr (GValueType x) (GValueType y))
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes ('TOr p q)
NTOr TypeAnn
forall k (a :: k). Annotation a
noAnn
FieldAnn
xFieldAnn FieldAnn
yFieldAnn
Notes (GValueType x)
xTypeAnn Notes (GValueType y)
yTypeAnn
, FieldAnn
forall k (a :: k). Annotation a
noAnn
, Annotation VarTag
xVarAnn
)
_ ->
( TypeAnn
-> FieldAnn
-> FieldAnn
-> Notes (GValueType x)
-> Notes (GValueType y)
-> Notes ('TOr (GValueType x) (GValueType y))
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes ('TOr p q)
NTOr TypeAnn
forall k (a :: k). Annotation a
noAnn
FieldAnn
forall k (a :: k). Annotation a
noAnn FieldAnn
forall k (a :: k). Annotation a
noAnn
Notes (GValueType x)
xTypeAnn Notes (GValueType y)
yTypeAnn
, FieldAnn
forall k (a :: k). Annotation a
noAnn
, Annotation VarTag
yVarAnn
)
instance
( GHasAnnotation x
, GHasAnnotation y
)
=>
GHasAnnotation (x G.:*: y)
where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (x :*: y)), FieldAnn, Annotation VarTag)
gGetAnnotation o :: AnnOptions
o _ b2 :: GenerateFieldAnnFlag
b2 =
let (xTypeAnn :: Notes (GValueType x)
xTypeAnn, xFieldAnn :: FieldAnn
xFieldAnn, xVarAnn :: Annotation VarTag
xVarAnn) = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType x), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @x AnnOptions
o FollowEntrypointFlag
NotFollowEntrypoint GenerateFieldAnnFlag
b2
(yTypeAnn :: Notes (GValueType y)
yTypeAnn, yFieldAnn :: FieldAnn
yFieldAnn, yVarAnn :: Annotation VarTag
yVarAnn) = AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType y), FieldAnn, Annotation VarTag)
forall (a :: * -> *).
GHasAnnotation a =>
AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType a), FieldAnn, Annotation VarTag)
gGetAnnotation @y AnnOptions
o FollowEntrypointFlag
NotFollowEntrypoint GenerateFieldAnnFlag
b2
in
( TypeAnn
-> FieldAnn
-> FieldAnn
-> Annotation VarTag
-> Annotation VarTag
-> Notes (GValueType x)
-> Notes (GValueType y)
-> Notes ('TPair (GValueType x) (GValueType y))
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn
-> FieldAnn
-> Annotation VarTag
-> Annotation VarTag
-> Notes p
-> Notes q
-> Notes ('TPair p q)
NTPair TypeAnn
forall k (a :: k). Annotation a
noAnn
FieldAnn
xFieldAnn FieldAnn
yFieldAnn
Annotation VarTag
xVarAnn Annotation VarTag
yVarAnn
Notes (GValueType x)
xTypeAnn Notes (GValueType y)
yTypeAnn
, FieldAnn
forall k (a :: k). Annotation a
noAnn
, Annotation VarTag
forall k (a :: k). Annotation a
noAnn
)
instance (HasAnnotation x) => GHasAnnotation (G.Rec0 x) where
gGetAnnotation :: AnnOptions
-> FollowEntrypointFlag
-> GenerateFieldAnnFlag
-> (Notes (GValueType (Rec0 x)), FieldAnn, Annotation VarTag)
gGetAnnotation _ b :: FollowEntrypointFlag
b _ = (FollowEntrypointFlag -> Notes (ToT x)
forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @x FollowEntrypointFlag
b, FieldAnn
forall k (a :: k). Annotation a
noAnn, Annotation VarTag
forall k (a :: k). Annotation a
noAnn)