-- SPDX-FileCopyrightText: 2022 Oxhead Alpha
-- SPDX-License-Identifier: LicenseRef-MIT-OA

-- | This module contains a type family for converting a type to its RPC representation,
-- and TemplateHaskell functions for deriving RPC representations for custom types.
module Morley.AsRPC
  ( TAsRPC
  , HasRPCRepr(..)
  , MaybeRPC(..)
  , deriveRPC
  , deriveRPCWithStrategy
  , deriveManyRPC
  , deriveManyRPCWithStrategy
  -- * Conversions
  , valueAsRPC
  , replaceBigMapIds
  , notesAsRPC
  -- * Entailments
  , rpcSingIEvi
  , rpcHasNoOpEvi
  , rpcHasNoBigMapEvi
  , rpcHasNoNestedBigMapsEvi
  , rpcHasNoContractEvi
  , rpcStorageScopeEvi
  ) where

import Prelude hiding (Type)
import Prelude qualified

import Control.Lens.Plated (universe)
import Data.Constraint (Dict(..), (***), (:-)(Sub), (\\))
import Data.List qualified as List ((\\))
import Data.Singletons (Sing, withSingI)
import GHC.Generics qualified as G
import Language.Haskell.TH
  (Con(InfixC, NormalC, RecC), Cxt, Dec(DataD, NewtypeD, TySynD, TySynInstD),
  DerivStrategy(AnyclassStrategy), Info(TyConI), Kind, Loc(loc_module), Name, Q, TyLit(StrTyLit),
  TySynEqn(..), TyVarBndr, Type(..), cxt, instanceD, location, mkName, nameBase, ppr, reify,
  reifyInstances, standaloneDerivWithStrategyD)
import Language.Haskell.TH.ReifyMany (reifyManyTyCons)
import Language.Haskell.TH.ReifyMany.Internal (decConcreteNames)

import Morley.Micheline (ToExpression(..))
import Morley.Michelson.Text (MText)
import Morley.Michelson.Typed
  (BigMap, BigMapId, ContractPresence(ContractAbsent), ContractRef, EpAddress, HasNoBigMap,
  HasNoContract, HasNoNestedBigMaps, HasNoOp, IsoValue, Notes(..), OpPresence(..), Operation,
  SingI(sing), SingT(..), StorageScope, T(..), ToT, Value, Value'(..), WellTyped,
  checkContractTypePresence, checkOpPresence, toVal, withDict)
