-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert viewtype and view methods to LF #14456
Conversation
3486299
to
fe85d96
Compare
f9756c0
to
44f368a
Compare
a7de08b
to
053c0bc
Compare
4515960
to
daffa51
Compare
Marking this ready for review. Git tells me that there are ~128 lines worth of changes to non-daml/non-expected files. There are a few daml files with non-trivial changes, but most of them add unit viewtypes. |
950ba61
to
eb0d080
Compare
@@ -161,3 +164,10 @@ _exerciseInterfaceGuard : forall i t. | |||
ContractId t -> (t -> Bool) -> i -> Bool | |||
_exerciseInterfaceGuard cid tpred ivalue = | |||
tpred (unsafeFromInterface (coerceContractId cid) ivalue) | |||
|
|||
-- Read: Interface `i` has a view of type `v` | |||
class HasInterfaceView i v | i -> v where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes this makes more sense here, thanks
@@ -9,6 +9,7 @@ import DA.Assert ((===)) | |||
|
|||
-- | An interface comment. | |||
interface Token where | |||
viewtype () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this made me wonder, would users get an error for trying to define a method named view
?
@@ -85,8 +101,8 @@ Empty Interfaces | |||
:end-before: -- EMPTY_INTERFACE_END | |||
|
|||
- It is possible (though not necessarily useful) to define an interface without | |||
methods, precondition or choices. In such a case, the ``where`` keyword | |||
can be dropped. | |||
methods, precondition or choices. However, a view type must always be defined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for updating the docs :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, thank you! Please address the comment on computeInterfaceView
before merging but looks good otherwise.
daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/InterfaceViewSpec.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me other than
- (these two can be addressed in future PRs)
- error message for trying to
definedeclare a method namedview
in an interface (not in animplements
block) - moving the interface declarations checks to da-ghc
- error message for trying to
- @cocreature's point about
computeInterfaceView
This implements LF conversion, and typechecks the generated LF.
Builds on #14456 and #14439, will constitute fewer lines when those PRs are merged.