{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module Michelson.Typed.Haskell.Doc
( ADTRep
, WithinParens (..)
, TypeHasDoc (..)
, TypeDocHaskellRep
, TypeDocMichelsonRep
, PolyTypeHasDocC
, SomeTypeWithDoc (..)
, typeDocDependencies'
, HaveCommonTypeCtor
, IsHomomorphic
, genericTypeDocDependencies
, customTypeDocMdReference
, homomorphicTypeDocMdReference
, poly1TypeDocMdReference
, poly2TypeDocMdReference
, homomorphicTypeDocHaskellRep
, concreteTypeDocHaskellRep
, concreteTypeDocHaskellRepUnsafe
, haskellRepNoFields
, haskellRepStripFieldPrefix
, homomorphicTypeDocMichelsonRep
, concreteTypeDocMichelsonRep
, concreteTypeDocMichelsonRepUnsafe
, DType (..)
, DStorageType (..)
, GTypeHasDoc
, buildADTRep
, applyWithinParens
) where
import Data.Char (isLower, isUpper, toLower)
import qualified Data.Kind as Kind
import Data.Singletons (SingI, demote)
import qualified Data.Text as T
import Data.Typeable (typeRep)
import Fmt (Buildable, build, (+|), (|+))
import GHC.Generics ((:*:)(..), (:+:)(..))
import qualified GHC.Generics as G
import GHC.TypeLits (ErrorMessage(..), KnownSymbol, TypeError, symbolVal)
import Named (NamedF)
import qualified Text.Show
import Type.Showtype (Showtype(..))
import Michelson.Doc
import Michelson.Text
import Michelson.Typed.Aliases
import Michelson.Typed.EntryPoints
import Michelson.Typed.Haskell.Value
import Michelson.Typed.T
import Tezos.Address
import Tezos.Core
import Tezos.Crypto
import Util.Generic
import Util.Markdown
import Util.Named
import Util.Typeable
type ADTRep a = NonEmpty (Text, [(Maybe Text, a)])
buildADTRep :: forall a. (WithinParens -> a -> Markdown) -> ADTRep a -> Markdown
buildADTRep buildField = \case
p :| [] -> renderProduct (WithinParens False) (snd p)
ps -> (mappend (mdItalic "one of" <> " \n")) $
mconcat . map (("+ " <> ) . (<> "\n")) $
map (renderNamedProduct (WithinParens True)) (toList ps)
where
renderNamedProduct :: WithinParens -> (Text, [(Maybe Text, a)]) -> Markdown
renderNamedProduct wp (ctor, tys) =
mdBold (build ctor) <> " " <> renderProduct wp tys
renderProduct :: WithinParens -> [(Maybe Text, a)] -> Markdown
renderProduct wp = \case
[] -> "()"
[t] -> renderNamedField wp t
ts -> "(" <> (mconcat . intersperse ", " $ map (renderNamedField wp) ts) <> ")"
renderNamedField :: WithinParens -> (Maybe Text, a) -> Markdown
renderNamedField wp (mfieldName, ty) =
maybe "" buildFieldName mfieldName <>
buildField wp ty
mapADTRepFields :: (Maybe Text -> Maybe Text) -> ADTRep a -> ADTRep a
mapADTRepFields f = fmap . second . fmap $ first f
buildFieldName :: Text -> Markdown
buildFieldName name = mdItalic (mdBold (build name)) |+ " :"
newtype WithinParens = WithinParens Bool
applyWithinParens :: WithinParens -> Markdown -> Markdown
applyWithinParens (WithinParens wp) txt
| wp = "(" <> txt <> ")"
| otherwise = txt
class Typeable a => TypeHasDoc a where
typeDocName :: Proxy a -> Text
default typeDocName
:: (Generic a, KnownSymbol (GenericTypeName a))
=> Proxy a -> Text
typeDocName _ = toText $ symbolVal (Proxy @(GenericTypeName a))
typeDocMdDescription :: Markdown
typeDocMdReference :: Proxy a -> WithinParens -> Markdown
default typeDocMdReference
:: (Typeable a, IsHomomorphic a)
=> Proxy a -> WithinParens -> Markdown
typeDocMdReference = homomorphicTypeDocMdReference
typeDocDependencies :: Proxy a -> [SomeTypeWithDoc]
default typeDocDependencies
:: (Generic a, GTypeHasDoc (G.Rep a))
=> Proxy a -> [SomeTypeWithDoc]
typeDocDependencies = genericTypeDocDependencies
typeDocHaskellRep :: TypeDocHaskellRep a
default typeDocHaskellRep
:: (Generic a, GTypeHasDoc (G.Rep a), IsHomomorphic a)
=> TypeDocHaskellRep a
typeDocHaskellRep = haskellRepStripFieldPrefix homomorphicTypeDocHaskellRep
typeDocMichelsonRep :: TypeDocMichelsonRep a
default typeDocMichelsonRep
:: (SingI (ToT a), IsHomomorphic a)
=> TypeDocMichelsonRep a
typeDocMichelsonRep = homomorphicTypeDocMichelsonRep
type TypeDocHaskellRep a =
Proxy a -> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
type TypeDocMichelsonRep a =
Proxy a -> (Maybe DocTypeRepLHS, T)
data SomeTypeWithDoc where
SomeTypeWithDoc :: TypeHasDoc td => Proxy td -> SomeTypeWithDoc
newtype DocTypeRepLHS = DocTypeRepLHS Text
deriving newtype (IsString, Buildable)
typeDocDependencies'
:: TypeHasDoc a
=> Proxy a
-> [SomeDocDefinitionItem]
typeDocDependencies' at =
typeDocDependencies at <&>
\(SomeTypeWithDoc t) -> SomeDocDefinitionItem (DType t)
data DType where
DType :: TypeHasDoc a => Proxy a -> DType
instance Show DType where
show (DType a) = show $ typeRep a
instance Eq DType where
DType a1 == DType a2 = a1 `eqExt` a2
instance Ord DType where
DType a1 `compare` DType a2 = a1 `compareExt` a2
instance DocItem DType where
type DocItemPosition DType = 5000
type DocItemPlacement DType = 'DocItemInDefinitions
docItemSectionName = Just "Types"
docItemRef (DType a) = DocItemRef $
DocItemId ("types-" <> typeDocName a)
docItemDependencies (DType (ap' :: Proxy a)) =
typeDocDependencies' ap'
docItemToMarkdown lvl (DType (ap' :: Proxy a)) =
mconcat . catMaybes $
[ Just mdSeparator
, Just $ mdHeader lvl (mdTicked . build $ typeDocName ap')
, Just $ typeDocMdDescription @a |+ "\n\n"
, typeDocHaskellRep ap' <&> \(mlhs, rep) ->
let
buildField wp (SomeTypeWithDoc di) =
typeDocMdReference di wp
renderedRep =
buildADTRep buildField rep
rendered = case mlhs of
Nothing ->
mdSubsection "Structure" renderedRep
Just lhs ->
mdSubsection "Structure (example)" $
mdTicked (build lhs) <> " = " <> renderedRep
in rendered <> "\n\n"
, Just $
let (mlhs, rep) = typeDocMichelsonRep ap'
renderedRep = mdTicked (build rep)
rendered = case mlhs of
Nothing -> mdSubsection "Final Michelson representation"
renderedRep
Just lhs -> mdSubsection "Final Michelson representation (example)" $
mdTicked (build lhs) <> " = " <> renderedRep
in rendered <> "\n\n"
]
newtype DStorageType = DStorageType DType
instance DocItem DStorageType where
type DocItemPosition DStorageType = 2035
docItemSectionName = Just "Storage"
docItemToMarkdown lvl (DStorageType t) = docItemToMarkdown lvl t
docItemDependencies (DStorageType t) = docItemDependencies t
class HaveCommonTypeCtor a b
instance HaveCommonTypeCtor ac bc => HaveCommonTypeCtor (ac a) (bc b)
instance HaveCommonTypeCtor a a
class IsHomomorphic a where
instance TypeError ('Text "Type is not homomorphic: " ':<>: 'ShowType (a b)) =>
IsHomomorphic (a b)
instance {-# OVERLAPPABLE #-} IsHomomorphic a
customTypeDocMdReference :: (Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference (typeCtorName, tyDoc) typeArgsDoc wp =
let DocItemRef (DocItemId ctorDocItemId) = docItemRef tyDoc
in applyWithinParens wpSmart $
mconcat . intersperse " " $
( mdLocalRef (mdTicked $ build typeCtorName) ctorDocItemId
: (typeArgsDoc <&> \(DType di) -> typeDocMdReference di (WithinParens True))
)
where
wpSmart =
let WithinParens wp' = wp
in WithinParens (wp' && not (null typeArgsDoc))
homomorphicTypeDocMdReference
:: forall (t :: Kind.Type).
(Typeable t, TypeHasDoc t, IsHomomorphic t)
=> Proxy t -> WithinParens -> Markdown
homomorphicTypeDocMdReference tp _ =
customTypeDocMdReference
(toText $ showtype tp, DType tp)
[]
(WithinParens False)
poly1TypeDocMdReference
:: forall t (r :: Kind.Type) (a :: Kind.Type).
(r ~ t a, Typeable t, Each '[TypeHasDoc] [r, a], IsHomomorphic t)
=> Proxy r -> WithinParens -> Markdown
poly1TypeDocMdReference tp =
customTypeDocMdReference
(toText $ showtype (Proxy @t), DType tp)
[DType (Proxy @a)]
poly2TypeDocMdReference
:: forall t (r :: Kind.Type) (a :: Kind.Type) (b :: Kind.Type).
(r ~ t a b, Typeable t, Each '[TypeHasDoc] [r, a, b], IsHomomorphic t)
=> Proxy r -> WithinParens -> Markdown
poly2TypeDocMdReference tp =
customTypeDocMdReference
(toText $ showtype (Proxy @t), DType tp)
[ DType (Proxy @a)
, DType (Proxy @b)
]
genericTypeDocDependencies
:: forall a.
(Generic a, GTypeHasDoc (G.Rep a))
=> Proxy a -> [SomeTypeWithDoc]
genericTypeDocDependencies _ = do
(_, products) <- toList $ gTypeDocHaskellRep @(G.Rep a)
(_, ty) <- products
return ty
homomorphicTypeDocHaskellRep
:: forall a.
(Generic a, GTypeHasDoc (G.Rep a))
=> TypeDocHaskellRep a
homomorphicTypeDocHaskellRep _ = Just
( Nothing
, gTypeDocHaskellRep @(G.Rep a)
)
concreteTypeDocHaskellRep
:: forall a b.
( Typeable a, GenericIsoValue a, GTypeHasDoc (G.Rep a)
, HaveCommonTypeCtor b a
)
=> TypeDocHaskellRep b
concreteTypeDocHaskellRep = concreteTypeDocHaskellRepUnsafe @a
concreteTypeDocHaskellRepUnsafe
:: forall a b.
( Typeable a, GenericIsoValue a, GTypeHasDoc (G.Rep a)
)
=> TypeDocHaskellRep b
concreteTypeDocHaskellRepUnsafe _ = Just
( Just (DocTypeRepLHS . toText . showtype $ Proxy @a)
, gTypeDocHaskellRep @(G.Rep a)
)
haskellRepNoFields :: TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepNoFields mkRep =
\p -> second (mapADTRepFields (const Nothing)) <$> mkRep p
haskellRepStripFieldPrefix
:: HasCallStack
=> TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepStripFieldPrefix mkRep =
\p -> second (mapADTRepFields (fmap stripPrefix)) <$> mkRep p
where
stripPrefix fieldName =
case T.uncons $ T.dropWhile isLower fieldName of
Nothing -> error $ "Field '" <> fieldName <> "' has no prefix"
Just (c, cs) ->
let isAbbreviation = case T.uncons cs of
Just (c2, _)
| isUpper c2 -> True
| otherwise -> False
Nothing -> False
in T.cons (if isAbbreviation then c else toLower c) cs
homomorphicTypeDocMichelsonRep
:: forall a.
SingI (ToT a)
=> TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep _ =
( Nothing
, demote @(ToT a)
)
concreteTypeDocMichelsonRep
:: forall a b.
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a)
=> TypeDocMichelsonRep b
concreteTypeDocMichelsonRep _ =
( Just (DocTypeRepLHS . toText . showtype $ Proxy @a)
, demote @(ToT a)
)
concreteTypeDocMichelsonRepUnsafe
:: forall a b.
(Typeable a, SingI (ToT a))
=> TypeDocMichelsonRep b
concreteTypeDocMichelsonRepUnsafe _ =
( Just (DocTypeRepLHS . toText . showtype $ Proxy @a)
, demote @(ToT a)
)
class GTypeHasDoc (x :: Kind.Type -> Kind.Type) where
gTypeDocHaskellRep :: ADTRep SomeTypeWithDoc
instance GTypeHasDoc x => GTypeHasDoc (G.D1 i x) where
gTypeDocHaskellRep = gTypeDocHaskellRep @x
instance (GTypeHasDoc x, GTypeHasDoc y) => GTypeHasDoc (x :+: y) where
gTypeDocHaskellRep = gTypeDocHaskellRep @x <> gTypeDocHaskellRep @y
instance (GProductHasDoc x, KnownSymbol ctor) =>
GTypeHasDoc (G.C1 ('G.MetaCons ctor _1 _2) x) where
gTypeDocHaskellRep = one $
( toText $ symbolVal (Proxy @ctor)
, gProductDocHaskellRep @x
)
instance TypeError ('Text "Cannot derive documentation for void-like type") =>
GTypeHasDoc G.V1 where
gTypeDocHaskellRep = error "impossible"
class GProductHasDoc (x :: Kind.Type -> Kind.Type) where
gProductDocHaskellRep :: [(Maybe Text, SomeTypeWithDoc)]
instance (GProductHasDoc x, GProductHasDoc y) => GProductHasDoc (x :*: y) where
gProductDocHaskellRep = gProductDocHaskellRep @x <> gProductDocHaskellRep @y
instance TypeHasDoc a =>
GProductHasDoc (G.S1 ('G.MetaSel 'Nothing _1 _2 _3) (G.Rec0 a)) where
gProductDocHaskellRep = one (Nothing, SomeTypeWithDoc (Proxy @a))
instance (TypeHasDoc a, KnownSymbol field) =>
GProductHasDoc (G.S1 ('G.MetaSel ('Just field) _1 _2 _3) (G.Rec0 a)) where
gProductDocHaskellRep = one
( Just $ toText (symbolVal $ Proxy @field)
, SomeTypeWithDoc (Proxy @a)
)
instance GProductHasDoc G.U1 where
gProductDocHaskellRep = mempty
type PolyTypeHasDocC ts = Each '[TypeHasDoc] ts
type PolyCTypeHasDocC ts = Each '[TypeHasDoc] ts
instance TypeHasDoc Integer where
typeDocName _ = "Integer"
typeDocMdDescription = "Signed number."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc Natural where
typeDocName _ = "Natural"
typeDocMdDescription = "Unsigned number."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc MText where
typeDocName _ = "Text"
typeDocMdReference p = customTypeDocMdReference ("Text", DType p) []
typeDocMdDescription =
"Michelson string.\n\
\Not every text literal is valid string, see list of constraints in the \
\[Official Michelson documentation](https://tezos.gitlab.io/whitedoc/michelson.html#constants)."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc Bool where
typeDocName _ = "Bool"
typeDocMdDescription = "Bool primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc ByteString where
typeDocName _ = "ByteString"
typeDocMdDescription = "Bytes primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc Mutez where
typeDocName _ = "Mutez"
typeDocMdDescription = "Mutez primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc KeyHash where
typeDocName _ = "KeyHash"
typeDocMdDescription = "KeyHash primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc Timestamp where
typeDocName _ = "Timestamp"
typeDocMdDescription = "Timestamp primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc Address where
typeDocName _ = "Address simplified"
typeDocMdDescription =
"This is similar to Michelson Address, but does not retain entrypoint name \
\if it refers to a contract."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc EpAddress where
typeDocName _ = "Address"
typeDocMdDescription = "Address primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc PublicKey where
typeDocName _ = "PublicKey"
typeDocMdDescription = "PublicKey primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc Signature where
typeDocName _ = "Signature"
typeDocMdDescription = "Signature primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
instance TypeHasDoc () where
typeDocName _ = "()"
typeDocMdDescription = "Unit primitive."
typeDocDependencies _ = []
instance PolyTypeHasDocC '[a] => TypeHasDoc [a] where
typeDocName _ = "List"
typeDocMdDescription = "List primitive."
typeDocMdReference _ =
customTypeDocMdReference ("List", DType (Proxy @[a])) [DType (Proxy @a)]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @[Integer]
instance PolyTypeHasDocC '[a] => TypeHasDoc (Maybe a) where
typeDocMdDescription = "Option primitive."
typeDocMdReference = poly1TypeDocMdReference
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(Maybe Integer)
instance PolyTypeHasDocC [l, r] => TypeHasDoc (Either l r) where
typeDocMdDescription = "Or primitive."
typeDocMdReference = poly2TypeDocMdReference
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(Either Integer Natural)
instance PolyTypeHasDocC [a, b] => TypeHasDoc (a, b) where
typeDocName _ = "(a, b)"
typeDocMdReference _ = tupleTypeDocReference
[ typeDocMdReference (Proxy @a) (WithinParens False)
, typeDocMdReference (Proxy @b) (WithinParens False)
]
typeDocMdDescription = "Pair primitive."
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(Integer, Natural)
instance PolyCTypeHasDocC '[a] => TypeHasDoc (Set a) where
typeDocName _ = "Set"
typeDocMdReference = poly1TypeDocMdReference
typeDocMdDescription = "Set primitive."
typeDocDependencies _ = [SomeTypeWithDoc (Proxy @a)]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(Set Integer)
instance TypeHasDoc Operation where
typeDocName _ = "Operation"
typeDocMdReference tp = customTypeDocMdReference ("Operation", DType tp) []
typeDocMdDescription = "Operation primitive."
typeDocDependencies _ = []
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = homomorphicTypeDocMichelsonRep
instance PolyTypeHasDocC '[cp] => TypeHasDoc (ContractRef cp) where
typeDocName _ = "Contract"
typeDocMdReference = poly1TypeDocMdReference
typeDocMdDescription = "Contract primitive with given type of parameter."
typeDocDependencies _ = [SomeTypeWithDoc (Proxy @cp)]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(ContractRef Integer)
instance (PolyCTypeHasDocC '[k], PolyTypeHasDocC '[v], Ord k) =>
TypeHasDoc (Map k v) where
typeDocName _ = "Map"
typeDocMdReference = poly2TypeDocMdReference
typeDocMdDescription = "Map primitive."
typeDocDependencies _ = [SomeTypeWithDoc (Proxy @k), SomeTypeWithDoc (Proxy @v)]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(Map Integer Natural)
instance (PolyCTypeHasDocC '[k], PolyTypeHasDocC '[v], Ord k) =>
TypeHasDoc (BigMap k v) where
typeDocName _ = "BigMap"
typeDocMdReference = poly2TypeDocMdReference
typeDocMdDescription = "BigMap primitive."
typeDocDependencies _ = [SomeTypeWithDoc (Proxy @k), SomeTypeWithDoc (Proxy @v)]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(BigMap Integer Natural)
tupleTypeDocReference :: [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference vs _ = "(" +| mconcat (intersperse ", " $ map build vs) |+ ")"
instance PolyTypeHasDocC [a, b, c] => TypeHasDoc (a, b, c) where
typeDocName _ = "(a, b, c)"
typeDocMdReference _ = tupleTypeDocReference
[ typeDocMdReference (Proxy @a) (WithinParens False)
, typeDocMdReference (Proxy @b) (WithinParens False)
, typeDocMdReference (Proxy @c) (WithinParens False)
]
typeDocMdDescription = "Tuple of size 3."
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep = concreteTypeDocMichelsonRep @(Integer, Natural, MText)
instance PolyTypeHasDocC [a, b, c, d] => TypeHasDoc (a, b, c, d) where
typeDocName _ = "(a, b, c, d)"
typeDocMdReference _ = tupleTypeDocReference
[ typeDocMdReference (Proxy @a) (WithinParens False)
, typeDocMdReference (Proxy @b) (WithinParens False)
, typeDocMdReference (Proxy @c) (WithinParens False)
, typeDocMdReference (Proxy @d) (WithinParens False)
]
typeDocMdDescription = "Tuple of size 4."
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep =
concreteTypeDocMichelsonRep @((), (), (), ())
instance PolyTypeHasDocC [a, b, c, d, e] => TypeHasDoc (a, b, c, d, e) where
typeDocName _ = "(a, b, c, d, e)"
typeDocMdDescription = "Tuple of size 5."
typeDocMdReference _ = tupleTypeDocReference
[ typeDocMdReference (Proxy @a) (WithinParens False)
, typeDocMdReference (Proxy @b) (WithinParens False)
, typeDocMdReference (Proxy @c) (WithinParens False)
, typeDocMdReference (Proxy @d) (WithinParens False)
, typeDocMdReference (Proxy @e) (WithinParens False)
]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep =
concreteTypeDocMichelsonRep @((), (), (), (), ())
instance PolyTypeHasDocC [a, b, c, d, e, f] => TypeHasDoc (a, b, c, d, e, f) where
typeDocName _ = "(a, b, c, d, e, f)"
typeDocMdReference _ = tupleTypeDocReference
[ typeDocMdReference (Proxy @a) (WithinParens False)
, typeDocMdReference (Proxy @b) (WithinParens False)
, typeDocMdReference (Proxy @c) (WithinParens False)
, typeDocMdReference (Proxy @d) (WithinParens False)
, typeDocMdReference (Proxy @e) (WithinParens False)
, typeDocMdReference (Proxy @f) (WithinParens False)
]
typeDocMdDescription = "Tuple of size 6."
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep =
concreteTypeDocMichelsonRep @((), (), (), (), (), ())
instance PolyTypeHasDocC [a, b, c, d, e, f, g] => TypeHasDoc (a, b, c, d, e, f, g) where
typeDocName _ = "(a, b, c, d, e, f, g)"
typeDocMdReference _ = tupleTypeDocReference
[ typeDocMdReference (Proxy @a) (WithinParens False)
, typeDocMdReference (Proxy @b) (WithinParens False)
, typeDocMdReference (Proxy @c) (WithinParens False)
, typeDocMdReference (Proxy @d) (WithinParens False)
, typeDocMdReference (Proxy @e) (WithinParens False)
, typeDocMdReference (Proxy @f) (WithinParens False)
, typeDocMdReference (Proxy @g) (WithinParens False)
]
typeDocMdDescription = "Tuple of size 7."
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep =
concreteTypeDocMichelsonRep @((), (), (), (), (), (), ())
instance ( TypeHasDoc (ApplyNamedFunctor f a)
, KnownSymbol n
, SingI (ToT (ApplyNamedFunctor f Integer))
, Typeable f, Typeable a
) =>
TypeHasDoc (NamedF f a n) where
typeDocName _ = "Named entry"
typeDocMdReference _ wp =
applyWithinParens wp $
buildFieldName (toText (symbolVal $ Proxy @n)) +| " " +|
typeDocMdReference (Proxy @(ApplyNamedFunctor f a)) (WithinParens False) |+ ""
typeDocDependencies _ =
[SomeTypeWithDoc (Proxy @(ApplyNamedFunctor f a)), SomeTypeWithDoc (Proxy @Integer)]
typeDocHaskellRep _ = Nothing
typeDocMichelsonRep _ = (Just "number: Integer", demote @(ToT (ApplyNamedFunctor f Integer)))
typeDocMdDescription =
"Some entries have names for clarity.\n\n\
\In resulting Michelson names may be mapped to annotations."