import Morley.Tezos.Address (Address)
import Morley.Tezos.Core (ChainId, Mutez, Timestamp)
import Morley.Tezos.Crypto
import Morley.Util.CustomGeneric
  (GenericStrategy, customGeneric', deriveFullType, haskellBalanced, reifyDataType)
import Morley.Util.Named hiding (Name)
import Morley.Util.TH (isTypeAlias, lookupTypeNameOrFail)

{-# ANN module ("HLint: ignore Avoid lambda using `infix`" :: Text) #-}

-- $setup
-- >>> import Morley.Michelson.Typed (T(..), BigMap, mkBigMap)
-- >>> import Morley.Michelson.Typed.Haskell.Value (BigMapId(..))
-- >>> import Morley.Michelson.Text (MText)

----------------------------------------------------------------------------
-- TAsRPC
----------------------------------------------------------------------------

{- | A type-level function that maps a Michelson type to its Tezos RPC representation.

For example, when we retrieve a contract's storage using the Tezos RPC,
all its @big_map@s will be replaced by @nat@, representing a big_map ID.

>>> :k! TAsRPC ('TBigMap 'TInt 'TString)
...
= 'TNat

>>> :k! TAsRPC ('TList ('TBigMap 'TInt 'TString))
...
= 'TList 'TNat

>>> :k! TAsRPC ('TPair 'TString ('TPair 'TAddress ('TBigMap 'TInt 'TString)))
...
= 'TPair 'TString ('TPair 'TAddress 'TNat)


NB: As far as we are aware, details of RPC representation of Michelson
types are not documented. We know empirically that @big_map@s are
represented as their ids, and are the only type with an explicitly
different representation.

Whether @TAsRPC@ needs to propagate into type parameters then depends on
whether a value can hold big_map values.

* Values of type @option a@, @list a@, @pair a b@, and @or a b@ can
  contain big_map values, so their RPC representations are @option (TAsRPC a)@,
  @list (TAsRPC a)@, @pair (TAsRPC a) (TAsRPC b)@ and @or (TAsRPC a) (TAsRPC b)@.
* The keys of a @map k v@ cannot be big_maps, but the values can, so its
  RPC representation is @map k (TAsRPC v)@.
* Values of type @set a@ cannot contain big_maps, so its RPC
  representation is just @set a@.
* Values of type @contract a@ cannot contain big_maps either, because
  it's just a wrapper for an address and an entrypoint name, so its RPC
  representation is just @contract a@. The same reasoning applies to
  @ticket a@ and @lambda a b@.

-}
type TAsRPC :: T -> T
type family TAsRPC t where
  TAsRPC 'TKey = 'TKey
  TAsRPC 'TUnit = 'TUnit
  TAsRPC 'TSignature = 'TSignature
  TAsRPC 'TChainId = 'TChainId
  TAsRPC ('TOption t) = 'TOption (TAsRPC t)
  TAsRPC ('TList t) = 'TList (TAsRPC t)
  TAsRPC ('TSet t) = 'TSet t
  TAsRPC 'TOperation = 'TOperation
  TAsRPC ('TContract t) = 'TContract t
  TAsRPC ('TTicket t) = 'TTicket t
  TAsRPC ('TPair t1 t2) = 'TPair (TAsRPC t1) (TAsRPC t2)
  TAsRPC ('TOr t1 t2) = 'TOr (TAsRPC t1) (TAsRPC t2)
  TAsRPC ('TLambda t1 t2) = 'TLambda t1 t2
  TAsRPC ('TMap k v) = 'TMap k (TAsRPC v)
  TAsRPC ('TBigMap _ _) = 'TNat
  TAsRPC 'TInt = 'TInt
  TAsRPC 'TNat = 'TNat
  TAsRPC 'TString = 'TString
  TAsRPC 'TBytes = 'TBytes
  TAsRPC 'TMutez = 'TMutez
  TAsRPC 'TBool = 'TBool
  TAsRPC 'TKeyHash = 'TKeyHash
  TAsRPC 'TTimestamp = 'TTimestamp
  TAsRPC 'TAddress = 'TAddress
  TAsRPC 'TNever = 'TNever
  TAsRPC 'TBls12381Fr = 'TBls12381Fr
  TAsRPC 'TBls12381G1 = 'TBls12381G1
  TAsRPC 'TBls12381G2 = 'TBls12381G2
  TAsRPC 'TChest = 'TChest
  TAsRPC 'TChestKey = 'TChestKey
  TAsRPC ('TSaplingState n) = ('TSaplingState n)
  TAsRPC ('TSaplingTransaction n) = ('TSaplingTransaction n)

----------------------------------------------------------------------------
-- AsRPC
----------------------------------------------------------------------------

{- | A type-level function that maps a type to its Tezos RPC representation.

For example, when we retrieve a contract's storage using the Tezos RPC, all its 'BigMap's will be replaced
by 'BigMapId's.

So if a contract has a storage of type @T@, when we call the Tezos RPC
to retrieve it, we must deserialize the micheline expression to the type @AsRPC T@.

> AsRPC (BigMap Integer MText) ~ BigMapId Integer MText
> AsRPC [BigMap Integer MText] ~ [BigMapId Integer MText]
> AsRPC (MText, (Address, BigMap Integer MText)) ~ (MText, (Address, BigMapId Integer MText))

The following law must hold:

> TAsRPC (ToT t) ~ ToT (AsRPC t)

In other words, `ToT` and `AsRPC`/`TAsRPC` must be commutative.

@
   Storage ----------(applying ToT)-------------> ToT Storage
      |                                                |
      |                                                |
      |                                                |
(applying AsRPC)                                (applying TAsRPC)
      |                                                |
      |                                                |
      |                                                |
      |                                                V
      |                                        TAsRPC (ToT Storage)
      V                                                ~
AsRPC Storage ------(applying ToT)-----------> ToT (AsRPC Storage)
@


This law ensures that we can go from some type @Storage@ to @AsRPC Storage@ by
composing @fromVal . valueAsRPC . toVal@.

@
   Storage ------------(toVal)--------------> Value (ToT Storage)
      |                                                |
      |                                                |
      |                                                |
(fromVal . valueAsRPC . toVal)                    (valueAsRPC)
      |                                                |
      |                                                |
      |                                                |
      |                                                V
      |                                   Value (TAsRPC (ToT Storage))
      V                                                ~
AsRPC Storage <--------(fromVal)--------- Value (ToT (AsRPC Storage))
@

-}
class (TAsRPC (ToT t) ~ ToT (AsRPC t)) => HasRPCRepr (t :: Prelude.Type) where
  type AsRPC t :: Prelude.Type

-- Morley types

-- Note: We don't recursively apply @AsRPC@ to @k@ or @v@ because
-- bigmaps cannot contain nested bigmaps.
-- If this constraint is ever lifted, we'll have to change this instance
-- to @BigMapId k (AsRPC v)@
instance HasRPCRepr (BigMap k v) where type AsRPC (BigMap k v) = BigMapId k v
instance HasRPCRepr (Value t) where type AsRPC (Value t) = Value (TAsRPC t)
instance HasRPCRepr Integer where type AsRPC Integer = Integer
instance HasRPCRepr Natural where type AsRPC Natural = Natural
instance HasRPCRepr MText where type AsRPC MText = MText
instance HasRPCRepr Bool where type AsRPC Bool = Bool
instance HasRPCRepr ByteString where type AsRPC ByteString = ByteString
instance HasRPCRepr Mutez where type AsRPC Mutez = Mutez
instance HasRPCRepr KeyHash where type AsRPC KeyHash = KeyHash
instance HasRPCRepr Timestamp where type AsRPC Timestamp = Timestamp
instance HasRPCRepr Address where type AsRPC Address = Address
instance HasRPCRepr EpAddress where type AsRPC EpAddress = EpAddress
instance HasRPCRepr PublicKey where type AsRPC PublicKey = PublicKey
instance HasRPCRepr Signature where type AsRPC Signature = Signature
instance HasRPCRepr ChainId where type AsRPC ChainId = ChainId
instance HasRPCRepr Bls12381Fr where type AsRPC Bls12381Fr = Bls12381Fr
instance HasRPCRepr Bls12381G1 where type AsRPC Bls12381G1 = Bls12381G1
instance HasRPCRepr Bls12381G2 where type AsRPC Bls12381G2 = Bls12381G2
instance HasRPCRepr () where type AsRPC () = ()
instance HasRPCRepr a => HasRPCRepr [a] where
  type AsRPC [a] = [AsRPC a]
instance HasRPCRepr a => HasRPCRepr (Maybe a) where
  type AsRPC (Maybe a) = Maybe (AsRPC a)
instance (HasRPCRepr l, HasRPCRepr r) => HasRPCRepr (Either l r) where
  type AsRPC (Either l r) = Either (AsRPC l) (AsRPC r)
instance (HasRPCRepr a, HasRPCRepr b) => HasRPCRepr (a, b) where
  type AsRPC (a, b) = (AsRPC a, AsRPC b)
instance HasRPCRepr (Set a) where
  type AsRPC (Set a) = Set a
instance HasRPCRepr v => HasRPCRepr (Map k v) where
  type AsRPC (Map k v) = Map k (AsRPC v)
instance HasRPCRepr Operation where
  type AsRPC Operation = Operation
instance HasRPCRepr a => HasRPCRepr (Identity a) where
  type AsRPC (Identity a) = Identity (AsRPC a)
instance HasRPCRepr a => HasRPCRepr (NamedF Identity a name) where
  type AsRPC (NamedF Identity a name) = NamedF Identity (AsRPC a) name
instance HasRPCRepr a => HasRPCRepr (NamedF Maybe a name) where
  type AsRPC (NamedF Maybe a name) = NamedF Maybe (AsRPC a) name
instance Each '[HasRPCRepr] '[a, b, c] => HasRPCRepr (a, b, c) where
  type AsRPC (a, b, c) = (AsRPC a, AsRPC b, AsRPC c)
instance Each '[HasRPCRepr] '[a, b, c, d] => HasRPCRepr (a, b, c, d) where
  type AsRPC (a, b, c, d) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d)
instance Each '[HasRPCRepr] '[a, b, c, d, e] => HasRPCRepr (a, b, c, d, e) where
  type AsRPC (a, b, c, d, e) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d, AsRPC e)
instance Each '[HasRPCRepr] '[a, b, c, d, e, f] => HasRPCRepr (a, b, c, d, e, f) where
  type AsRPC (a, b, c, d, e, f) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d, AsRPC e, AsRPC f)
instance Each '[HasRPCRepr] '[a, b, c, d, e, f, g] => HasRPCRepr (a, b, c, d, e, f, g) where
  type AsRPC (a, b, c, d, e, f, g) = (AsRPC a, AsRPC b, AsRPC c, AsRPC d, AsRPC e, AsRPC f, AsRPC g)
instance HasRPCRepr (ContractRef arg) where
  type AsRPC (ContractRef arg) = ContractRef arg
instance HasRPCRepr Chest where
  type AsRPC Chest = Chest
instance HasRPCRepr ChestKey where
  type AsRPC ChestKey = ChestKey

----------------------------------------------------------------------------
-- MaybeRPC
----------------------------------------------------------------------------

-- | Represents a value that may or may not be in its RPC representation.
--
-- >>> :t NotRPC @(BigMap Integer MText) (mkBigMap @[(Integer, MText)] [])
-- ...
--   :: MaybeRPC (BigMap Integer MText)
--
-- >>> :t IsRPC @(BigMap Integer MText) (BigMapId 1)
-- ...
--   :: MaybeRPC (BigMap Integer MText)
data MaybeRPC v where
  NotRPC :: IsoValue  v => v -> MaybeRPC v
  IsRPC :: (SingI (ToT v), IsoValue (AsRPC v), HasRPCRepr v) => AsRPC v -> MaybeRPC v

instance HasNoOp (ToT v) => ToExpression (MaybeRPC v) where
  toExpression :: MaybeRPC v -> Expression
toExpression = \case
    NotRPC v
v -> Value (ToT v) -> Expression
forall a. ToExpression a => a -> Expression
toExpression (v -> Value (ToT v)
forall a. IsoValue a => a -> Value (ToT a)
toVal v
v)
    IsRPC AsRPC v
v -> (HasNoOp (ToT v) :- HasNoOp (ToT (AsRPC v)))
-> (HasNoOp (ToT (AsRPC v)) => Expression) -> Expression
forall (c :: Constraint) e r. HasDict c e => e -> (c => r) -> r
withDict ((SingI (ToT v), HasNoOp (ToT v)) =>
HasNoOp (ToT v) :- HasNoOp (TAsRPC (ToT v))
forall (t :: T).
(SingI t, HasNoOp t) =>
HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi @(ToT v)) ((HasNoOp (ToT (AsRPC v)) => Expression) -> Expression)
-> (HasNoOp (ToT (AsRPC v)) => Expression) -> Expression
forall a b. (a -> b) -> a -> b
$ Value (ToT (AsRPC v)) -> Expression
forall a. ToExpression a => a -> Expression
toExpression (AsRPC v -> Value (ToT (AsRPC v))
forall a. IsoValue a => a -> Value (ToT a)
toVal AsRPC v
v)

----------------------------------------------------------------------------
-- Derive RPC repr
----------------------------------------------------------------------------

-- | Derive an RPC representation for a type, as well as instances for 'Generic', 'IsoValue' and 'HasRPCRepr'.
--
-- > data ExampleStorage a b = ExampleStorage
-- >   { esField1 :: Integer
-- >   , esField2 :: [BigMap Integer MText]
-- >   , esField3 :: a
-- >   }
-- >   deriving stock Generic
-- >   deriving anyclass IsoValue
-- >
-- > deriveRPC "ExampleStorage"
--
-- Will generate:
--
-- > data ExampleStorageRPC a b = ExampleStorageRPC
-- >   { esField1RPC :: AsRPC Integer
-- >   , esField2RPC :: AsRPC [BigMap Integer MText]
-- >   , esField3RPC :: AsRPC a
-- >   }
-- >
-- > instance HasRPCRepr a => HasRPCRepr (ExampleStorage a b) where
-- >   type AsRPC (ExampleStorage a b) = ExampleStorageRPC a b
-- > deriving anyclass instance (IsoValue (AsRPC a), IsoValue (AsRPC b)) => IsoValue (ExampleStorageRPC a b)
-- > instance Generic (ExampleStorageRPC a b) where
-- >   ...
deriveRPC :: String -> Q [Dec]
deriveRPC :: String -> Q [Dec]
deriveRPC String
typeStr = String -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy String
typeStr GenericStrategy
haskellBalanced

-- | Recursively enumerate @data@, @newtype@ and @type@ declarations,
-- and derives an RPC representation for each type that doesn't yet have one.
--
-- You can also pass in a list of types for which you _don't_ want
-- an RPC representation to be derived.
--
-- In this example, 'deriveManyRPC' will generate an RPC
-- representation for @A@ and @B@,
-- but not for @C@ (because we explicitly said we don't want one)
-- or @D@ (because it already has one).
--
-- > data B = B
-- > data C = C
-- > data D = D
-- > deriveRPC "D"
-- >
-- > data A = A B C D
-- > deriveManyRPC "A" ["C"]
deriveManyRPC :: String -> [String] -> Q [Dec]
deriveManyRPC :: String -> [String] -> Q [Dec]
deriveManyRPC String
typeStr [String]
skipTypes =
  String -> [String] -> GenericStrategy -> Q [Dec]
deriveManyRPCWithStrategy String
typeStr [String]
skipTypes GenericStrategy
haskellBalanced

-- | Same as 'deriveManyRPC', but uses a custom strategy for deriving a 'Generic' instance.
deriveManyRPCWithStrategy :: String -> [String] -> GenericStrategy -> Q [Dec]
deriveManyRPCWithStrategy :: String -> [String] -> GenericStrategy -> Q [Dec]
deriveManyRPCWithStrategy String
typeStr [String]
skipTypes GenericStrategy
gs = do
  [Name]
skipTypeNames <- (String -> Q Name) -> [String] -> Q [Name]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse String -> Q Name
lookupTypeNameOrFail [String]
skipTypes
  Name
typeName <- String -> Q Name
lookupTypeNameOrFail String
typeStr
  Q Bool -> Q () -> Q ()
forall (m :: * -> *). Monad m => m Bool -> m () -> m ()
whenM (Name -> Q Bool
isTypeAlias Name
typeName) (Q () -> Q ()) -> Q () -> Q ()
forall a b. (a -> b) -> a -> b
$ String -> Q ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q ()) -> String -> Q ()
forall a b. (a -> b) -> a -> b
$ String
typeStr String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" is a 'type' alias but not 'data' or 'newtype'."
  [Name]
allTypeNames <- Name -> Q [Name]
findWithoutInstance Name
typeName
  [[Dec]] -> [Dec]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join ([[Dec]] -> [Dec]) -> Q [[Dec]] -> Q [Dec]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Name] -> (Name -> Q [Dec]) -> Q [[Dec]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM ([Name]
allTypeNames [Name] -> [Name] -> [Name]
forall a. Eq a => [a] -> [a] -> [a]
List.\\ [Name]
skipTypeNames) \Name
name -> Name -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy' Name
name GenericStrategy
gs
  where

    -- | Recursively enumerate @data@, @newtype@ and @type@ declarations,
    -- and returns the names of only @data@ and @newtype@ of those that
    -- don't yet have an 'AsRPC' instance. Type aliases don't need instances
    -- and respectively there is no need to derive 'AsRPC' for them.
    findWithoutInstance :: Name -> Q [Name]
    findWithoutInstance :: Name -> Q [Name]
findWithoutInstance Name
typeName =
      ((Name, Info) -> Name) -> [(Name, Info)] -> [Name]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Name, Info) -> Name
forall a b. (a, b) -> a
fst ([(Name, Info)] -> [Name]) -> Q [(Name, Info)] -> Q [Name]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        ((Name, Dec) -> Q (Bool, [Name])) -> [Name] -> Q [(Name, Info)]
reifyManyTyCons
          (\(Name
name, Dec
dec) ->
            Q Bool -> Q (Bool, [Name]) -> Q (Bool, [Name]) -> Q (Bool, [Name])
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (Name -> Q Bool
isTypeAlias Name
name)
              ((Bool, [Name]) -> Q (Bool, [Name])
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
False, Dec -> [Name]
decConcreteNames Dec
dec))
              (Q Bool -> Q (Bool, [Name]) -> Q (Bool, [Name]) -> Q (Bool, [Name])
forall (m :: * -> *) a. Monad m => m Bool -> m a -> m a -> m a
ifM (Name -> Q Bool
hasRPCInstance Name
name)
                ((Bool, [Name]) -> Q (Bool, [Name])
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
False, []))
                ((Bool, [Name]) -> Q (Bool, [Name])
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool
True, Dec -> [Name]
decConcreteNames Dec
dec)))
          )
          [Name
typeName]

    hasRPCInstance :: Name -> Q Bool
    hasRPCInstance :: Name -> Q Bool
hasRPCInstance Name
typeName = do
      Name -> Q (Maybe Type)
deriveFullTypeFromName Name
typeName Q (Maybe Type) -> (Maybe Type -> Q Bool) -> Q Bool
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
        Maybe Type
Nothing ->
          String -> Q Bool
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q Bool) -> String -> Q Bool
forall a b. (a -> b) -> a -> b
$ String
"Found a field with a type that is neither a 'data' nor a 'newtype' nor a 'type': "
            String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Name -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show Name
typeName
        Just Type
typ ->
          Bool -> Bool
not (Bool -> Bool) -> ([Dec] -> Bool) -> [Dec] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Dec] -> Bool
forall t. Container t => t -> Bool
null ([Dec] -> Bool) -> Q [Dec] -> Q Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> [Type] -> Q [Dec]
reifyInstances ''AsRPC [Type
typ]

    -- | Given a type name, return the corresponding type expression
    -- (applied to any type variables, if necessary).
    --
    -- For example, assuming a data type like @data F a b = ...@ exists in the type environment,
    -- then @deriveFullTypeFromName ''F@ will return the type expression @[t|F a b|]@.
    --
    -- Note that only @data@, @newtype@ and @type@ declarations are supported at the moment.
    deriveFullTypeFromName :: Name -> Q (Maybe Type)
    deriveFullTypeFromName :: Name -> Q (Maybe Type)
deriveFullTypeFromName Name
typeName = do
      Info
typeInfo <- Name -> Q Info
reify Name
typeName
      case Info
typeInfo of
        TyConI (DataD [Type]
_ Name
_ [TyVarBndr]
vars Maybe Type
mKind [Con]
_ [DerivClause]
_) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Maybe Type) -> Q Type -> Q (Maybe Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Maybe Type -> [TyVarBndr] -> Q Type
deriveFullType Name
typeName Maybe Type
mKind [TyVarBndr]
vars
        TyConI (NewtypeD [Type]
_ Name
_ [TyVarBndr]
vars Maybe Type
mKind Con
_ [DerivClause]
_) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Maybe Type) -> Q Type -> Q (Maybe Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Maybe Type -> [TyVarBndr] -> Q Type
deriveFullType Name
typeName Maybe Type
mKind [TyVarBndr]
vars
        TyConI (TySynD Name
_ [TyVarBndr]
vars Type
_) -> Type -> Maybe Type
forall a. a -> Maybe a
Just (Type -> Maybe Type) -> Q Type -> Q (Maybe Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> Maybe Type -> [TyVarBndr] -> Q Type
deriveFullType Name
typeName Maybe Type
forall a. Maybe a
Nothing [TyVarBndr]
vars
        Info
_ -> Maybe Type -> Q (Maybe Type)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Type
forall a. Maybe a
Nothing

-- | Same as 'deriveRPC', but uses a custom strategy for deriving a 'Generic' instance.
deriveRPCWithStrategy :: String -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy :: String -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy String
typeStr GenericStrategy
gs = do
  Name
typeName <- String -> Q Name
lookupTypeNameOrFail String
typeStr
  Q Bool -> Q () -> Q ()
forall (m :: * -> *). Monad m => m Bool -> m () -> m ()
whenM (Name -> Q Bool
isTypeAlias Name
typeName) (Q () -> Q ()) -> Q () -> Q ()
forall a b. (a -> b) -> a -> b
$ String -> Q ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q ()) -> String -> Q ()
forall a b. (a -> b) -> a -> b
$ String
typeStr String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" is a 'type' alias but not 'data' or 'newtype'."
  Name -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy' Name
typeName GenericStrategy
gs

deriveRPCWithStrategy' :: Name -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy' :: Name -> GenericStrategy -> Q [Dec]
deriveRPCWithStrategy' Name
typeName GenericStrategy
gs = do
  (Name
_, [Type]
decCxt, Maybe Type
mKind, [TyVarBndr]
tyVars, [Con]
constructors) <- Name -> Q (Name, [Type], Maybe Type, [TyVarBndr], [Con])
reifyDataType Name
typeName

  -- TODO [#722]: use `reifyInstances` to check that 'AsRPC' exists for `fieldType`
  -- Print user-friendly error msg if it doesn't.
  let typeNameRPC :: Name
typeNameRPC = Name -> Name
convertName Name
typeName
  [Con]
constructorsRPC <- (Con -> Q Con) -> [Con] -> Q [Con]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Con -> Q Con
convertConstructor [Con]
constructors
  [Type]
fieldTypes <- [Con] -> Q [Type]
getFieldTypes [Con]
constructors
  [Type]
fieldTypesRPC <- [Con] -> Q [Type]
getFieldTypes [Con]
constructorsRPC

  Type
derivedType <- Name -> Maybe Type -> [TyVarBndr] -> Q Type
deriveFullType Name
typeName Maybe Type
mKind [TyVarBndr]
tyVars
  Type
derivedTypeRPC <- Name -> Maybe Type -> [TyVarBndr] -> Q Type
deriveFullType Name
typeNameRPC Maybe Type
mKind [TyVarBndr]
tyVars

  -- Note: we can't use `makeRep0Inline` to derive a `Rep` instance for `derivedTypeRPC`
  -- It internally uses `reify` to lookup info about `derivedTypeRPC`, and because `derivedTypeRPC` hasn't
  -- been spliced *yet*, the lookup fails.
  -- So, instead, we fetch the `Rep` instance for `derivedType`, and
  -- append "RPC" to the type/constructor/field names in its metadata.
  --
  -- If, for some reason, we find out that this approach doesn't work for some edge cases,
  -- we should get rid of it and patch the @generic-deriving@ package to export a version of `makeRep0Inline`
  -- that doesn't use `reify` (it should be easy enough).
  TySynEqn
repInstance <- Name -> Type -> Q TySynEqn
reifyRepInstance Name
typeName Type
derivedType
  String
currentModuleName <- Loc -> String
loc_module (Loc -> String) -> Q Loc -> Q String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Q Loc
location
  let repTypeRPC :: Type
repTypeRPC = String -> TySynEqn -> Type
convertRep String
currentModuleName TySynEqn
repInstance
  Dec
typeDecOfRPC <- Name
-> [Type] -> Name -> [TyVarBndr] -> Maybe Type -> [Con] -> Q Dec
mkTypeDeclaration Name
typeName [Type]
decCxt Name
typeNameRPC [TyVarBndr]
tyVars Maybe Type
mKind [Con]
constructorsRPC

  [[Dec]] -> [Dec]
forall a. Monoid a => [a] -> a
mconcat ([[Dec]] -> [Dec]) -> Q [[Dec]] -> Q [Dec]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Q [Dec]] -> Q [[Dec]]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
    [ [Dec] -> Q [Dec]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Dec] -> Q [Dec]) -> (Dec -> [Dec]) -> Dec -> Q [Dec]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dec -> [Dec]
forall x. One x => OneItem x -> x
one (Dec -> Q [Dec]) -> Dec -> Q [Dec]
forall a b. (a -> b) -> a -> b
$ Dec
typeDecOfRPC
    , Dec -> [Dec]
forall x. One x => OneItem x -> x
one (Dec -> [Dec]) -> Q Dec -> Q [Dec]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Type] -> Type -> Type -> Q Dec
mkAsRPCInstance [Type]
fieldTypes Type
derivedType Type
derivedTypeRPC
    , [Type] -> Type -> Q [Dec]
mkIsoValueInstance [Type]
fieldTypesRPC Type
derivedTypeRPC
    , Maybe Type -> Name -> Type -> [Con] -> GenericStrategy -> Q [Dec]
customGeneric' (Type -> Maybe Type
forall a. a -> Maybe a
Just Type
repTypeRPC) Name
typeNameRPC Type
derivedTypeRPC [Con]
constructorsRPC GenericStrategy
gs
    ]

  where
    -- | Given the field type @FieldType a b@, returns @AsRPC (FieldType a b)@.
    convertFieldType :: Type -> Type
    convertFieldType :: Type -> Type
convertFieldType Type
tp = Name -> Type
ConT ''AsRPC Type -> Type -> Type
`AppT` Type
tp

    convertNameStr :: String -> String
    convertNameStr :: String -> String
convertNameStr String
s = String
s String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"RPC"

    convertName :: Name -> Name
    convertName :: Name -> Name
convertName = String -> Name
mkName (String -> Name) -> (Name -> String) -> Name -> Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
convertNameStr (String -> String) -> (Name -> String) -> Name -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> String
nameBase

    -- | Given the constructor
    -- @C { f :: Int }@,
    -- returns the constructor
    -- @CRPC { fRPC :: AsRPC Int }@.
    convertConstructor :: Con -> Q Con
    convertConstructor :: Con -> Q Con
convertConstructor = \case
      RecC Name
conName [VarBangType]
fields -> Con -> Q Con
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Con -> Q Con) -> Con -> Q Con
forall a b. (a -> b) -> a -> b
$
        Name -> [VarBangType] -> Con
RecC
          (Name -> Name
convertName Name
conName)
          ([VarBangType]
fields [VarBangType] -> (VarBangType -> VarBangType) -> [VarBangType]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
fieldName, Bang
fieldBang, Type
fieldType) ->
            (Name -> Name
convertName Name
fieldName, Bang
fieldBang, Type -> Type
convertFieldType Type
fieldType)
          )
      NormalC Name
conName [BangType]
fields -> Con -> Q Con
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Con -> Q Con) -> Con -> Q Con
forall a b. (a -> b) -> a -> b
$
        Name -> [BangType] -> Con
