{-# 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 :: (WithinParens -> a -> Markdown) -> ADTRep a -> Markdown
buildADTRep buildField :: WithinParens -> a -> Markdown
buildField = \case
p :: (Text, [(Maybe Text, a)])
p :| [] -> WithinParens -> [(Maybe Text, a)] -> Markdown
renderProduct (Bool -> WithinParens
WithinParens Bool
False) ((Text, [(Maybe Text, a)]) -> [(Maybe Text, a)]
forall a b. (a, b) -> b
snd (Text, [(Maybe Text, a)])
p)
ps :: ADTRep a
ps -> (Markdown -> Markdown -> Markdown
forall a. Monoid a => a -> a -> a
mappend (Markdown -> Markdown
mdItalic "one of" Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> " \n")) (Markdown -> Markdown) -> Markdown -> Markdown
forall a b. (a -> b) -> a -> b
$
[Markdown] -> Markdown
forall a. Monoid a => [a] -> a
mconcat ([Markdown] -> Markdown)
-> ([Markdown] -> [Markdown]) -> [Markdown] -> Markdown
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Markdown -> Markdown) -> [Markdown] -> [Markdown]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (("+ " Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> ) (Markdown -> Markdown)
-> (Markdown -> Markdown) -> Markdown -> Markdown
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> "\n")) ([Markdown] -> Markdown) -> [Markdown] -> Markdown
forall a b. (a -> b) -> a -> b
$
((Text, [(Maybe Text, a)]) -> Markdown)
-> [(Text, [(Maybe Text, a)])] -> [Markdown]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (WithinParens -> (Text, [(Maybe Text, a)]) -> Markdown
renderNamedProduct (Bool -> WithinParens
WithinParens Bool
True)) (ADTRep a -> [Element (ADTRep a)]
forall t. Container t => t -> [Element t]
toList ADTRep a
ps)
where
renderNamedProduct :: WithinParens -> (Text, [(Maybe Text, a)]) -> Markdown
renderNamedProduct :: WithinParens -> (Text, [(Maybe Text, a)]) -> Markdown
renderNamedProduct wp :: WithinParens
wp (ctor :: Text
ctor, tys :: [(Maybe Text, a)]
tys) =
Markdown -> Markdown
mdBold (Text -> Markdown
forall p. Buildable p => p -> Markdown
build Text
ctor) Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> " " Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> WithinParens -> [(Maybe Text, a)] -> Markdown
renderProduct WithinParens
wp [(Maybe Text, a)]
tys
renderProduct :: WithinParens -> [(Maybe Text, a)] -> Markdown
renderProduct :: WithinParens -> [(Maybe Text, a)] -> Markdown
renderProduct wp :: WithinParens
wp = \case
[] -> "()"
[t :: (Maybe Text, a)
t] -> WithinParens -> (Maybe Text, a) -> Markdown
renderNamedField WithinParens
wp (Maybe Text, a)
t
ts :: [(Maybe Text, a)]
ts -> "(" Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> ([Markdown] -> Markdown
forall a. Monoid a => [a] -> a
mconcat ([Markdown] -> Markdown)
-> ([Markdown] -> [Markdown]) -> [Markdown] -> Markdown
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Markdown -> [Markdown] -> [Markdown]
forall a. a -> [a] -> [a]
intersperse ", " ([Markdown] -> Markdown) -> [Markdown] -> Markdown
forall a b. (a -> b) -> a -> b
$ ((Maybe Text, a) -> Markdown) -> [(Maybe Text, a)] -> [Markdown]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (WithinParens -> (Maybe Text, a) -> Markdown
renderNamedField WithinParens
wp) [(Maybe Text, a)]
ts) Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> ")"
renderNamedField :: WithinParens -> (Maybe Text, a) -> Markdown
renderNamedField :: WithinParens -> (Maybe Text, a) -> Markdown
renderNamedField wp :: WithinParens
wp (mfieldName :: Maybe Text
mfieldName, ty :: a
ty) =
Markdown -> (Text -> Markdown) -> Maybe Text -> Markdown
forall b a. b -> (a -> b) -> Maybe a -> b
maybe "" Text -> Markdown
buildFieldName Maybe Text
mfieldName Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<>
WithinParens -> a -> Markdown
buildField WithinParens
wp a
ty
mapADTRepFields :: (Maybe Text -> Maybe Text) -> ADTRep a -> ADTRep a
mapADTRepFields :: (Maybe Text -> Maybe Text) -> ADTRep a -> ADTRep a
mapADTRepFields f :: Maybe Text -> Maybe Text
f = ((Text, [(Maybe Text, a)]) -> (Text, [(Maybe Text, a)]))
-> ADTRep a -> ADTRep a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Text, [(Maybe Text, a)]) -> (Text, [(Maybe Text, a)]))
-> ADTRep a -> ADTRep a)
-> (((Maybe Text, a) -> (Maybe Text, a))
-> (Text, [(Maybe Text, a)]) -> (Text, [(Maybe Text, a)]))
-> ((Maybe Text, a) -> (Maybe Text, a))
-> ADTRep a
-> ADTRep a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([(Maybe Text, a)] -> [(Maybe Text, a)])
-> (Text, [(Maybe Text, a)]) -> (Text, [(Maybe Text, a)])
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (([(Maybe Text, a)] -> [(Maybe Text, a)])
-> (Text, [(Maybe Text, a)]) -> (Text, [(Maybe Text, a)]))
-> (((Maybe Text, a) -> (Maybe Text, a))
-> [(Maybe Text, a)] -> [(Maybe Text, a)])
-> ((Maybe Text, a) -> (Maybe Text, a))
-> (Text, [(Maybe Text, a)])
-> (Text, [(Maybe Text, a)])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Maybe Text, a) -> (Maybe Text, a))
-> [(Maybe Text, a)] -> [(Maybe Text, a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((Maybe Text, a) -> (Maybe Text, a)) -> ADTRep a -> ADTRep a)
-> ((Maybe Text, a) -> (Maybe Text, a)) -> ADTRep a -> ADTRep a
forall a b. (a -> b) -> a -> b
$ (Maybe Text -> Maybe Text) -> (Maybe Text, a) -> (Maybe Text, a)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Maybe Text -> Maybe Text
f
buildFieldName :: Text -> Markdown
buildFieldName :: Text -> Markdown
buildFieldName name :: Text
name = Markdown -> Markdown
mdItalic (Markdown -> Markdown
mdBold (Text -> Markdown
forall p. Buildable p => p -> Markdown
build Text
name)) Markdown -> Markdown -> Markdown
forall a b. (Buildable a, FromBuilder b) => a -> Markdown -> b
|+ " :"
newtype WithinParens = WithinParens Bool
applyWithinParens :: WithinParens -> Markdown -> Markdown
applyWithinParens :: WithinParens -> Markdown -> Markdown
applyWithinParens (WithinParens wp :: Bool
wp) txt :: Markdown
txt
| Bool
wp = "(" Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Markdown
txt Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> ")"
| Bool
otherwise = Markdown
txt
class Typeable a => TypeHasDoc a where
typeDocName :: Proxy a -> Text
default typeDocName
:: (Generic a, KnownSymbol (GenericTypeName a))
=> Proxy a -> Text
typeDocName _ = String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Proxy (GTypeName (Rep a)) -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy (GTypeName (Rep a))
forall k (t :: k). Proxy t
Proxy @(GenericTypeName a))
typeDocMdDescription :: Markdown
typeDocMdReference :: Proxy a -> WithinParens -> Markdown
default typeDocMdReference
:: (Typeable a, IsHomomorphic a)
=> Proxy a -> WithinParens -> Markdown
typeDocMdReference = Proxy a -> WithinParens -> Markdown
forall t.
(Typeable t, TypeHasDoc t, IsHomomorphic t) =>
Proxy t -> WithinParens -> Markdown
homomorphicTypeDocMdReference
typeDocDependencies :: Proxy a -> [SomeTypeWithDoc]
default typeDocDependencies
:: (Generic a, GTypeHasDoc (G.Rep a))
=> Proxy a -> [SomeTypeWithDoc]
typeDocDependencies = Proxy a -> [SomeTypeWithDoc]
forall a.
(Generic a, GTypeHasDoc (Rep a)) =>
Proxy a -> [SomeTypeWithDoc]
genericTypeDocDependencies
typeDocHaskellRep :: TypeDocHaskellRep a
default typeDocHaskellRep
:: (Generic a, GTypeHasDoc (G.Rep a), IsHomomorphic a)
=> TypeDocHaskellRep a
typeDocHaskellRep = TypeDocHaskellRep a -> TypeDocHaskellRep a
forall a.
HasCallStack =>
TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepStripFieldPrefix TypeDocHaskellRep a
forall a. (Generic a, GTypeHasDoc (Rep a)) => TypeDocHaskellRep a
homomorphicTypeDocHaskellRep
typeDocMichelsonRep :: TypeDocMichelsonRep a
default typeDocMichelsonRep
:: (SingI (ToT a), IsHomomorphic a)
=> TypeDocMichelsonRep a
typeDocMichelsonRep = TypeDocMichelsonRep a
forall a. SingI (ToT a) => TypeDocMichelsonRep a
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 (String -> DocTypeRepLHS
(String -> DocTypeRepLHS) -> IsString DocTypeRepLHS
forall a. (String -> a) -> IsString a
fromString :: String -> DocTypeRepLHS
$cfromString :: String -> DocTypeRepLHS
IsString, DocTypeRepLHS -> Markdown
(DocTypeRepLHS -> Markdown) -> Buildable DocTypeRepLHS
forall p. (p -> Markdown) -> Buildable p
build :: DocTypeRepLHS -> Markdown
$cbuild :: DocTypeRepLHS -> Markdown
Buildable)
typeDocDependencies'
:: TypeHasDoc a
=> Proxy a
-> [SomeDocDefinitionItem]
typeDocDependencies' :: Proxy a -> [SomeDocDefinitionItem]
typeDocDependencies' at :: Proxy a
at =
Proxy a -> [SomeTypeWithDoc]
forall a. TypeHasDoc a => Proxy a -> [SomeTypeWithDoc]
typeDocDependencies Proxy a
at [SomeTypeWithDoc]
-> (SomeTypeWithDoc -> SomeDocDefinitionItem)
-> [SomeDocDefinitionItem]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&>
\(SomeTypeWithDoc t :: Proxy td
t) -> DType -> SomeDocDefinitionItem
forall d.
(DocItem d, DocItemPlacement d ~ 'DocItemInDefinitions) =>
d -> SomeDocDefinitionItem
SomeDocDefinitionItem (Proxy td -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy td
t)
data DType where
DType :: TypeHasDoc a => Proxy a -> DType
instance Show DType where
show :: DType -> String
show (DType a :: Proxy a
a) = TypeRep -> String
forall b a. (Show a, IsString b) => a -> b
show (TypeRep -> String) -> TypeRep -> String
forall a b. (a -> b) -> a -> b
$ Proxy a -> TypeRep
forall k (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep Proxy a
a
instance Eq DType where
DType a1 :: Proxy a
a1 == :: DType -> DType -> Bool
== DType a2 :: Proxy a
a2 = Proxy a
a1 Proxy a -> Proxy a -> Bool
forall a1 a2. (Typeable a1, Typeable a2, Eq a1) => a1 -> a2 -> Bool
`eqExt` Proxy a
a2
instance Ord DType where
DType a1 :: Proxy a
a1 compare :: DType -> DType -> Ordering
`compare` DType a2 :: Proxy a
a2 = Proxy a
a1 Proxy a -> Proxy a -> Ordering
forall a1 a2.
(Typeable a1, Typeable a2, Ord a1) =>
a1 -> a2 -> Ordering
`compareExt` Proxy a
a2
instance DocItem DType where
type DocItemPosition DType = 5000
type DocItemPlacement DType = 'DocItemInDefinitions
docItemSectionName :: Maybe Text
docItemSectionName = Text -> Maybe Text
forall a. a -> Maybe a
Just "Types"
docItemRef :: DType -> DocItemRef (DocItemPlacement DType)
docItemRef (DType a :: Proxy a
a) = DocItemId -> DocItemRef 'DocItemInDefinitions
DocItemId -> DocItemRef (DocItemPlacement DType)
DocItemRef (DocItemId -> DocItemRef (DocItemPlacement DType))
-> DocItemId -> DocItemRef (DocItemPlacement DType)
forall a b. (a -> b) -> a -> b
$
Text -> DocItemId
DocItemId ("types-" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Proxy a -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy a
a)
docItemDependencies :: DType -> [SomeDocDefinitionItem]
docItemDependencies (DType (Proxy a
ap' :: Proxy a)) =
Proxy a -> [SomeDocDefinitionItem]
forall a. TypeHasDoc a => Proxy a -> [SomeDocDefinitionItem]
typeDocDependencies' Proxy a
ap'
docItemToMarkdown :: HeaderLevel -> DType -> Markdown
docItemToMarkdown lvl :: HeaderLevel
lvl (DType (Proxy a
ap' :: Proxy a)) =
[Markdown] -> Markdown
forall a. Monoid a => [a] -> a
mconcat ([Markdown] -> Markdown)
-> ([Maybe Markdown] -> [Markdown]) -> [Maybe Markdown] -> Markdown
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe Markdown] -> [Markdown]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe Markdown] -> Markdown) -> [Maybe Markdown] -> Markdown
forall a b. (a -> b) -> a -> b
$
[ Markdown -> Maybe Markdown
forall a. a -> Maybe a
Just Markdown
mdSeparator
, Markdown -> Maybe Markdown
forall a. a -> Maybe a
Just (Markdown -> Maybe Markdown) -> Markdown -> Maybe Markdown
forall a b. (a -> b) -> a -> b
$ HeaderLevel -> Markdown -> Markdown
mdHeader HeaderLevel
lvl (Markdown -> Markdown
mdTicked (Markdown -> Markdown) -> (Text -> Markdown) -> Text -> Markdown
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Markdown
forall p. Buildable p => p -> Markdown
build (Text -> Markdown) -> Text -> Markdown
forall a b. (a -> b) -> a -> b
$ Proxy a -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy a
ap')
, Markdown -> Maybe Markdown
forall a. a -> Maybe a
Just (Markdown -> Maybe Markdown) -> Markdown -> Maybe Markdown
forall a b. (a -> b) -> a -> b
$ TypeHasDoc a => Markdown
forall a. TypeHasDoc a => Markdown
typeDocMdDescription @a Markdown -> Markdown -> Markdown
forall a b. (Buildable a, FromBuilder b) => a -> Markdown -> b
|+ "\n\n"
, TypeDocHaskellRep a
forall a. TypeHasDoc a => TypeDocHaskellRep a
typeDocHaskellRep Proxy a
ap' Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> ((Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc) -> Markdown)
-> Maybe Markdown
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(mlhs :: Maybe DocTypeRepLHS
mlhs, rep :: ADTRep SomeTypeWithDoc
rep) ->
let
buildField :: WithinParens -> SomeTypeWithDoc -> Markdown
buildField wp :: WithinParens
wp (SomeTypeWithDoc di :: Proxy td
di) =
Proxy td -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference Proxy td
di WithinParens
wp
renderedRep :: Markdown
renderedRep =
(WithinParens -> SomeTypeWithDoc -> Markdown)
-> ADTRep SomeTypeWithDoc -> Markdown
forall a. (WithinParens -> a -> Markdown) -> ADTRep a -> Markdown
buildADTRep WithinParens -> SomeTypeWithDoc -> Markdown
buildField ADTRep SomeTypeWithDoc
rep
rendered :: Markdown
rendered = case Maybe DocTypeRepLHS
mlhs of
Nothing ->
Markdown -> Markdown -> Markdown
mdSubsection "Structure" Markdown
renderedRep
Just lhs :: DocTypeRepLHS
lhs ->
Markdown -> Markdown -> Markdown
mdSubsection "Structure (example)" (Markdown -> Markdown) -> Markdown -> Markdown
forall a b. (a -> b) -> a -> b
$
Markdown -> Markdown
mdTicked (DocTypeRepLHS -> Markdown
forall p. Buildable p => p -> Markdown
build DocTypeRepLHS
lhs) Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> " = " Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Markdown
renderedRep
in Markdown
rendered Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> "\n\n"
, Markdown -> Maybe Markdown
forall a. a -> Maybe a
Just (Markdown -> Maybe Markdown) -> Markdown -> Maybe Markdown
forall a b. (a -> b) -> a -> b
$
let (mlhs :: Maybe DocTypeRepLHS
mlhs, rep :: T
rep) = TypeDocMichelsonRep a
forall a. TypeHasDoc a => TypeDocMichelsonRep a
typeDocMichelsonRep Proxy a
ap'
renderedRep :: Markdown
renderedRep = Markdown -> Markdown
mdTicked (T -> Markdown
forall p. Buildable p => p -> Markdown
build T
rep)
rendered :: Markdown
rendered = case Maybe DocTypeRepLHS
mlhs of
Nothing -> Markdown -> Markdown -> Markdown
mdSubsection "Final Michelson representation"
Markdown
renderedRep
Just lhs :: DocTypeRepLHS
lhs -> Markdown -> Markdown -> Markdown
mdSubsection "Final Michelson representation (example)" (Markdown -> Markdown) -> Markdown -> Markdown
forall a b. (a -> b) -> a -> b
$
Markdown -> Markdown
mdTicked (DocTypeRepLHS -> Markdown
forall p. Buildable p => p -> Markdown
build DocTypeRepLHS
lhs) Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> " = " Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Markdown
renderedRep
in Markdown
rendered Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> "\n\n"
]
newtype DStorageType = DStorageType DType
deriving stock (forall x. DStorageType -> Rep DStorageType x)
-> (forall x. Rep DStorageType x -> DStorageType)
-> Generic DStorageType
forall x. Rep DStorageType x -> DStorageType
forall x. DStorageType -> Rep DStorageType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DStorageType x -> DStorageType
$cfrom :: forall x. DStorageType -> Rep DStorageType x
Generic
instance DocItem DStorageType where
type DocItemPosition DStorageType = 835
docItemSectionName :: Maybe Text
docItemSectionName = Text -> Maybe Text
forall a. a -> Maybe a
Just "Storage"
docItemToMarkdown :: HeaderLevel -> DStorageType -> Markdown
docItemToMarkdown lvl :: HeaderLevel
lvl (DStorageType t :: DType
t) = HeaderLevel -> DType -> Markdown
forall d. DocItem d => HeaderLevel -> d -> Markdown
docItemToMarkdown HeaderLevel
lvl DType
t
docItemDependencies :: DStorageType -> [SomeDocDefinitionItem]
docItemDependencies (DStorageType t :: DType
t) = DType -> [SomeDocDefinitionItem]
forall d. DocItem d => d -> [SomeDocDefinitionItem]
docItemDependencies DType
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 :: (Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference (typeCtorName :: Text
typeCtorName, tyDoc :: DType
tyDoc) typeArgsDoc :: [DType]
typeArgsDoc wp :: WithinParens
wp =
let DocItemRef ctorDocItemId = DType -> DocItemRef (DocItemPlacement DType)
forall d. DocItem d => d -> DocItemRef (DocItemPlacement d)
docItemRef DType
tyDoc
in WithinParens -> Markdown -> Markdown
applyWithinParens WithinParens
wpSmart (Markdown -> Markdown) -> Markdown -> Markdown
forall a b. (a -> b) -> a -> b
$
[Markdown] -> Markdown
forall a. Monoid a => [a] -> a
mconcat ([Markdown] -> Markdown)
-> ([Markdown] -> [Markdown]) -> [Markdown] -> Markdown
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Markdown -> [Markdown] -> [Markdown]
forall a. a -> [a] -> [a]
intersperse " " ([Markdown] -> Markdown) -> [Markdown] -> Markdown
forall a b. (a -> b) -> a -> b
$
( Markdown -> DocItemId -> Markdown
forall anchor. ToAnchor anchor => Markdown -> anchor -> Markdown
mdLocalRef (Markdown -> Markdown
mdTicked (Markdown -> Markdown) -> Markdown -> Markdown
forall a b. (a -> b) -> a -> b
$ Text -> Markdown
forall p. Buildable p => p -> Markdown
build Text
typeCtorName) DocItemId
ctorDocItemId
Markdown -> [Markdown] -> [Markdown]
forall a. a -> [a] -> [a]
: ([DType]
typeArgsDoc [DType] -> (DType -> Markdown) -> [Markdown]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(DType di :: Proxy a
di) -> Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference Proxy a
di (Bool -> WithinParens
WithinParens Bool
True))
)
where
wpSmart :: WithinParens
wpSmart =
let WithinParens wp' :: Bool
wp' = WithinParens
wp
in Bool -> WithinParens
WithinParens (Bool
wp' Bool -> Bool -> Bool
&& Bool -> Bool
not ([DType] -> Bool
forall t. Container t => t -> Bool
null [DType]
typeArgsDoc))
homomorphicTypeDocMdReference
:: forall (t :: Kind.Type).
(Typeable t, TypeHasDoc t, IsHomomorphic t)
=> Proxy t -> WithinParens -> Markdown
homomorphicTypeDocMdReference :: Proxy t -> WithinParens -> Markdown
homomorphicTypeDocMdReference tp :: Proxy t
tp _ =
(Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference
(Proxy t -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy t
tp, Proxy t -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy t
tp)
[]
(Bool -> WithinParens
WithinParens Bool
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 :: Proxy r -> WithinParens -> Markdown
poly1TypeDocMdReference tp :: Proxy r
tp =
(Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference
(String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Proxy t -> String
forall k (a :: k) (proxy :: k -> *).
Showtype a =>
proxy a -> String
showtype (Proxy t
forall k (t :: k). Proxy t
Proxy @t), Proxy r -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy r
tp)
[Proxy a -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (Proxy a
forall k (t :: k). Proxy t
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 :: Proxy r -> WithinParens -> Markdown
poly2TypeDocMdReference tp :: Proxy r
tp =
(Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference
(String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Proxy t -> String
forall k (a :: k) (proxy :: k -> *).
Showtype a =>
proxy a -> String
showtype (Proxy t
forall k (t :: k). Proxy t
Proxy @t), Proxy r -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy r
tp)
[ Proxy a -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
, Proxy b -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (Proxy b
forall k (t :: k). Proxy t
Proxy @b)
]
genericTypeDocDependencies
:: forall a.
(Generic a, GTypeHasDoc (G.Rep a))
=> Proxy a -> [SomeTypeWithDoc]
genericTypeDocDependencies :: Proxy a -> [SomeTypeWithDoc]
genericTypeDocDependencies _ = do
(_, products :: [(Maybe Text, SomeTypeWithDoc)]
products) <- ADTRep SomeTypeWithDoc -> [(Text, [(Maybe Text, SomeTypeWithDoc)])]
forall t. Container t => t -> [Element t]
toList (ADTRep SomeTypeWithDoc
-> [(Text, [(Maybe Text, SomeTypeWithDoc)])])
-> ADTRep SomeTypeWithDoc
-> [(Text, [(Maybe Text, SomeTypeWithDoc)])]
forall a b. (a -> b) -> a -> b
$ GTypeHasDoc (Rep a) => ADTRep SomeTypeWithDoc
forall (x :: * -> *). GTypeHasDoc x => ADTRep SomeTypeWithDoc
gTypeDocHaskellRep @(G.Rep a)
(_, ty :: SomeTypeWithDoc
ty) <- [(Maybe Text, SomeTypeWithDoc)]
products
SomeTypeWithDoc -> [SomeTypeWithDoc]
forall (m :: * -> *) a. Monad m => a -> m a
return SomeTypeWithDoc
ty
homomorphicTypeDocHaskellRep
:: forall a.
(Generic a, GTypeHasDoc (G.Rep a))
=> TypeDocHaskellRep a
homomorphicTypeDocHaskellRep :: TypeDocHaskellRep a
homomorphicTypeDocHaskellRep _ = (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. a -> Maybe a
Just
( Maybe DocTypeRepLHS
forall a. Maybe a
Nothing
, GTypeHasDoc (Rep a) => ADTRep SomeTypeWithDoc
forall (x :: * -> *). GTypeHasDoc x => ADTRep SomeTypeWithDoc
gTypeDocHaskellRep @(G.Rep a)
)
concreteTypeDocHaskellRep
:: forall a b.
( Typeable a, GenericIsoValue a, GTypeHasDoc (G.Rep a)
, HaveCommonTypeCtor b a
)
=> TypeDocHaskellRep b
concreteTypeDocHaskellRep :: TypeDocHaskellRep b
concreteTypeDocHaskellRep = forall b.
(Typeable a, GenericIsoValue a, GTypeHasDoc (Rep a)) =>
TypeDocHaskellRep b
forall a b.
(Typeable a, GenericIsoValue a, GTypeHasDoc (Rep a)) =>
TypeDocHaskellRep b
concreteTypeDocHaskellRepUnsafe @a
concreteTypeDocHaskellRepUnsafe
:: forall a b.
( Typeable a, GenericIsoValue a, GTypeHasDoc (G.Rep a)
)
=> TypeDocHaskellRep b
concreteTypeDocHaskellRepUnsafe :: TypeDocHaskellRep b
concreteTypeDocHaskellRepUnsafe _ = (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. a -> Maybe a
Just
( DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a. a -> Maybe a
Just (Text -> DocTypeRepLHS
DocTypeRepLHS (Text -> DocTypeRepLHS)
-> (Proxy a -> Text) -> Proxy a -> DocTypeRepLHS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> (Proxy a -> String) -> Proxy a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> String
forall k (a :: k) (proxy :: k -> *).
Showtype a =>
proxy a -> String
showtype (Proxy a -> DocTypeRepLHS) -> Proxy a -> DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ Proxy a
forall k (t :: k). Proxy t
Proxy @a)
, GTypeHasDoc (Rep a) => ADTRep SomeTypeWithDoc
forall (x :: * -> *). GTypeHasDoc x => ADTRep SomeTypeWithDoc
gTypeDocHaskellRep @(G.Rep a)
)
haskellRepNoFields :: TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepNoFields :: TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepNoFields mkRep :: TypeDocHaskellRep a
mkRep =
\p :: Proxy a
p -> (ADTRep SomeTypeWithDoc -> ADTRep SomeTypeWithDoc)
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second ((Maybe Text -> Maybe Text)
-> ADTRep SomeTypeWithDoc -> ADTRep SomeTypeWithDoc
forall a. (Maybe Text -> Maybe Text) -> ADTRep a -> ADTRep a
mapADTRepFields (Maybe Text -> Maybe Text -> Maybe Text
forall a b. a -> b -> a
const Maybe Text
forall a. Maybe a
Nothing)) ((Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc))
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeDocHaskellRep a
mkRep Proxy a
p
haskellRepStripFieldPrefix
:: HasCallStack
=> TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepStripFieldPrefix :: TypeDocHaskellRep a -> TypeDocHaskellRep a
haskellRepStripFieldPrefix mkRep :: TypeDocHaskellRep a
mkRep =
\p :: Proxy a
p -> (ADTRep SomeTypeWithDoc -> ADTRep SomeTypeWithDoc)
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second ((Maybe Text -> Maybe Text)
-> ADTRep SomeTypeWithDoc -> ADTRep SomeTypeWithDoc
forall a. (Maybe Text -> Maybe Text) -> ADTRep a -> ADTRep a
mapADTRepFields ((Text -> Text) -> Maybe Text -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Text
stripPrefix)) ((Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc))
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeDocHaskellRep a
mkRep Proxy a
p
where
stripPrefix :: Text -> Text
stripPrefix fieldName :: Text
fieldName =
case Text -> Maybe (Char, Text)
T.uncons (Text -> Maybe (Char, Text)) -> Text -> Maybe (Char, Text)
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> Text -> Text
T.dropWhile Char -> Bool
isLower Text
fieldName of
Nothing -> Text -> Text
forall a. HasCallStack => Text -> a
error (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$ "Field '" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
fieldName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "' has no prefix"
Just (c :: Char
c, cs :: Text
cs) ->
let isAbbreviation :: Bool
isAbbreviation = case Text -> Maybe (Char, Text)
T.uncons Text
cs of
Just (c2 :: Char
c2, _)
| Char -> Bool
isUpper Char
c2 -> Bool
True
| Bool
otherwise -> Bool
False
Nothing -> Bool
False
in Char -> Text -> Text
T.cons (if Bool
isAbbreviation then Char
c else Char -> Char
toLower Char
c) Text
cs
homomorphicTypeDocMichelsonRep
:: forall a.
SingI (ToT a)
=> TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep :: TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep _ =
( Maybe DocTypeRepLHS
forall a. Maybe a
Nothing
, (SingKind T, SingI (ToT a)) => Demote T
forall k (a :: k). (SingKind k, SingI a) => Demote k
demote @(ToT a)
)
concreteTypeDocMichelsonRep
:: forall a b.
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a)
=> TypeDocMichelsonRep b
concreteTypeDocMichelsonRep :: TypeDocMichelsonRep b
concreteTypeDocMichelsonRep _ =
( DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a. a -> Maybe a
Just (Text -> DocTypeRepLHS
DocTypeRepLHS (Text -> DocTypeRepLHS)
-> (Proxy a -> Text) -> Proxy a -> DocTypeRepLHS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> (Proxy a -> String) -> Proxy a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> String
forall k (a :: k) (proxy :: k -> *).
Showtype a =>
proxy a -> String
showtype (Proxy a -> DocTypeRepLHS) -> Proxy a -> DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ Proxy a
forall k (t :: k). Proxy t
Proxy @a)
, (SingKind T, SingI (ToT a)) => Demote T
forall k (a :: k). (SingKind k, SingI a) => Demote k
demote @(ToT a)
)
concreteTypeDocMichelsonRepUnsafe
:: forall a b.
(Typeable a, SingI (ToT a))
=> TypeDocMichelsonRep b
concreteTypeDocMichelsonRepUnsafe :: TypeDocMichelsonRep b
concreteTypeDocMichelsonRepUnsafe _ =
( DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a. a -> Maybe a
Just (Text -> DocTypeRepLHS
DocTypeRepLHS (Text -> DocTypeRepLHS)
-> (Proxy a -> Text) -> Proxy a -> DocTypeRepLHS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> (Proxy a -> String) -> Proxy a -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> String
forall k (a :: k) (proxy :: k -> *).
Showtype a =>
proxy a -> String
showtype (Proxy a -> DocTypeRepLHS) -> Proxy a -> DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ Proxy a
forall k (t :: k). Proxy t
Proxy @a)
, (SingKind T, SingI (ToT a)) => Demote T
forall k (a :: k). (SingKind k, SingI a) => Demote k
demote @(ToT a)
)
class GTypeHasDoc (x :: Kind.Type -> Kind.Type) where
gTypeDocHaskellRep :: ADTRep SomeTypeWithDoc
instance GTypeHasDoc x => GTypeHasDoc (G.D1 i x) where
gTypeDocHaskellRep :: ADTRep SomeTypeWithDoc
gTypeDocHaskellRep = GTypeHasDoc x => ADTRep SomeTypeWithDoc
forall (x :: * -> *). GTypeHasDoc x => ADTRep SomeTypeWithDoc
gTypeDocHaskellRep @x
instance (GTypeHasDoc x, GTypeHasDoc y) => GTypeHasDoc (x :+: y) where
gTypeDocHaskellRep :: ADTRep SomeTypeWithDoc
gTypeDocHaskellRep = GTypeHasDoc x => ADTRep SomeTypeWithDoc
forall (x :: * -> *). GTypeHasDoc x => ADTRep SomeTypeWithDoc
gTypeDocHaskellRep @x ADTRep SomeTypeWithDoc
-> ADTRep SomeTypeWithDoc -> ADTRep SomeTypeWithDoc
forall a. Semigroup a => a -> a -> a
<> GTypeHasDoc y => ADTRep SomeTypeWithDoc
forall (x :: * -> *). GTypeHasDoc x => ADTRep SomeTypeWithDoc
gTypeDocHaskellRep @y
instance (GProductHasDoc x, KnownSymbol ctor) =>
GTypeHasDoc (G.C1 ('G.MetaCons ctor _1 _2) x) where
gTypeDocHaskellRep :: ADTRep SomeTypeWithDoc
gTypeDocHaskellRep = OneItem (ADTRep SomeTypeWithDoc) -> ADTRep SomeTypeWithDoc
forall x. One x => OneItem x -> x
one (OneItem (ADTRep SomeTypeWithDoc) -> ADTRep SomeTypeWithDoc)
-> OneItem (ADTRep SomeTypeWithDoc) -> ADTRep SomeTypeWithDoc
forall a b. (a -> b) -> a -> b
$
( String -> Text
forall a. ToText a => a -> Text
toText (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Proxy ctor -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy ctor
forall k (t :: k). Proxy t
Proxy @ctor)
, GProductHasDoc x => [(Maybe Text, SomeTypeWithDoc)]
forall (x :: * -> *).
GProductHasDoc x =>
[(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep @x
)
instance TypeError ('Text "Cannot derive documentation for void-like type") =>
GTypeHasDoc G.V1 where
gTypeDocHaskellRep :: ADTRep SomeTypeWithDoc
gTypeDocHaskellRep = Text -> ADTRep SomeTypeWithDoc
forall a. HasCallStack => Text -> a
error "impossible"
class GProductHasDoc (x :: Kind.Type -> Kind.Type) where
gProductDocHaskellRep :: [(Maybe Text, SomeTypeWithDoc)]
instance (GProductHasDoc x, GProductHasDoc y) => GProductHasDoc (x :*: y) where
gProductDocHaskellRep :: [(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep = GProductHasDoc x => [(Maybe Text, SomeTypeWithDoc)]
forall (x :: * -> *).
GProductHasDoc x =>
[(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep @x [(Maybe Text, SomeTypeWithDoc)]
-> [(Maybe Text, SomeTypeWithDoc)]
-> [(Maybe Text, SomeTypeWithDoc)]
forall a. Semigroup a => a -> a -> a
<> GProductHasDoc y => [(Maybe Text, SomeTypeWithDoc)]
forall (x :: * -> *).
GProductHasDoc x =>
[(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep @y
instance TypeHasDoc a =>
GProductHasDoc (G.S1 ('G.MetaSel 'Nothing _1 _2 _3) (G.Rec0 a)) where
gProductDocHaskellRep :: [(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep = OneItem [(Maybe Text, SomeTypeWithDoc)]
-> [(Maybe Text, SomeTypeWithDoc)]
forall x. One x => OneItem x -> x
one (Maybe Text
forall a. Maybe a
Nothing, Proxy a -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy a
forall k (t :: k). Proxy t
Proxy @a))
instance (TypeHasDoc a, KnownSymbol field) =>
GProductHasDoc (G.S1 ('G.MetaSel ('Just field) _1 _2 _3) (G.Rec0 a)) where
gProductDocHaskellRep :: [(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep = OneItem [(Maybe Text, SomeTypeWithDoc)]
-> [(Maybe Text, SomeTypeWithDoc)]
forall x. One x => OneItem x -> x
one
( Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> Text -> Maybe Text
forall a b. (a -> b) -> a -> b
$ String -> Text
forall a. ToText a => a -> Text
toText (Proxy field -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy field -> String) -> Proxy field -> String
forall a b. (a -> b) -> a -> b
$ Proxy field
forall k (t :: k). Proxy t
Proxy @field)
, Proxy a -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy a
forall k (t :: k). Proxy t
Proxy @a)
)
instance GProductHasDoc G.U1 where
gProductDocHaskellRep :: [(Maybe Text, SomeTypeWithDoc)]
gProductDocHaskellRep = [(Maybe Text, SomeTypeWithDoc)]
forall a. Monoid a => a
mempty
type PolyTypeHasDocC ts = Each '[TypeHasDoc] ts
type PolyCTypeHasDocC ts = Each '[TypeHasDoc] ts
instance TypeHasDoc Integer where
typeDocName :: Proxy Integer -> Text
typeDocName _ = "Integer"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Signed number."
typeDocDependencies :: Proxy Integer -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Integer
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc Natural where
typeDocName :: Proxy Natural -> Text
typeDocName _ = "Natural"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Unsigned number."
typeDocDependencies :: Proxy Natural -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Natural
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc MText where
typeDocName :: Proxy MText -> Text
typeDocName _ = "Text"
typeDocMdReference :: Proxy MText -> WithinParens -> Markdown
typeDocMdReference p :: Proxy MText
p = (Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference ("Text", Proxy MText -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy MText
p) []
typeDocMdDescription :: Markdown
typeDocMdDescription =
"Michelson string.\n\n\
\This has to contain only ASCII characters with codes from [32; 126] range; \
\additionally, newline feed character is allowed."
typeDocDependencies :: Proxy MText -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep MText
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc Bool where
typeDocName :: Proxy Bool -> Text
typeDocName _ = "Bool"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Bool primitive."
typeDocDependencies :: Proxy Bool -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Bool
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc ByteString where
typeDocName :: Proxy ByteString -> Text
typeDocName _ = "ByteString"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Bytes primitive."
typeDocDependencies :: Proxy ByteString -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep ByteString
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc Mutez where
typeDocName :: Proxy Mutez -> Text
typeDocName _ = "Mutez"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Mutez primitive."
typeDocDependencies :: Proxy Mutez -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Mutez
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc KeyHash where
typeDocName :: Proxy KeyHash -> Text
typeDocName _ = "KeyHash"
typeDocMdDescription :: Markdown
typeDocMdDescription = "KeyHash primitive."
typeDocDependencies :: Proxy KeyHash -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep KeyHash
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc Timestamp where
typeDocName :: Proxy Timestamp -> Text
typeDocName _ = "Timestamp"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Timestamp primitive."
typeDocDependencies :: Proxy Timestamp -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Timestamp
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc Address where
typeDocName :: Proxy Address -> Text
typeDocName _ = "Address (no entrypoint)"
typeDocMdDescription :: Markdown
typeDocMdDescription =
"This is similar to Michelson Address, but does not retain entrypoint name \
\if it refers to a contract."
typeDocDependencies :: Proxy Address -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Address
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc EpAddress where
typeDocName :: Proxy EpAddress -> Text
typeDocName _ = "Address"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Address primitive."
typeDocDependencies :: Proxy EpAddress -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep EpAddress
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc PublicKey where
typeDocName :: Proxy PublicKey -> Text
typeDocName _ = "PublicKey"
typeDocMdDescription :: Markdown
typeDocMdDescription = "PublicKey primitive."
typeDocDependencies :: Proxy PublicKey -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep PublicKey
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc Signature where
typeDocName :: Proxy Signature -> Text
typeDocName _ = "Signature"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Signature primitive."
typeDocDependencies :: Proxy Signature -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Signature
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
instance TypeHasDoc () where
typeDocName :: Proxy () -> Text
typeDocName _ = "()"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Unit primitive."
typeDocDependencies :: Proxy () -> [SomeTypeWithDoc]
typeDocDependencies _ = []
instance PolyTypeHasDocC '[a] => TypeHasDoc [a] where
typeDocName :: Proxy [a] -> Text
typeDocName _ = "List"
typeDocMdDescription :: Markdown
typeDocMdDescription = "List primitive."
typeDocMdReference :: Proxy [a] -> WithinParens -> Markdown
typeDocMdReference _ =
(Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference ("List", Proxy [a] -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (Proxy [a]
forall k (t :: k). Proxy t
Proxy @[a])) [Proxy a -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (Proxy a
forall k (t :: k). Proxy t
Proxy @a)]
typeDocHaskellRep :: TypeDocHaskellRep [a]
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep [a]
typeDocMichelsonRep = forall b.
(Typeable [Integer], SingI (ToT [Integer]),
HaveCommonTypeCtor b [Integer]) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @[Integer]
instance PolyTypeHasDocC '[a] => TypeHasDoc (Maybe a) where
typeDocMdDescription :: Markdown
typeDocMdDescription = "Option primitive."
typeDocMdReference :: Proxy (Maybe a) -> WithinParens -> Markdown
typeDocMdReference = Proxy (Maybe a) -> WithinParens -> Markdown
forall (t :: * -> *) r a.
(r ~ t a, Typeable t, Each '[TypeHasDoc] '[r, a],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly1TypeDocMdReference
typeDocHaskellRep :: TypeDocHaskellRep (Maybe a)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (Maybe a)
typeDocMichelsonRep = forall b.
(Typeable (Maybe Integer), SingI (ToT (Maybe Integer)),
HaveCommonTypeCtor b (Maybe Integer)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(Maybe Integer)
instance PolyTypeHasDocC [l, r] => TypeHasDoc (Either l r) where
typeDocMdDescription :: Markdown
typeDocMdDescription = "Or primitive."
typeDocMdReference :: Proxy (Either l r) -> WithinParens -> Markdown
typeDocMdReference = Proxy (Either l r) -> WithinParens -> Markdown
forall (t :: * -> * -> *) r a b.
(r ~ t a b, Typeable t, Each '[TypeHasDoc] '[r, a, b],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly2TypeDocMdReference
typeDocHaskellRep :: TypeDocHaskellRep (Either l r)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (Either l r)
typeDocMichelsonRep = forall b.
(Typeable (Either Integer Natural),
SingI (ToT (Either Integer Natural)),
HaveCommonTypeCtor b (Either Integer Natural)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(Either Integer Natural)
instance PolyTypeHasDocC [a, b] => TypeHasDoc (a, b) where
typeDocName :: Proxy (a, b) -> Text
typeDocName _ = "(a, b)"
typeDocMdReference :: Proxy (a, b) -> WithinParens -> Markdown
typeDocMdReference _ = [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference
[ Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy a
forall k (t :: k). Proxy t
Proxy @a) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy b -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy b
forall k (t :: k). Proxy t
Proxy @b) (Bool -> WithinParens
WithinParens Bool
False)
]
typeDocMdDescription :: Markdown
typeDocMdDescription = "Pair primitive."
typeDocHaskellRep :: TypeDocHaskellRep (a, b)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (a, b)
typeDocMichelsonRep = forall b.
(Typeable (Integer, Natural), SingI (ToT (Integer, Natural)),
HaveCommonTypeCtor b (Integer, Natural)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(Integer, Natural)
instance PolyCTypeHasDocC '[a] => TypeHasDoc (Set a) where
typeDocName :: Proxy (Set a) -> Text
typeDocName _ = "Set"
typeDocMdReference :: Proxy (Set a) -> WithinParens -> Markdown
typeDocMdReference = Proxy (Set a) -> WithinParens -> Markdown
forall (t :: * -> *) r a.
(r ~ t a, Typeable t, Each '[TypeHasDoc] '[r, a],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly1TypeDocMdReference
typeDocMdDescription :: Markdown
typeDocMdDescription = "Set primitive."
typeDocDependencies :: Proxy (Set a) -> [SomeTypeWithDoc]
typeDocDependencies _ = [Proxy a -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy a
forall k (t :: k). Proxy t
Proxy @a)]
typeDocHaskellRep :: TypeDocHaskellRep (Set a)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (Set a)
typeDocMichelsonRep = forall b.
(Typeable (Set Integer), SingI (ToT (Set Integer)),
HaveCommonTypeCtor b (Set Integer)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(Set Integer)
instance TypeHasDoc Operation where
typeDocName :: Proxy Operation -> Text
typeDocName _ = "Operation"
typeDocMdReference :: Proxy Operation -> WithinParens -> Markdown
typeDocMdReference tp :: Proxy Operation
tp = (Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference ("Operation", Proxy Operation -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy Operation
tp) []
typeDocMdDescription :: Markdown
typeDocMdDescription = "Operation primitive."
typeDocDependencies :: Proxy Operation -> [SomeTypeWithDoc]
typeDocDependencies _ = []
typeDocHaskellRep :: TypeDocHaskellRep Operation
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep Operation
typeDocMichelsonRep = TypeDocMichelsonRep Operation
forall a. SingI (ToT a) => TypeDocMichelsonRep a
homomorphicTypeDocMichelsonRep
instance PolyTypeHasDocC '[cp] => TypeHasDoc (ContractRef cp) where
typeDocName :: Proxy (ContractRef cp) -> Text
typeDocName _ = "Contract"
typeDocMdReference :: Proxy (ContractRef cp) -> WithinParens -> Markdown
typeDocMdReference = Proxy (ContractRef cp) -> WithinParens -> Markdown
forall (t :: * -> *) r a.
(r ~ t a, Typeable t, Each '[TypeHasDoc] '[r, a],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly1TypeDocMdReference
typeDocMdDescription :: Markdown
typeDocMdDescription = "Contract primitive with given type of parameter."
typeDocDependencies :: Proxy (ContractRef cp) -> [SomeTypeWithDoc]
typeDocDependencies _ = [Proxy cp -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy cp
forall k (t :: k). Proxy t
Proxy @cp)]
typeDocHaskellRep :: TypeDocHaskellRep (ContractRef cp)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (ContractRef cp)
typeDocMichelsonRep = forall b.
(Typeable (ContractRef Integer), SingI (ToT (ContractRef Integer)),
HaveCommonTypeCtor b (ContractRef Integer)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(ContractRef Integer)
instance (PolyCTypeHasDocC '[k], PolyTypeHasDocC '[v], Ord k) =>
TypeHasDoc (Map k v) where
typeDocName :: Proxy (Map k v) -> Text
typeDocName _ = "Map"
typeDocMdReference :: Proxy (Map k v) -> WithinParens -> Markdown
typeDocMdReference = Proxy (Map k v) -> WithinParens -> Markdown
forall (t :: * -> * -> *) r a b.
(r ~ t a b, Typeable t, Each '[TypeHasDoc] '[r, a, b],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly2TypeDocMdReference
typeDocMdDescription :: Markdown
typeDocMdDescription = "Map primitive."
typeDocDependencies :: Proxy (Map k v) -> [SomeTypeWithDoc]
typeDocDependencies _ = [Proxy k -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy k
forall k (t :: k). Proxy t
Proxy @k), Proxy v -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy v
forall k (t :: k). Proxy t
Proxy @v)]
typeDocHaskellRep :: TypeDocHaskellRep (Map k v)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (Map k v)
typeDocMichelsonRep = forall b.
(Typeable (Map Integer Natural), SingI (ToT (Map Integer Natural)),
HaveCommonTypeCtor b (Map Integer Natural)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(Map Integer Natural)
instance (PolyCTypeHasDocC '[k], PolyTypeHasDocC '[v], Ord k) =>
TypeHasDoc (BigMap k v) where
typeDocName :: Proxy (BigMap k v) -> Text
typeDocName _ = "BigMap"
typeDocMdReference :: Proxy (BigMap k v) -> WithinParens -> Markdown
typeDocMdReference = Proxy (BigMap k v) -> WithinParens -> Markdown
forall (t :: * -> * -> *) r a b.
(r ~ t a b, Typeable t, Each '[TypeHasDoc] '[r, a, b],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly2TypeDocMdReference
typeDocMdDescription :: Markdown
typeDocMdDescription = "BigMap primitive."
typeDocDependencies :: Proxy (BigMap k v) -> [SomeTypeWithDoc]
typeDocDependencies _ = [Proxy k -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy k
forall k (t :: k). Proxy t
Proxy @k), Proxy v -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy v
forall k (t :: k). Proxy t
Proxy @v)]
typeDocHaskellRep :: TypeDocHaskellRep (BigMap k v)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (BigMap k v)
typeDocMichelsonRep = forall b.
(Typeable (BigMap Integer Natural),
SingI (ToT (BigMap Integer Natural)),
HaveCommonTypeCtor b (BigMap Integer Natural)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(BigMap Integer Natural)
tupleTypeDocReference :: [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference :: [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference vs :: [Markdown]
vs _ = "(" Markdown -> Markdown -> Markdown
forall b. FromBuilder b => Markdown -> Markdown -> b
+| [Markdown] -> Markdown
forall a. Monoid a => [a] -> a
mconcat (Markdown -> [Markdown] -> [Markdown]
forall a. a -> [a] -> [a]
intersperse ", " ([Markdown] -> [Markdown]) -> [Markdown] -> [Markdown]
forall a b. (a -> b) -> a -> b
$ (Markdown -> Markdown) -> [Markdown] -> [Markdown]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map Markdown -> Markdown
forall p. Buildable p => p -> Markdown
build [Markdown]
vs) Markdown -> Markdown -> Markdown
forall a b. (Buildable a, FromBuilder b) => a -> Markdown -> b
|+ ")"
instance PolyTypeHasDocC [a, b, c] => TypeHasDoc (a, b, c) where
typeDocName :: Proxy (a, b, c) -> Text
typeDocName _ = "(a, b, c)"
typeDocMdReference :: Proxy (a, b, c) -> WithinParens -> Markdown
typeDocMdReference _ = [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference
[ Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy a
forall k (t :: k). Proxy t
Proxy @a) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy b -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy b
forall k (t :: k). Proxy t
Proxy @b) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy c -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy c
forall k (t :: k). Proxy t
Proxy @c) (Bool -> WithinParens
WithinParens Bool
False)
]
typeDocMdDescription :: Markdown
typeDocMdDescription = "Tuple of size 3."
typeDocHaskellRep :: TypeDocHaskellRep (a, b, c)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (a, b, c)
typeDocMichelsonRep = forall b.
(Typeable (Integer, Natural, MText),
SingI (ToT (Integer, Natural, MText)),
HaveCommonTypeCtor b (Integer, Natural, MText)) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(Integer, Natural, MText)
instance PolyTypeHasDocC [a, b, c, d] => TypeHasDoc (a, b, c, d) where
typeDocName :: Proxy (a, b, c, d) -> Text
typeDocName _ = "(a, b, c, d)"
typeDocMdReference :: Proxy (a, b, c, d) -> WithinParens -> Markdown
typeDocMdReference _ = [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference
[ Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy a
forall k (t :: k). Proxy t
Proxy @a) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy b -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy b
forall k (t :: k). Proxy t
Proxy @b) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy c -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy c
forall k (t :: k). Proxy t
Proxy @c) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy d -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy d
forall k (t :: k). Proxy t
Proxy @d) (Bool -> WithinParens
WithinParens Bool
False)
]
typeDocMdDescription :: Markdown
typeDocMdDescription = "Tuple of size 4."
typeDocHaskellRep :: TypeDocHaskellRep (a, b, c, d)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (a, b, c, d)
typeDocMichelsonRep =
forall b.
(Typeable ((), (), (), ()), SingI (ToT ((), (), (), ())),
HaveCommonTypeCtor b ((), (), (), ())) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @((), (), (), ())
instance PolyTypeHasDocC [a, b, c, d, e] => TypeHasDoc (a, b, c, d, e) where
typeDocName :: Proxy (a, b, c, d, e) -> Text
typeDocName _ = "(a, b, c, d, e)"
typeDocMdDescription :: Markdown
typeDocMdDescription = "Tuple of size 5."
typeDocMdReference :: Proxy (a, b, c, d, e) -> WithinParens -> Markdown
typeDocMdReference _ = [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference
[ Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy a
forall k (t :: k). Proxy t
Proxy @a) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy b -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy b
forall k (t :: k). Proxy t
Proxy @b) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy c -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy c
forall k (t :: k). Proxy t
Proxy @c) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy d -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy d
forall k (t :: k). Proxy t
Proxy @d) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy e -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy e
forall k (t :: k). Proxy t
Proxy @e) (Bool -> WithinParens
WithinParens Bool
False)
]
typeDocHaskellRep :: TypeDocHaskellRep (a, b, c, d, e)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (a, b, c, d, e)
typeDocMichelsonRep =
forall b.
(Typeable ((), (), (), (), ()), SingI (ToT ((), (), (), (), ())),
HaveCommonTypeCtor b ((), (), (), (), ())) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @((), (), (), (), ())
instance PolyTypeHasDocC [a, b, c, d, e, f] => TypeHasDoc (a, b, c, d, e, f) where
typeDocName :: Proxy (a, b, c, d, e, f) -> Text
typeDocName _ = "(a, b, c, d, e, f)"
typeDocMdReference :: Proxy (a, b, c, d, e, f) -> WithinParens -> Markdown
typeDocMdReference _ = [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference
[ Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy a
forall k (t :: k). Proxy t
Proxy @a) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy b -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy b
forall k (t :: k). Proxy t
Proxy @b) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy c -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy c
forall k (t :: k). Proxy t
Proxy @c) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy d -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy d
forall k (t :: k). Proxy t
Proxy @d) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy e -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy e
forall k (t :: k). Proxy t
Proxy @e) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy f -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy f
forall k (t :: k). Proxy t
Proxy @f) (Bool -> WithinParens
WithinParens Bool
False)
]
typeDocMdDescription :: Markdown
typeDocMdDescription = "Tuple of size 6."
typeDocHaskellRep :: TypeDocHaskellRep (a, b, c, d, e, f)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (a, b, c, d, e, f)
typeDocMichelsonRep =
forall b.
(Typeable ((), (), (), (), (), ()),
SingI (ToT ((), (), (), (), (), ())),
HaveCommonTypeCtor b ((), (), (), (), (), ())) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @((), (), (), (), (), ())
instance PolyTypeHasDocC [a, b, c, d, e, f, g] => TypeHasDoc (a, b, c, d, e, f, g) where
typeDocName :: Proxy (a, b, c, d, e, f, g) -> Text
typeDocName _ = "(a, b, c, d, e, f, g)"
typeDocMdReference :: Proxy (a, b, c, d, e, f, g) -> WithinParens -> Markdown
typeDocMdReference _ = [Markdown] -> WithinParens -> Markdown
tupleTypeDocReference
[ Proxy a -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy a
forall k (t :: k). Proxy t
Proxy @a) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy b -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy b
forall k (t :: k). Proxy t
Proxy @b) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy c -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy c
forall k (t :: k). Proxy t
Proxy @c) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy d -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy d
forall k (t :: k). Proxy t
Proxy @d) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy e -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy e
forall k (t :: k). Proxy t
Proxy @e) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy f -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy f
forall k (t :: k). Proxy t
Proxy @f) (Bool -> WithinParens
WithinParens Bool
False)
, Proxy g -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy g
forall k (t :: k). Proxy t
Proxy @g) (Bool -> WithinParens
WithinParens Bool
False)
]
typeDocMdDescription :: Markdown
typeDocMdDescription = "Tuple of size 7."
typeDocHaskellRep :: TypeDocHaskellRep (a, b, c, d, e, f, g)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (a, b, c, d, e, f, g)
typeDocMichelsonRep =
forall b.
(Typeable ((), (), (), (), (), (), ()),
SingI (ToT ((), (), (), (), (), (), ())),
HaveCommonTypeCtor b ((), (), (), (), (), (), ())) =>
TypeDocMichelsonRep b
forall k a (b :: k).
(Typeable a, SingI (ToT a), HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @((), (), (), (), (), (), ())
instance ( TypeHasDoc (ApplyNamedFunctor f a)
, KnownSymbol n
, SingI (ToT (ApplyNamedFunctor f Integer))
, Typeable f, Typeable a
) =>
TypeHasDoc (NamedF f a n) where
typeDocName :: Proxy (NamedF f a n) -> Text
typeDocName _ = "Named entry"
typeDocMdReference :: Proxy (NamedF f a n) -> WithinParens -> Markdown
typeDocMdReference _ wp :: WithinParens
wp =
WithinParens -> Markdown -> Markdown
applyWithinParens WithinParens
wp (Markdown -> Markdown) -> Markdown -> Markdown
forall a b. (a -> b) -> a -> b
$
Text -> Markdown
buildFieldName (String -> Text
forall a. ToText a => a -> Text
toText (Proxy n -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy n -> String) -> Proxy n -> String
forall a b. (a -> b) -> a -> b
$ Proxy n
forall k (t :: k). Proxy t
Proxy @n)) Markdown -> Markdown -> Markdown
forall b. FromBuilder b => Markdown -> Markdown -> b
+| " " Markdown -> Markdown -> Markdown
forall b. FromBuilder b => Markdown -> Markdown -> b
+|
Proxy (ApplyNamedFunctor f a) -> WithinParens -> Markdown
forall a. TypeHasDoc a => Proxy a -> WithinParens -> Markdown
typeDocMdReference (Proxy (ApplyNamedFunctor f a)
forall k (t :: k). Proxy t
Proxy @(ApplyNamedFunctor f a)) (Bool -> WithinParens
WithinParens Bool
False) Markdown -> Markdown -> Markdown
forall a b. (Buildable a, FromBuilder b) => a -> Markdown -> b
|+ ""
typeDocDependencies :: Proxy (NamedF f a n) -> [SomeTypeWithDoc]
typeDocDependencies _ =
[Proxy (ApplyNamedFunctor f a) -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy (ApplyNamedFunctor f a)
forall k (t :: k). Proxy t
Proxy @(ApplyNamedFunctor f a)), Proxy Integer -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy Integer
forall k (t :: k). Proxy t
Proxy @Integer)]
typeDocHaskellRep :: TypeDocHaskellRep (NamedF f a n)
typeDocHaskellRep _ = Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. Maybe a
Nothing
typeDocMichelsonRep :: TypeDocMichelsonRep (NamedF f a n)
typeDocMichelsonRep _ = (DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a. a -> Maybe a
Just "number: Integer", (SingKind T, SingI (ToT (ApplyNamedFunctor f Integer))) => Demote T
forall k (a :: k). (SingKind k, SingI a) => Demote k
demote @(ToT (ApplyNamedFunctor f Integer)))
typeDocMdDescription :: Markdown
typeDocMdDescription =
"Some entries have names for clarity.\n\n\
\In resulting Michelson names may be mapped to annotations."