mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Remove TemplateOrInterface type class (#15347)
This commit is contained in:
parent
8b77bec622
commit
d071e5e505
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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`.
|
||||
|
Loading…
Reference in New Issue
Block a user