NormalC (Name -> Name
convertName Name
conName) ((Type -> Type) -> BangType -> BangType
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second Type -> Type
convertFieldType (BangType -> BangType) -> [BangType] -> [BangType]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [BangType]
fields)
      InfixC BangType
fieldType1 Name
conName BangType
fieldType2 -> Con -> Q Con
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Con -> Q Con) -> Con -> Q Con
forall a b. (a -> b) -> a -> b
$
        BangType -> Name -> BangType -> Con
InfixC ((Type -> Type) -> BangType -> BangType
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second Type -> Type
convertFieldType BangType
fieldType1) (Name -> Name
convertName Name
conName) ((Type -> Type) -> BangType -> BangType
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second Type -> Type
convertFieldType BangType
fieldType2)
      Con
constr -> String -> Q Con
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q Con) -> String -> Q Con
forall a b. (a -> b) -> a -> b
$ String
"Unsupported constructor for '" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Name -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show Name
typeName String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"': " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Doc -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show (Con -> Doc
forall a. Ppr a => a -> Doc
ppr Con
constr)

    -- | Get a list of all the unique types of all the fields of all the given constructors.
    getFieldTypes :: [Con] -> Q [Type]
    getFieldTypes :: [Con] -> Q [Type]
getFieldTypes [Con]
constrs = [Type] -> [Type]
forall a. Ord a => [a] -> [a]
ordNub ([Type] -> [Type]) -> ([[Type]] -> [Type]) -> [[Type]] -> [Type]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[Type]] -> [Type]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join ([[Type]] -> [Type]) -> Q [[Type]] -> Q [Type]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Con] -> (Con -> Q [Type]) -> Q [[Type]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [Con]
constrs \case
      RecC Name
_ [VarBangType]
fields -> [Type] -> Q [Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Type] -> Q [Type]) -> [Type] -> Q [Type]
forall a b. (a -> b) -> a -> b
$ [VarBangType]
fields [VarBangType] -> (VarBangType -> Type) -> [Type]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \(Name
_, Bang
_, Type
fieldType) -> Type
fieldType
      NormalC Name
