ScopedTypeVariables and TypeApplications
App Development3 posts167 viewsLast activity Feb 2022
AS
asarpeshkarOP
Feb 2022Is there a limitation on using a scoped type variable in a visible type application? For example, the following doesn’t compile with “error:Not in scope: type variable ‘t’”:
qck : TemplateKey t k => forall t k. Proxy t -> Party -> k -> Script (Optional (ContractId t, t))
qck _ = queryContractKey @t
Context: I’d like to write a class method that queries for a template type t in the class head, but that doesn’t work, and neither does this standalone declaration with an explicit forall.
What am I doing wrong?
CO
cocreature
Feb 2022Your forall is too far nested down. You need to pull it outside the constraint. Then your example compiles perfectly fine:
qck : forall t k. TemplateKey t k => Proxy t -> Party -> k -> Script (Optional (ContractId t, t))
qck _ = queryContractKey @t
AS
asarpeshkar
Feb 2022Thanks, that worked.