-
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
Add an initial version of DAML script #3428
Conversation
The code still needs a fair amount of cleanup but it seems to work and there is a test so I’d like to do the cleanup in-tree after merging the current state
10d5d40
to
e607d4d
Compare
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.
You should use match
instead of asInstanceOf
.
dar.all | ||
.find { | ||
case (pkgId, pkg) => | ||
pkg.modules.contains(DottedName.assertFromString("DA.Internal.LF")) |
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.
DottedName.assertFromString("DA.Internal.LF")
can be a constant.
<root level="INFO"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
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.
I would not put loback.xml
in the src/main/resources
. It would get packaged in a jar and gets deployed to maven. This is going to pollute end-user's classpath with unnecessary logback.xml. I would rather force everyone who deploys you app start thinking about logback configuration ASAP :)
java -Dlogback.configurationFile=/path/to/config.xml
is the way to go. However we have not been following this practice. So feel free to disregard this comment :)
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.
src/test/resources
is fine, it does not pollute production classpath.
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.
We don’t plan to publish anything else than the executable and even for the executable you can still override the bundled logback file with -Dlogback.configurationFile
.
} | ||
} | ||
} | ||
val tuple = machine.toSValue.asInstanceOf[STuple] |
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.
you should use match here, something like this:
machine.toSValue match {
case STuple(_, (a0: SVariant) :: (a1: SVariant) :: _) => (a0, a1)
case => sys.error("something unexpected")
}
or if you know that it is a tuple 2
machine.toSValue match {
case STuple(_, (a0: SVariant) :: (a1: SVariant) :: Nil) => (a0, a1)
case => sys.error("something unexpected")
}
in any case using match
is more idiomatic Scala, you should never use asInstanceOf
.
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.
oops it is java.util.ArrayList
you cannot match it like this, so you might want to convert it to Scala first. But in any case using asInstanceOf
is discouraged unless you are hardcore Java programmer :)
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.
Yeah I’ll kill all the asInstanceOf
stuff in a follow-up PR. That was just for prototyping.
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.
had a chat with @cocreature. He wants to merge it ASAP to avoid any further conflicts. He is planning to address the instanceOf
in a follow-up PR.
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.
Super nice. Thank you so much!
Free x >>= f = Free ((>>= f) <$> x) | ||
|
||
-- | A free applicative, since we don’t have existentials we have to use the weird RankNTypes encoding, this is isomorphic to | ||
-- forall b. Ap f b (Ap f (b -> a)) |
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.
-- forall b. Ap f b (Ap f (b -> a)) | |
-- forall b. Ap (f b) (Ap f (b -> a)) |
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.
Good catch, thanks! fixed in #3438
SEMakeClo(Array(), 1, SEVar(1))) | ||
val compiledPackages = PureCompiledPackages(darMap, definitionMap).right.get | ||
|
||
def toLedgerRecord(v: SValue) = { |
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.
Could some of this be shared between triggers and daml-script?
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.
We could probably share a bit, e.g., the logic for converting AnyTemplate
but most of the conversion are specific to the types used in the trigger/script library so the shared code isn’t as large as one might hope. I’ll first cleanup the conversion logic here and then see what we can factor out.
The code still needs a fair amount of cleanup but it seems to work and there is a test so I’d like to do the cleanup in-tree after merging the current state
The code still needs a fair amount of cleanup but it seems to work and
there is a test so I’d like to do the cleanup in-tree after merging
the current state
Pull Request Checklist
NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.