_ [BangType]
fields -> [Type] -> Q [Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Type] -> Q [Type]) -> [Type] -> Q [Type]
forall a b. (a -> b) -> a -> b
$ BangType -> Type
forall a b. (a, b) -> b
snd (BangType -> Type) -> [BangType] -> [Type]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [BangType]
fields
      InfixC BangType
field1 Name
_ BangType
field2 -> [Type] -> Q [Type]
forall (f :: * -> *) a. Applicative f => a -> f a
pure [BangType -> Type
forall a b. (a, b) -> b
snd BangType
field1, BangType -> Type
forall a b. (a, b) -> b
snd BangType
field2]
      Con
constr -> String -> Q [Type]
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q [Type]) -> String -> Q [Type]
forall a b. (a -> b) -> a -> b
$ String
"Unsupported constructor for '" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Name -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show Name
typeName String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"': " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Doc -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show (Con -> Doc
forall a. Ppr a => a -> Doc
ppr Con
constr)

    mkTypeDeclaration :: Name -> Cxt -> Name -> [TyVarBndr] -> Maybe Kind -> [Con] -> Q Dec
    mkTypeDeclaration :: Name
-> [Type] -> Name -> [TyVarBndr] -> Maybe Type -> [Con] -> Q Dec
mkTypeDeclaration Name
tyName [Type]
decCxt Name
typeNameRPC [TyVarBndr]
tyVars Maybe Type
mKind [Con]
constructorsRPC = do
      Info
typeInfo <- Name -> Q Info
reify Name
tyName
      case Info
typeInfo of
        TyConI DataD {} -> Dec -> Q Dec
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dec -> Q Dec) -> Dec -> Q Dec
forall a b. (a -> b) -> a -> b
$ [Type]
-> Name
-> [TyVarBndr]
-> Maybe Type
-> [Con]
-> [DerivClause]
-> Dec
DataD [Type]
decCxt Name
typeNameRPC [TyVarBndr]
tyVars Maybe Type
mKind [Con]
constructorsRPC []
        TyConI NewtypeD {} -> (case [Con]
constructorsRPC of
          [Con
con] -> Dec -> Q Dec
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dec -> Q Dec) -> Dec -> Q Dec
forall a b. (a -> b) -> a -> b
$ [Type]
-> Name -> [TyVarBndr] -> Maybe Type -> Con -> [DerivClause] -> Dec
NewtypeD [Type]
decCxt Name
typeNameRPC [TyVarBndr]
tyVars Maybe Type
mKind Con
con []
          [Con]
_ -> String -> Q Dec
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Newtype has only one constructor")
        Info
_ -> String -> Q Dec
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q Dec) -> String -> Q Dec
forall a b. (a -> b) -> a -> b
$ String
"Only newtypes and data types are supported, but '" String -> String -> String
forall a. Semigroup a => a -> a -> a
<>
          Name -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show Name
tyName String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"' is:\n" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Doc -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show (Info -> Doc
forall a. Ppr a => a -> Doc
ppr Info
typeInfo)

    -- | Traverse a 'Rep' type and:
    --
    -- 1. Inspect its metadata and append @RPC@ to the type/constructor/field names.
    -- 2. Convert field types (e.g. @T@ becomes @AsRPC T@).
    -- 3. Replace the Rep's module name with the name of the module of where this Q is being spliced.
    convertRep :: String -> TySynEqn -> Type
    convertRep :: String -> TySynEqn -> Type
convertRep String
currentModuleName (TySynEqn Maybe [TyVarBndr]
_tyVars Type
_lhs Type
rhs) = Type -> Type
go Type
rhs
      where
        go :: Type -> Type
        go :: Type -> Type
go = \case
          -- Rename type name and module name
          PromotedT Name
t `AppT` LitT (StrTyLit String
tyName) `AppT` LitT (StrTyLit String
_moduleName)
            | Name
t Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
== 'G.MetaData
            -> Name -> Type
PromotedT Name
t Type -> Type -> Type
`AppT` TyLit -> Type
LitT (String -> TyLit
StrTyLit (String -> String
convertNameStr String
tyName)) Type -> Type -> Type
`AppT` TyLit -> Type
LitT (String -> TyLit
StrTyLit String
currentModuleName)
          -- Rename constructor names
          PromotedT Name
t `AppT` LitT (StrTyLit String
conName)
            | Name
t Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
== 'G.MetaCons
            -> Name -> Type
PromotedT Name
t Type -> Type -> Type
`AppT` TyLit -> Type
LitT (String -> TyLit
StrTyLit (String -> String
convertNameStr String
conName))
          -- Rename field names
          PromotedT Name
t `AppT` (PromotedT Name
just `AppT` LitT (StrTyLit String
fieldName))
            | Name
t Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
== 'G.MetaSel
            -> Name -> Type
PromotedT Name
t Type -> Type -> Type
`AppT` (Name -> Type
PromotedT Name
just Type -> Type -> Type
`AppT` TyLit -> Type
LitT (String -> TyLit
StrTyLit (String -> String
convertNameStr String
fieldName)))
          -- Replace field type @T@ with @AsRPC T@
          ConT Name
x `AppT` Type
fieldType
            | Name
x Name -> Name -> Bool
forall a. Eq a => a -> a -> Bool
== ''G.Rec0
            -> Name -> Type
ConT Name
x Type -> Type -> Type
`AppT` Type -> Type
convertFieldType Type
fieldType
          Type
x `AppT` Type
y -> Type -> Type
go Type
x Type -> Type -> Type
`AppT` Type -> Type
go Type
y
          Type
x -> Type
x

    -- | Lookup the generic 'Rep' type instance for the given type.
    reifyRepInstance :: Name -> Type -> Q TySynEqn
    reifyRepInstance :: Name -> Type -> Q TySynEqn
reifyRepInstance Name
name Type
tp =
      Name -> [Type] -> Q [Dec]
reifyInstances ''G.Rep [Type
tp] Q [Dec] -> ([Dec] -> Q TySynEqn) -> Q TySynEqn
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
        [TySynInstD TySynEqn
repInstance] -> TySynEqn -> Q TySynEqn
forall (f :: * -> *) a. Applicative f => a -> f a
pure TySynEqn
repInstance
        (Dec
_:[Dec]
_) -> String -> Q TySynEqn
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q TySynEqn) -> String -> Q TySynEqn
forall a b. (a -> b) -> a -> b
$ String
"Found multiple instances of 'Generic' for '" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Name -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show Name
name String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"'."
        [] -> String -> Q TySynEqn
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Q TySynEqn) -> String -> Q TySynEqn
forall a b. (a -> b) -> a -> b
$ String
"Type '" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Name -> String
forall b a. (PrettyShow a, Show a, IsString b) => a -> b
show Name
name String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"' must implement 'Generic'."

    -- | Given the type @Foo a b = Foo (Bar a)@, generate an 'IsoValue' instance like:
    --
    -- > deriving anyclass instance IsoValue (AsRPC (Bar a)) => IsoValue (FooRPC a b)
    --
    -- Note that if a type variable @t@ is a phantom type variable, then no @IsoValue (AsRPC t)@
    -- constraint is generated for it.
    mkIsoValueInstance :: [Type] -> Type -> Q [Dec]
    mkIsoValueInstance :: [Type] -> Type -> Q [Dec]
mkIsoValueInstance [Type]
fieldTypes Type
tp =
      Dec -> [Dec]
forall x. One x => OneItem x -> x
one (Dec -> [Dec]) -> Q Dec -> Q [Dec]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe DerivStrategy -> Q [Type] -> Q Type -> Q Dec
standaloneDerivWithStrategyD (DerivStrategy -> Maybe DerivStrategy
forall a. a -> Maybe a
Just DerivStrategy
AnyclassStrategy) Q [Type]
constraints [t|IsoValue $(pure tp)|]
      where
        constraints :: Q Cxt
        constraints :: Q [Type]
constraints =
          [Q Type] -> Q [Type]
cxt ([Q Type] -> Q [Type]) -> [Q Type] -> Q [Type]
forall a b. (a -> b) -> a -> b
$ (Type -> Bool) -> [Type] -> [Type]
forall a. (a -> Bool) -> [a] -> [a]
filter Type -> Bool
hasTyVar [Type]
fieldTypes [Type] -> (Type -> Q Type) -> [Q Type]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Type
fieldType ->
            [t|IsoValue $(pure fieldType)|]

    -- | Given the type @Foo a b = Foo (Bar a)@, generate an 'HasRPCRepr' instance like:
    --
    -- > instance HasRPCRepr (Bar a) => HasRPCRepr (Foo a b) where
    -- >   type AsRPC (Foo a b) = FooRPC a b
    --
    -- Note that if a type variable @t@ is a phantom type variable, then no @HasRPCRepr@
    -- constraint is generated for it.
    mkAsRPCInstance :: [Type] -> Type -> Type -> Q Dec
    mkAsRPCInstance :: [Type] -> Type -> Type -> Q Dec
