Remove TemplateOrInterface type class (#15347)

This commit is contained in:
Remy 2022-11-15 09:44:51 +01:00 committed by GitHub
parent 8b77bec622
commit d071e5e505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 24 deletions

View File

@ -20,21 +20,8 @@ import DA.Internal.Template
import GHC.Types (primitive)
type TemplateOrInterface t =
( HasTemplateTypeRep t
, HasToAnyTemplate t
, HasFromAnyTemplate t
)
-- | Constraint satisfied by templates.
type Template t =
( HasSignatory t
, HasObserver t
, HasEnsure t
, HasAgreement t
, HasCreate t
, HasFetch t
, HasArchive t
, HasTemplateTypeRep t
( HasTemplateTypeRep t
, HasToAnyTemplate t
, HasFromAnyTemplate t
)
@ -100,7 +87,7 @@ stakeholder t = signatory t ++ observer t
-- | Constraint satisfied by choices.
type Choice t c r =
( TemplateOrInterface t
( Template t
, HasExercise t c r
, HasToAnyChoice t c r
, HasFromAnyChoice t c r

View File

@ -775,7 +775,7 @@ tests tools = testGroup "Data Dependencies" $
-- Regression for issue https://github.com/digital-asset/daml/issues/9663
-- Constraint tuple functions
, "constraintTupleFn : (Template t, Show t) => t -> ()"
, "constraintTupleFn : (HasSignatory t, Show t) => t -> ()"
, "constraintTupleFn = const ()"
, "type BigConstraint a b c = (Show a, Show b, Show c, Additive c)"
, "bigConstraintFn : BigConstraint a b c => a -> b -> c -> c -> Text"
@ -854,7 +854,7 @@ tests tools = testGroup "Data Dependencies" $
, "usesHasFieldEmptyIndirectly : HasField \"\" a b => a -> b"
, "usesHasFieldEmptyIndirectly = usesHasFieldEmpty"
-- use constraint tuple fn
, "useConstraintTupleFn : (Template t, Show t) => t -> ()"
, "useConstraintTupleFn : (HasSignatory t, Show t) => t -> ()"
, "useConstraintTupleFn x = constraintTupleFn x"
, "useBigConstraintFn : Text"
, "useBigConstraintFn = bigConstraintFn True \"Hello\" 10 20"

View File

@ -818,7 +818,6 @@ completionTests run _runScenarios = testGroup "completion"
map (set documentation Nothing) completions @?=
[ mkTypeCompletion "Party"
, mkTypeCompletion "IsParties"
, mkTypeCompletion "TemplateOrInterface"
]
, testCase "with keyword" $ run $ do
foo <- openDoc' "Foo.daml" damlId $ T.unlines

View File

@ -229,7 +229,7 @@ data QueryInterfacePayload a = QueryInterfacePayload
-- | Query the set of active contracts views for an interface
-- that are visible to the given party.
queryInterface : forall i v p. (TemplateOrInterface i, HasInterfaceView i v, IsParties p) => p -> Script [(ContractId i, Optional v)]
queryInterface : forall i v p. (Template i, HasInterfaceView i v, IsParties p) => p -> Script [(ContractId i, Optional v)]
queryInterface p = lift $ Free $ QueryInterface QueryInterfacePayload with
parties = toParties p
interfaceId = templateTypeRep @i
@ -244,7 +244,7 @@ data QueryInterfaceContractIdPayload a = QueryInterfaceContractIdPayload
, locations : [(Text, SrcLoc)]
} deriving Functor
queryInterfaceContractId : forall i v p. (TemplateOrInterface i, HasInterfaceView i v, IsParties p) => HasCallStack => p -> ContractId i -> Script (Optional v)
queryInterfaceContractId : forall i v p. (Template i, HasInterfaceView i v, IsParties p) => HasCallStack => p -> ContractId i -> Script (Optional v)
queryInterfaceContractId p c = lift $ Free $ QueryInterfaceContractId QueryInterfaceContractIdPayload with
parties = toParties p
interfaceId = templateTypeRep @i
@ -776,7 +776,7 @@ instance Show AnyContractId where
where app_prec = 10
-- | HIDE This is an early access feature.
fromAnyContractId : forall t. TemplateOrInterface t => AnyContractId -> Optional (ContractId t)
fromAnyContractId : forall t. Template t => AnyContractId -> Optional (ContractId t)
fromAnyContractId cid
| cid.templateId == templateTypeRep @t = Some (coerceContractId cid.contractId)
| otherwise = None

View File

@ -68,7 +68,7 @@ instance Show AnyContractId where
-- | Wrap a `ContractId t` in `AnyContractId`.
toAnyContractId : forall t. TemplateOrInterface t => ContractId t -> AnyContractId
toAnyContractId : forall t. Template t => ContractId t -> AnyContractId
toAnyContractId cid = AnyContractId
{ templateId = templateTypeRep @t
, contractId = coerceContractId cid
@ -76,7 +76,7 @@ toAnyContractId cid = AnyContractId
-- | Check if a `AnyContractId` corresponds to the given template or return
-- `None` otherwise.
fromAnyContractId : forall t. TemplateOrInterface t => AnyContractId -> Optional (ContractId t)
fromAnyContractId : forall t. Template t => AnyContractId -> Optional (ContractId t)
fromAnyContractId cid
| cid.templateId == templateTypeRep @t = Some (coerceContractId cid.contractId)
| otherwise = None
@ -188,7 +188,7 @@ data RegisteredTemplates
= AllInDar -- ^ Listen to events for all templates in the given DAR.
| RegisteredTemplates [RegisteredTemplate]
registeredTemplate : forall t. TemplateOrInterface t => RegisteredTemplate
registeredTemplate : forall t. Template t => RegisteredTemplate
registeredTemplate = RegisteredTemplate (templateTypeRep @t)
-- | A ledger API command. To construct a command use `createCmd` and `exerciseCmd`.