mkAsRPCInstance [Type]
fieldTypes Type
tp Type
tpRPC = do
      [Dec]
typeInstance <- [d|type instance AsRPC $(pure tp) = $(pure tpRPC)|]
      Q [Type] -> Q Type -> [Q Dec] -> Q Dec
instanceD Q [Type]
constraints [t|HasRPCRepr $(pure tp)|]
        (Dec -> Q Dec
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dec -> Q Dec) -> [Dec] -> [Q Dec]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Dec]
typeInstance)
      where
        constraints :: Q Cxt
        constraints :: Q [Type]
constraints =
          [Q Type] -> Q [Type]
cxt ([Q Type] -> Q [Type]) -> [Q Type] -> Q [Type]
forall a b. (a -> b) -> a -> b
$ (Type -> Bool) -> [Type] -> [Type]
forall a. (a -> Bool) -> [a] -> [a]
filter Type -> Bool
hasTyVar [Type]
fieldTypes [Type] -> (Type -> Q Type) -> [Q Type]
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \Type
fieldType ->
            [t|HasRPCRepr $(pure fieldType)|]

    -- | Checks if the given type has any type variables.
    hasTyVar :: Type -> Bool
    hasTyVar :: Type -> Bool
hasTyVar Type
ty =
      ((Type -> Bool) -> [Type] -> Bool)
-> [Type] -> (Type -> Bool) -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Type -> Bool) -> [Type] -> Bool
forall t. Container t => (Element t -> Bool) -> t -> Bool
any (Type -> [Type]
forall a. Plated a => a -> [a]
universe Type
ty) \case
        VarT Name
_ -> Bool
True
        Type
_ -> Bool
False

----------------------------------------------------------------------------
-- Conversions
----------------------------------------------------------------------------

-- | Replace all big_maps in a value with the respective big_map IDs.
--
-- Throws an error if it finds a big_map without an ID.
valueAsRPC :: HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC :: Value t -> Value (TAsRPC t)
valueAsRPC Value t
v =
  case Value t
v of
    VKey {} -> Value t
Value (TAsRPC t)
v
    VUnit {} -> Value t
Value (TAsRPC t)
v
    VSignature {} -> Value t
Value (TAsRPC t)
v
    VChainId {} -> Value t
Value (TAsRPC t)
v
    VChest {} -> Value t
Value (TAsRPC t)
v
    VChestKey {} -> Value t
Value (TAsRPC t)
v
    VOption (Maybe (Value t)
vMaybe :: Maybe (Value elem)) ->
      (SingI t :- SingI (TAsRPC t))
-> (SingI (TAsRPC t) => Value ('TOption (TAsRPC t)))
-> Value ('TOption (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => e -> (c => r) -> r
withDict (SingI t :- SingI (TAsRPC t)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @elem) ((SingI (TAsRPC t) => Value ('TOption (TAsRPC t)))
 -> Value ('TOption (TAsRPC t)))
-> (SingI (TAsRPC t) => Value ('TOption (TAsRPC t)))
-> Value ('TOption (TAsRPC t))
forall a b. (a -> b) -> a -> b
$
        Maybe (Value' Instr (TAsRPC t)) -> Value ('TOption (TAsRPC t))
forall (t :: T) (instr :: [T] -> [T] -> *).
SingI t =>
Maybe (Value' instr t) -> Value' instr ('TOption t)
VOption (Maybe (Value' Instr (TAsRPC t)) -> Value ('TOption (TAsRPC t)))
-> Maybe (Value' Instr (TAsRPC t)) -> Value ('TOption (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Value t -> Value' Instr (TAsRPC t)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC (Value t -> Value' Instr (TAsRPC t))
-> Maybe (Value t) -> Maybe (Value' Instr (TAsRPC t))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Value t)
vMaybe
    VList ([Value t]
vList :: [Value elem]) ->
      (SingI t :- SingI (TAsRPC t))
-> (SingI (TAsRPC t) => Value ('TList (TAsRPC t)))
-> Value ('TList (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => e -> (c => r) -> r
withDict (SingI t :- SingI (TAsRPC t)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @elem) ((SingI (TAsRPC t) => Value ('TList (TAsRPC t)))
 -> Value ('TList (TAsRPC t)))
-> (SingI (TAsRPC t) => Value ('TList (TAsRPC t)))
-> Value ('TList (TAsRPC t))
forall a b. (a -> b) -> a -> b
$
        [Value' Instr (TAsRPC t)] -> Value ('TList (TAsRPC t))
forall (t :: T) (instr :: [T] -> [T] -> *).
SingI t =>
[Value' instr t] -> Value' instr ('TList t)
VList ([Value' Instr (TAsRPC t)] -> Value ('TList (TAsRPC t)))
-> [Value' Instr (TAsRPC t)] -> Value ('TList (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Value t -> Value' Instr (TAsRPC t)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC (Value t -> Value' Instr (TAsRPC t))
-> [Value t] -> [Value' Instr (TAsRPC t)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Value t]
vList
    VSet {} -> Value t
Value (TAsRPC t)
v
    VOp {} -> Value t
Value (TAsRPC t)
v
    VContract {} -> Value t
Value (TAsRPC t)
v
    VTicket {} -> Value t
Value (TAsRPC t)
v
    VPair (Value' Instr l
x, Value' Instr r
y) -> (Value' Instr (TAsRPC l), Value' Instr (TAsRPC r))
-> Value' Instr ('TPair (TAsRPC l) (TAsRPC r))
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(Value' instr l, Value' instr r) -> Value' instr ('TPair l r)
VPair (Value' Instr l -> Value' Instr (TAsRPC l)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC Value' Instr l
x, Value' Instr r -> Value' Instr (TAsRPC r)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC Value' Instr r
y)
    VOr (Either (Value l) (Value r)
vEither :: Either (Value l) (Value r)) ->
      ((SingI l, SingI r) :- (SingI (TAsRPC l), SingI (TAsRPC r)))
-> ((SingI (TAsRPC l), SingI (TAsRPC r)) =>
    Value ('TOr (TAsRPC l) (TAsRPC r)))
-> Value ('TOr (TAsRPC l) (TAsRPC r))
forall (c :: Constraint) e r. HasDict c e => e -> (c => r) -> r
withDict (SingI l :- SingI (TAsRPC l)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @l (SingI l :- SingI (TAsRPC l))
-> (SingI r :- SingI (TAsRPC r))
-> (SingI l, SingI r) :- (SingI (TAsRPC l), SingI (TAsRPC r))
forall (a :: Constraint) (b :: Constraint) (c :: Constraint)
       (d :: Constraint).
(a :- b) -> (c :- d) -> (a, c) :- (b, d)
*** SingI r :- SingI (TAsRPC r)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @r) (((SingI (TAsRPC l), SingI (TAsRPC r)) =>
  Value ('TOr (TAsRPC l) (TAsRPC r)))
 -> Value ('TOr (TAsRPC l) (TAsRPC r)))
-> ((SingI (TAsRPC l), SingI (TAsRPC r)) =>
    Value ('TOr (TAsRPC l) (TAsRPC r)))
-> Value ('TOr (TAsRPC l) (TAsRPC r))
forall a b. (a -> b) -> a -> b
$
        case Either (Value l) (Value r)
vEither of
          Right Value r
r -> Either (Value' Instr (TAsRPC l)) (Value' Instr (TAsRPC r))
-> Value ('TOr (TAsRPC l) (TAsRPC r))
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(SingI l, SingI r) =>
Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r)
VOr (Value' Instr (TAsRPC r)
-> Either (Value' Instr (TAsRPC l)) (Value' Instr (TAsRPC r))
forall a b. b -> Either a b
Right (Value r -> Value' Instr (TAsRPC r)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC Value r
r))
          Left Value l
l -> Either (Value' Instr (TAsRPC l)) (Value' Instr (TAsRPC r))
-> Value ('TOr (TAsRPC l) (TAsRPC r))
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(SingI l, SingI r) =>
Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r)
VOr (Value' Instr (TAsRPC l)
-> Either (Value' Instr (TAsRPC l)) (Value' Instr (TAsRPC r))
forall a b. a -> Either a b
Left (Value l -> Value' Instr (TAsRPC l)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC Value l
l))
    VLam {} -> Value t
Value (TAsRPC t)
v
    VMap (Map (Value k) (Value v)
vMap :: Map (Value k) (Value v)) ->
      (SingI v :- SingI (TAsRPC v))
-> (SingI (TAsRPC v) => Value ('TMap k (TAsRPC v)))
-> Value ('TMap k (TAsRPC v))
forall (c :: Constraint) e r. HasDict c e => e -> (c => r) -> r
withDict (SingI v :- SingI (TAsRPC v)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @v) ((SingI (TAsRPC v) => Value ('TMap k (TAsRPC v)))
 -> Value ('TMap k (TAsRPC v)))
-> (SingI (TAsRPC v) => Value ('TMap k (TAsRPC v)))
-> Value ('TMap k (TAsRPC v))
forall a b. (a -> b) -> a -> b
$
        Map (Value k) (Value' Instr (TAsRPC v))
-> Value ('TMap k (TAsRPC v))
forall (k :: T) (v :: T) (instr :: [T] -> [T] -> *).
(SingI k, SingI v, Comparable k) =>
Map (Value' instr k) (Value' instr v) -> Value' instr ('TMap k v)
VMap (Map (Value k) (Value' Instr (TAsRPC v))
 -> Value ('TMap k (TAsRPC v)))
-> Map (Value k) (Value' Instr (TAsRPC v))
-> Value ('TMap k (TAsRPC v))
forall a b. (a -> b) -> a -> b
$ Value v -> Value' Instr (TAsRPC v)
forall (t :: T). HasCallStack => Value t -> Value (TAsRPC t)
valueAsRPC (Value v -> Value' Instr (TAsRPC v))
-> Map (Value k) (Value v)
-> Map (Value k) (Value' Instr (TAsRPC v))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map (Value k) (Value v)
vMap
    VBigMap (Just Natural
bmId) Map (Value' Instr k) (Value' Instr v)
_ -> Natural -> Value' Instr 'TNat
forall (instr :: [T] -> [T] -> *). Natural -> Value' instr 'TNat
VNat Natural
bmId
    VBigMap Maybe Natural
Nothing Map (Value' Instr k) (Value' Instr v)
_ ->
      Text -> Value' Instr 'TNat
forall a. HasCallStack => Text -> a
error (Text -> Value' Instr 'TNat) -> Text -> Value' Instr 'TNat
forall a b. (a -> b) -> a -> b
$ [Text] -> Text
unlines
        [ Text
"Expected all big_maps to have an ID, but at least one big_map didn't."
        , Text
"This is most likely a bug."
        ]
    VInt {} -> Value t
Value (TAsRPC t)
v
    VNat {} -> Value t
Value (TAsRPC t)
v
    VString {} -> Value t
Value (TAsRPC t)
v
    VBytes {} -> Value t
Value (TAsRPC t)
v
    VMutez {} -> Value t
Value (TAsRPC t)
v
    VBool {} -> Value t
Value (TAsRPC t)
v
    VKeyHash {} -> Value t
Value (TAsRPC t)
v
    VTimestamp {} -> Value t
Value (TAsRPC t)
v
    VAddress {} -> Value t
Value (TAsRPC t)
v
    VBls12381Fr {} -> Value t
Value (TAsRPC t)
v
    VBls12381G1 {} -> Value t
Value (TAsRPC t)
v
    VBls12381G2 {} -> Value t
Value (TAsRPC t)
v

-- | Replaces all bigmap IDs with their corresponding bigmap values.
-- This is the inverse of `valueAsRPC`.
replaceBigMapIds
  :: forall t m. Monad m
  => (forall k v. (SingI k, SingI v) => Natural -> m (Value ('TBigMap k v)))
  -- ^ A function for looking up a bigmap using its ID.
  -> Sing t -> Value (TAsRPC t) -> m (Value t)
replaceBigMapIds :: (forall (k :: T) (v :: T).
 (SingI k, SingI v) =>
 Natural -> m (Value ('TBigMap k v)))
-> Sing t -> Value (TAsRPC t) -> m (Value t)
replaceBigMapIds forall (k :: T) (v :: T).
(SingI k, SingI v) =>
Natural -> m (Value ('TBigMap k v))
findBigMapById = Sing t -> Value (TAsRPC t) -> m (Value t)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go
  where
    go :: forall t1. Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
    go :: Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing t1
s Value (TAsRPC t1)
v = case (Sing t1
SingT t1
s, Value (TAsRPC t1)
v) of
      (STKey {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STUnit {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STSignature {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STChainId {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STChest {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STChestKey {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STOption Sing n
sMaybe, VOption vMaybe) ->
        Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sMaybe ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$
          Maybe (Value' Instr n) -> Value' Instr ('TOption n)
forall (t :: T) (instr :: [T] -> [T] -> *).
SingI t =>
Maybe (Value' instr t) -> Value' instr ('TOption t)
VOption (Maybe (Value' Instr n) -> Value' Instr ('TOption n))
-> m (Maybe (Value' Instr n)) -> m (Value' Instr ('TOption n))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' Instr t -> m (Value' Instr n))
-> Maybe (Value' Instr t) -> m (Maybe (Value' Instr n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Sing n -> Value (TAsRPC n) -> m (Value' Instr n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sMaybe) Maybe (Value' Instr t)
vMaybe
      (STList Sing n
sList, VList vList) ->
        Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sList ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$
          [Value' Instr n] -> Value' Instr ('TList n)
forall (t :: T) (instr :: [T] -> [T] -> *).
SingI t =>
[Value' instr t] -> Value' instr ('TList t)
VList ([Value' Instr n] -> Value' Instr ('TList n))
-> m [Value' Instr n] -> m (Value' Instr ('TList n))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' Instr t -> m (Value' Instr n))
-> [Value' Instr t] -> m [Value' Instr n]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Sing n -> Value (TAsRPC n) -> m (Value' Instr n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sList) [Value' Instr t]
vList
      (STSet {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STOperation {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STContract {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STTicket {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STPair Sing n
sa Sing n
sb, VPair (a, b)) -> do
        Value n
a' <- Sing n -> Value (TAsRPC n) -> m (Value n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sa Value' Instr l
Value (TAsRPC n)
a
        Value n
b' <- Sing n -> Value (TAsRPC n) -> m (Value n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sb Value' Instr r
Value (TAsRPC n)
b
        pure $ (Value n, Value n) -> Value' Instr ('TPair n n)
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(Value' instr l, Value' instr r) -> Value' instr ('TPair l r)
VPair (Value n
a', Value n
b')
      (STOr Sing n
sl Sing n
sr, VOr vEither) -> Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sl ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$ Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sr ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$
        case Either (Value' Instr l) (Value' Instr r)
vEither of
          Right Value' Instr r
r -> Either (Value' Instr n) (Value' Instr n) -> Value' Instr ('TOr n n)
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(SingI l, SingI r) =>
Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r)
VOr (Either (Value' Instr n) (Value' Instr n)
 -> Value' Instr ('TOr n n))
-> (Value' Instr n -> Either (Value' Instr n) (Value' Instr n))
-> Value' Instr n
-> Value' Instr ('TOr n n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value' Instr n -> Either (Value' Instr n) (Value' Instr n)
forall a b. b -> Either a b
Right (Value' Instr n -> Value' Instr ('TOr n n))
-> m (Value' Instr n) -> m (Value' Instr ('TOr n n))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sing n -> Value (TAsRPC n) -> m (Value' Instr n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sr Value' Instr r
Value (TAsRPC n)
r
          Left Value' Instr l
l -> Either (Value' Instr n) (Value' Instr n) -> Value' Instr ('TOr n n)
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(SingI l, SingI r) =>
Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r)
VOr (Either (Value' Instr n) (Value' Instr n)
 -> Value' Instr ('TOr n n))
-> (Value' Instr n -> Either (Value' Instr n) (Value' Instr n))
-> Value' Instr n
-> Value' Instr ('TOr n n)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value' Instr n -> Either (Value' Instr n) (Value' Instr n)
forall a b. a -> Either a b
Left (Value' Instr n -> Value' Instr ('TOr n n))
-> m (Value' Instr n) -> m (Value' Instr ('TOr n n))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Sing n -> Value (TAsRPC n) -> m (Value' Instr n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sl Value' Instr l
Value (TAsRPC n)
l
      (STLambda {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STMap Sing n
_ Sing n
sv, VMap vList) ->
        Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sv ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$
          Map (Value' Instr k) (Value' Instr n) -> Value' Instr ('TMap k n)
forall (k :: T) (v :: T) (instr :: [T] -> [T] -> *).
(SingI k, SingI v, Comparable k) =>
Map (Value' instr k) (Value' instr v) -> Value' instr ('TMap k v)
VMap (Map (Value' Instr k) (Value' Instr n) -> Value' Instr ('TMap k n))
-> m (Map (Value' Instr k) (Value' Instr n))
-> m (Value' Instr ('TMap k n))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value' Instr v -> m (Value' Instr n))
-> Map (Value' Instr k) (Value' Instr v)
-> m (Map (Value' Instr k) (Value' Instr n))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (Sing n -> Value (TAsRPC n) -> m (Value' Instr n)
forall (t1 :: T). Sing t1 -> Value (TAsRPC t1) -> m (Value t1)
go Sing n
sv) Map (Value' Instr k) (Value' Instr v)
vList
      (STBigMap Sing n
sk Sing n
sv, VNat bigMapId) -> Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sk ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$ Sing n -> (SingI n => m (Value t1)) -> m (Value t1)
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sv ((SingI n => m (Value t1)) -> m (Value t1))
-> (SingI n => m (Value t1)) -> m (Value t1)
forall a b. (a -> b) -> a -> b
$ Natural -> m (Value ('TBigMap n n))
forall (k :: T) (v :: T).
(SingI k, SingI v) =>
Natural -> m (Value ('TBigMap k v))
findBigMapById Natural
bigMapId
      (STInt {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STNat {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STString {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STBytes {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STMutez {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STBool {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STKeyHash {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STTimestamp {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STAddress {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STBls12381Fr {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STBls12381G1 {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v
      (STBls12381G2 {}, Value (TAsRPC t1)
_) -> Value t1 -> m (Value t1)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Value t1
Value (TAsRPC t1)
v

-- | Replace all @big_map@ annotations in a value with @nat@ annotations.
notesAsRPC :: Notes t -> Notes (TAsRPC t)
notesAsRPC :: Notes t -> Notes (TAsRPC t)
notesAsRPC Notes t
notes =
  case Notes t
notes of
    NTKey {} -> Notes t
Notes (TAsRPC t)
notes
    NTUnit {} -> Notes t
Notes (TAsRPC t)
notes
    NTSignature {} -> Notes t
Notes (TAsRPC t)
notes
    NTChainId {} -> Notes t
Notes (TAsRPC t)
notes
    NTChest {} -> Notes t
Notes (TAsRPC t)
notes
    NTChestKey {} -> Notes t
Notes (TAsRPC t)
notes
    NTOption TypeAnn
typeAnn Notes t
elemNotes -> TypeAnn -> Notes (TAsRPC t) -> Notes ('TOption (TAsRPC t))
forall (t :: T). TypeAnn -> Notes t -> Notes ('TOption t)
NTOption TypeAnn
typeAnn (Notes (TAsRPC t) -> Notes ('TOption (TAsRPC t)))
-> Notes (TAsRPC t) -> Notes ('TOption (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Notes t -> Notes (TAsRPC t)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes t
elemNotes
    NTList TypeAnn
typeAnn Notes t
elemNotes -> TypeAnn -> Notes (TAsRPC t) -> Notes ('TList (TAsRPC t))
forall (t :: T). TypeAnn -> Notes t -> Notes ('TList t)
NTList TypeAnn
typeAnn (Notes (TAsRPC t) -> Notes ('TList (TAsRPC t)))
-> Notes (TAsRPC t) -> Notes ('TList (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Notes t -> Notes (TAsRPC t)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes t
elemNotes
    NTSet {} -> Notes t
Notes (TAsRPC t)
notes
    NTOperation {} -> Notes t
Notes (TAsRPC t)
notes
    NTContract {} -> Notes t
Notes (TAsRPC t)
notes
    NTTicket {} -> Notes t
Notes (TAsRPC t)
notes
    NTPair TypeAnn
typeAnn FieldAnn
fieldAnn1 FieldAnn
fieldAnn2 VarAnn
varAnn1 VarAnn
varAnn2 Notes p
notes1 Notes q
notes2 ->
      TypeAnn
-> FieldAnn
-> FieldAnn
-> VarAnn
-> VarAnn
-> Notes (TAsRPC p)
-> Notes (TAsRPC q)
-> Notes ('TPair (TAsRPC p) (TAsRPC q))
forall (p :: T) (p :: T).
TypeAnn
-> FieldAnn
-> FieldAnn
-> VarAnn
-> VarAnn
-> Notes p
-> Notes p
-> Notes ('TPair p p)
NTPair TypeAnn
typeAnn FieldAnn
fieldAnn1 FieldAnn
fieldAnn2 VarAnn
varAnn1 VarAnn
varAnn2 (Notes p -> Notes (TAsRPC p)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes p
notes1) (Notes q -> Notes (TAsRPC q)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes q
notes2)
    NTOr TypeAnn
typeAnn FieldAnn
fieldAnn1 FieldAnn
fieldAnn2 Notes p
notes1 Notes q
notes2 ->
      TypeAnn
-> FieldAnn
-> FieldAnn
-> Notes (TAsRPC p)
-> Notes (TAsRPC q)
-> Notes ('TOr (TAsRPC p) (TAsRPC q))
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes ('TOr p q)
NTOr TypeAnn
typeAnn FieldAnn
fieldAnn1 FieldAnn
fieldAnn2 (Notes p -> Notes (TAsRPC p)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes p
notes1) (Notes q -> Notes (TAsRPC q)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes q
notes2)
    NTLambda {} -> Notes t
Notes (TAsRPC t)
notes
    NTMap TypeAnn
typeAnn Notes k
keyAnns Notes v
valueNotes -> TypeAnn
-> Notes k -> Notes (TAsRPC v) -> Notes ('TMap k (TAsRPC v))
forall (k :: T) (v :: T).
TypeAnn -> Notes k -> Notes v -> Notes ('TMap k v)
NTMap TypeAnn
typeAnn Notes k
keyAnns (Notes v -> Notes (TAsRPC v)
forall (t :: T). Notes t -> Notes (TAsRPC t)
notesAsRPC Notes v
valueNotes)
    NTBigMap TypeAnn
typeAnn Notes k
_ Notes v
_ -> TypeAnn -> Notes 'TNat
NTNat TypeAnn
typeAnn
    NTInt {} -> Notes t
Notes (TAsRPC t)
notes
    NTNat {} -> Notes t
Notes (TAsRPC t)
notes
    NTString {} -> Notes t
Notes (TAsRPC t)
notes
    NTBytes {} -> Notes t
Notes (TAsRPC t)
notes
    NTMutez {} -> Notes t
Notes (TAsRPC t)
notes
    NTBool {} -> Notes t
Notes (TAsRPC t)
notes
    NTKeyHash {} -> Notes t
Notes (TAsRPC t)
notes
    NTTimestamp {} -> Notes t
Notes (TAsRPC t)
notes
    NTAddress {} -> Notes t
Notes (TAsRPC t)
notes
    NTBls12381Fr {} -> Notes t
Notes (TAsRPC t)
notes
    NTBls12381G1 {} -> Notes t
Notes (TAsRPC t)
notes
    NTBls12381G2 {} -> Notes t
Notes (TAsRPC t)
notes
    NTNever {} -> Notes t
Notes (TAsRPC t)
notes
    NTSaplingState {} -> Notes t
Notes (TAsRPC t)
notes
    NTSaplingTransaction {} -> Notes t
Notes (TAsRPC t)
notes

----------------------------------------------------------------------------
-- Entailments
----------------------------------------------------------------------------

-- | A proof that if a singleton exists for @t@,
-- then so it does for @TAsRPC t@.
rpcSingIEvi :: forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi :: SingI t :- SingI (TAsRPC t)
rpcSingIEvi =
  (SingI t => Dict (SingI (TAsRPC t))) -> SingI t :- SingI (TAsRPC t)
forall (a :: Constraint) (b :: Constraint). (a => Dict b) -> a :- b
Sub ((SingI t => Dict (SingI (TAsRPC t)))
 -> SingI t :- SingI (TAsRPC t))
-> (SingI t => Dict (SingI (TAsRPC t)))
-> SingI t :- SingI (TAsRPC t)
forall a b. (a -> b) -> a -> b
$
    case SingI t => Sing t
forall k (a :: k). SingI a => Sing a
sing @t of
      Sing t
STKey -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STUnit {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STSignature {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STChainId {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STChest {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STChestKey {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STOption (s :: Sing elem) -> Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
s ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ SingI (TAsRPC n) => Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @elem
      STList (s :: Sing elem) -> Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
s ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$  SingI (TAsRPC n) => Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @elem
      STSet (s :: Sing elem) -> Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
s ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ SingI (TAsRPC n) => Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @elem
      STOperation {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STContract {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STTicket {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STPair (sa :: Sing a) (sb :: Sing b) ->
        Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sa ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sb ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$
          SingI (TAsRPC n) => Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @a (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @b
      STOr (sl :: Sing l) (sr :: Sing r) ->
        Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sl ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sr ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$
          SingI (TAsRPC n) => Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @l (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @r
      STLambda {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STMap (sk :: Sing k) (sv :: Sing v) ->
        Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sk ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$ Sing n
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall k (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing n
sv ((SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t)))
-> (SingI n => Dict (SingI (TAsRPC t))) -> Dict (SingI (TAsRPC t))
forall a b. (a -> b) -> a -> b
$
          SingI (TAsRPC n) => Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @k (SingI (TAsRPC n) => Dict (SingI (TAsRPC t)))
-> (SingI n :- SingI (TAsRPC n)) -> Dict (SingI (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI n :- SingI (TAsRPC n)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @v
      STBigMap {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STInt {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STNat {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STString {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STBytes {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STMutez {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STBool {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STKeyHash {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STBls12381Fr {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STBls12381G1 {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STBls12381G2 {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STTimestamp {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STAddress {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STNever {} -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STSaplingState _ -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
      STSaplingTransaction _ -> Dict (SingI (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict

-- | A proof that if @t@ is well-typed, then @TAsRPC t@ is also well-typed.
rpcWellTypedEvi :: forall (t :: T). WellTyped t => WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi :: WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi = Sing t -> WellTyped t :- WellTyped (TAsRPC t)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing t
forall k (a :: k). SingI a => Sing a
sing

rpcWellTypedEvi'
  :: WellTyped t
  => Sing t
  -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' :: Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing t
sng = (WellTyped t => Dict (WellTyped (TAsRPC t)))
-> WellTyped t :- WellTyped (TAsRPC t)
forall (a :: Constraint) (b :: Constraint). (a => Dict b) -> a :- b
Sub ((WellTyped t => Dict (WellTyped (TAsRPC t)))
 -> WellTyped t :- WellTyped (TAsRPC t))
-> (WellTyped t => Dict (WellTyped (TAsRPC t)))
-> WellTyped t :- WellTyped (TAsRPC t)
forall a b. (a -> b) -> a -> b
$ case Sing t
sng of
  Sing t
STKey -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STUnit {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSignature {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChainId {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STOption s -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
s
  STList s -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
s
  STSet s -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
s
  STOperation {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STContract s -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
s
  STTicket s -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
s
  STPair sa sb -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sa (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sb
  STOr sl sr -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sl (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sr
  STLambda sa sb -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sa (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sb
  STMap sk sv -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sk (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sv
  STBigMap sk sv -> WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sk (WellTyped (TAsRPC n) => Dict (WellTyped (TAsRPC t)))
-> (WellTyped n :- WellTyped (TAsRPC n))
-> Dict (WellTyped (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> WellTyped n :- WellTyped (TAsRPC n)
forall (t :: T).
WellTyped t =>
Sing t -> WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi' Sing n
sv
  STInt {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNat {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STString {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBytes {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMutez {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBool {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STKeyHash {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381Fr {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G1 {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G2 {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTimestamp {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STAddress {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChest {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChestKey {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNever {} -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingState _ -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingTransaction _ -> Dict (WellTyped (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict

-- | A proof that if @t@ does not contain any operations, then neither does @TAsRPC t@.
rpcHasNoOpEvi :: forall (t :: T). (SingI t, HasNoOp t) => HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi :: HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi = Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing t
forall k (a :: k). SingI a => Sing a
sing

rpcHasNoOpEvi'
  :: HasNoOp t
  => Sing t
  -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' :: Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing t
sng = (HasNoOp t => Dict (HasNoOp (TAsRPC t)))
-> HasNoOp t :- HasNoOp (TAsRPC t)
forall (a :: Constraint) (b :: Constraint). (a => Dict b) -> a :- b
Sub ((HasNoOp t => Dict (HasNoOp (TAsRPC t)))
 -> HasNoOp t :- HasNoOp (TAsRPC t))
-> (HasNoOp t => Dict (HasNoOp (TAsRPC t)))
-> HasNoOp t :- HasNoOp (TAsRPC t)
forall a b. (a -> b) -> a -> b
$ case Sing t
sng of
  Sing t
STKey -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STUnit {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSignature {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChainId {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChest {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChestKey {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STOption s -> HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
s
  STList s -> HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
s
  STSet s -> HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
s
  STContract {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTicket {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STPair sa sb -> case Sing n -> OpPresence n
forall (ty :: T). Sing ty -> OpPresence ty
checkOpPresence Sing n
sa of
    OpPresence n
OpAbsent -> HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
sa (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
sb
  STOr sl sr -> case Sing n -> OpPresence n
forall (ty :: T). Sing ty -> OpPresence ty
checkOpPresence Sing n
sl of
    OpPresence n
OpAbsent -> HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
sl (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
sr
  STLambda {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMap _ sv -> case Sing n -> OpPresence n
forall (ty :: T). Sing ty -> OpPresence ty
checkOpPresence Sing n
sv of
    OpPresence n
OpAbsent -> HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoOp (TAsRPC n) => Dict (HasNoOp (TAsRPC t)))
-> (HasNoOp n :- HasNoOp (TAsRPC n)) -> Dict (HasNoOp (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoOp n :- HasNoOp (TAsRPC n)
forall (t :: T).
HasNoOp t =>
Sing t -> HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi' Sing n
sv
  STBigMap {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STInt {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNat {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STString {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBytes {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMutez {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBool {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STKeyHash {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381Fr {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G1 {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G2 {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTimestamp {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STAddress {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNever {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingState {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingTransaction {} -> Dict (HasNoOp (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict

-- | A proof that @AsRPC (Value t)@ does not contain big_maps.
rpcHasNoBigMapEvi :: forall (t :: T). SingI t => Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi :: Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi = Sing t -> Dict (HasNoBigMap (TAsRPC t))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' (SingI t => Sing t
forall k (a :: k). SingI a => Sing a
sing @t)

rpcHasNoBigMapEvi' :: Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' :: Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' = \case
  Sing t
STKey -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STUnit {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSignature {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChainId {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChest {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChestKey {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STOption s -> HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TOption (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoBigMap (TAsRPC n) =>
 Dict (HasNoBigMap ('TOption (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TOption (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
s
  STList s -> HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TList (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TList (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TList (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
s
  STSet s -> HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TSet n))
forall (a :: Constraint). a => Dict a
Dict (HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TSet n)))
-> Dict (HasNoBigMap (TAsRPC n)) -> Dict (HasNoBigMap ('TSet n))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
s
  STOperation {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STContract {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTicket {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STPair sa sb -> HasNoBigMap (TAsRPC n) =>
Dict (HasNoBigMap ('TPair (TAsRPC n) (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoBigMap (TAsRPC n) =>
 Dict (HasNoBigMap ('TPair (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TPair (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
sa (HasNoBigMap (TAsRPC n) =>
 Dict (HasNoBigMap ('TPair (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TPair (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
sb
  STOr sl sr -> HasNoBigMap (TAsRPC n) =>
Dict (HasNoBigMap ('TOr (TAsRPC n) (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoBigMap (TAsRPC n) =>
 Dict (HasNoBigMap ('TOr (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TOr (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
sl (HasNoBigMap (TAsRPC n) =>
 Dict (HasNoBigMap ('TOr (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TOr (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
sr
  STLambda {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMap sk sv -> HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TMap n (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TMap n (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TMap n (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
sk (HasNoBigMap (TAsRPC n) => Dict (HasNoBigMap ('TMap n (TAsRPC n))))
-> Dict (HasNoBigMap (TAsRPC n))
-> Dict (HasNoBigMap ('TMap n (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoBigMap (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoBigMap (TAsRPC t))
rpcHasNoBigMapEvi' Sing n
sv
  STBigMap {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STInt {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNat {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STString {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBytes {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMutez {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBool {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STKeyHash {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381Fr {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G1 {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G2 {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTimestamp {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STAddress {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNever {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingState {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingTransaction {} -> Dict (HasNoBigMap (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict

-- | A proof that @AsRPC (Value t)@ does not contain big_maps.
rpcHasNoNestedBigMapsEvi
  :: forall (t :: T).
     SingI t
  => Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi :: Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi = Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' (SingI t => Sing t
forall k (a :: k). SingI a => Sing a
sing @t)

rpcHasNoNestedBigMapsEvi' :: Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' :: Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' = \case
  Sing t
STKey -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STUnit {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSignature {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChainId {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChest {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChestKey {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STOption s -> HasNoNestedBigMaps (TAsRPC n) =>
Dict (HasNoNestedBigMaps ('TOption (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TOption (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TOption (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
s
  STList s -> HasNoNestedBigMaps (TAsRPC n) =>
Dict (HasNoNestedBigMaps ('TList (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TList (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TList (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
s
  STSet s -> HasNoNestedBigMaps (TAsRPC n) =>
Dict (HasNoNestedBigMaps ('TSet n))
forall (a :: Constraint). a => Dict a
Dict (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TSet n)))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TSet n))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
s
  STOperation {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STContract {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTicket {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STPair sa sb ->
    HasNoNestedBigMaps (TAsRPC n) =>
Dict (HasNoNestedBigMaps ('TPair (TAsRPC n) (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TPair (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TPair (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
sa (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TPair (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TPair (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
sb
  STOr sl sr ->
    HasNoNestedBigMaps (TAsRPC n) =>
Dict (HasNoNestedBigMaps ('TOr (TAsRPC n) (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TOr (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TOr (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
sl (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TOr (TAsRPC n) (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TOr (TAsRPC n) (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
sr
  STLambda {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMap sk sv ->
    HasNoNestedBigMaps (TAsRPC n) =>
Dict (HasNoNestedBigMaps ('TMap n (TAsRPC n)))
forall (a :: Constraint). a => Dict a
Dict (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TMap n (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TMap n (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
sk (HasNoNestedBigMaps (TAsRPC n) =>
 Dict (HasNoNestedBigMaps ('TMap n (TAsRPC n))))
-> Dict (HasNoNestedBigMaps (TAsRPC n))
-> Dict (HasNoNestedBigMaps ('TMap n (TAsRPC n)))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> Dict (HasNoNestedBigMaps (TAsRPC n))
forall (t :: T). Sing t -> Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi' Sing n
sv
  STBigMap {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STInt {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNat {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STString {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBytes {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMutez {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBool {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STKeyHash {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381Fr {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G1 {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G2 {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTimestamp {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STAddress {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNever {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingState {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingTransaction {} -> Dict (HasNoNestedBigMaps (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict

-- | A proof that if @t@ does not contain any contract values, then neither does @TAsRPC t@.
rpcHasNoContractEvi
  :: forall (t :: T).
     (SingI t, HasNoContract t)
  => HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi :: HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi = Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing t
forall k (a :: k). SingI a => Sing a
sing

rpcHasNoContractEvi'
  :: HasNoContract t
  => Sing t
  -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' :: Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing t
sng = (HasNoContract t => Dict (HasNoContract (TAsRPC t)))
-> HasNoContract t :- HasNoContract (TAsRPC t)
forall (a :: Constraint) (b :: Constraint). (a => Dict b) -> a :- b
Sub ((HasNoContract t => Dict (HasNoContract (TAsRPC t)))
 -> HasNoContract t :- HasNoContract (TAsRPC t))
-> (HasNoContract t => Dict (HasNoContract (TAsRPC t)))
-> HasNoContract t :- HasNoContract (TAsRPC t)
forall a b. (a -> b) -> a -> b
$ case Sing t
sng of
  Sing t
STKey -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STUnit {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSignature {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChainId {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChest {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STChestKey {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STOption s -> HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
s
  STList s -> HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
s
  STSet _ -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STOperation {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTicket {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STPair sa sb -> case Sing n -> ContractPresence n
forall (ty :: T). Sing ty -> ContractPresence ty
checkContractTypePresence Sing n
sa of
    ContractPresence n
ContractAbsent ->
      HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
sa (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
sb
  STOr sl sr -> case Sing n -> ContractPresence n
forall (ty :: T). Sing ty -> ContractPresence ty
checkContractTypePresence Sing n
sl of
    ContractPresence n
ContractAbsent ->
      HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
sl (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
sr
  STLambda {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMap _ sv -> HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict (HasNoContract (TAsRPC n) => Dict (HasNoContract (TAsRPC t)))
-> (HasNoContract n :- HasNoContract (TAsRPC n))
-> Dict (HasNoContract (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ Sing n -> HasNoContract n :- HasNoContract (TAsRPC n)
forall (t :: T).
HasNoContract t =>
Sing t -> HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi' Sing n
sv
  STBigMap {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STInt {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNat {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STString {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBytes {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STMutez {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBool {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STKeyHash {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381Fr {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G1 {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STBls12381G2 {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STTimestamp {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STAddress {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STNever {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingState {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
  STSaplingTransaction {} -> Dict (HasNoContract (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict

-- | A proof that if @t@ is a valid storage type, then so is @TAsRPC t@.
rpcStorageScopeEvi :: forall (t :: T). StorageScope t :- StorageScope (TAsRPC t)
rpcStorageScopeEvi :: StorageScope t :- StorageScope (TAsRPC t)
rpcStorageScopeEvi =
  (StorageScope t => Dict (StorageScope (TAsRPC t)))
-> StorageScope t :- StorageScope (TAsRPC t)
forall (a :: Constraint) (b :: Constraint). (a => Dict b) -> a :- b
Sub ((StorageScope t => Dict (StorageScope (TAsRPC t)))
 -> StorageScope t :- StorageScope (TAsRPC t))
-> (StorageScope t => Dict (StorageScope (TAsRPC t)))
-> StorageScope t :- StorageScope (TAsRPC t)
forall a b. (a -> b) -> a -> b
$ SingI (TAsRPC t) => Dict (StorageScope (TAsRPC t))
forall (a :: Constraint). a => Dict a
Dict
    (SingI (TAsRPC t) => Dict (StorageScope (TAsRPC t)))
-> (SingI t :- SingI (TAsRPC t)) -> Dict (StorageScope (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI t :- SingI (TAsRPC t)
forall (t :: T). SingI t :- SingI (TAsRPC t)
rpcSingIEvi @t
    (HasNoOp (TAsRPC t) => Dict (StorageScope (TAsRPC t)))
-> (HasNoOp t :- HasNoOp (TAsRPC t))
-> Dict (StorageScope (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ (SingI t, HasNoOp t) => HasNoOp t :- HasNoOp (TAsRPC t)
forall (t :: T).
(SingI t, HasNoOp t) =>
HasNoOp t :- HasNoOp (TAsRPC t)
rpcHasNoOpEvi @t
    (HasNoNestedBigMaps (TAsRPC t) => Dict (StorageScope (TAsRPC t)))
-> Dict (HasNoNestedBigMaps (TAsRPC t))
-> Dict (StorageScope (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ SingI t => Dict (HasNoNestedBigMaps (TAsRPC t))
forall (t :: T). SingI t => Dict (HasNoNestedBigMaps (TAsRPC t))
rpcHasNoNestedBigMapsEvi @t
    (HasNoContract (TAsRPC t) => Dict (StorageScope (TAsRPC t)))
-> (HasNoContract t :- HasNoContract (TAsRPC t))
-> Dict (StorageScope (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ (SingI t, HasNoContract t) =>
HasNoContract t :- HasNoContract (TAsRPC t)
forall (t :: T).
(SingI t, HasNoContract t) =>
HasNoContract t :- HasNoContract (TAsRPC t)
rpcHasNoContractEvi @t
    (WellTyped (TAsRPC t) => Dict (StorageScope (TAsRPC t)))
-> (WellTyped t :- WellTyped (TAsRPC t))
-> Dict (StorageScope (TAsRPC t))
forall (c :: Constraint) e r. HasDict c e => (c => r) -> e -> r
\\ WellTyped t => WellTyped t :- WellTyped (TAsRPC t)
forall (t :: T). WellTyped t => WellTyped t :- WellTyped (TAsRPC t)
rpcWellTypedEvi @t