-
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
Converting functions in data dependencies. #4182
Conversation
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 great, thanks for doing this so quickly! We should definitely add a test before merging. I would suggest that we use something like a template in DAML-LF 1.6 or 1.7 + top-level monomorphized create
, archive
and signatory
functions. That provides a fairly user-friendly way of upgrading packages with templates from before the typeclass changes (so in particular anything on DAML-LF <= 1.7) so this is probably something that we’ll actually need.
(noLoc $ HsVar noExt (mkRdrName "error")) | ||
(mkStringLit msg) | ||
|
||
mkStringLit :: T.Text -> LHsExpr GhcPs |
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.
Judging from CI this seems to break probably due to OverloadedStrings
, maybe try generating {-# LANGUAGE NoOverloadedStrings #-}
or whatever the extension is called to disable this.
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.
Trying it out. I spent way too much time looking for where to add this extension in HsModule
... turns out there was a plaintext header being added with the list of extensions. 😅
| (lfName, lfType) <- dvalBinder | ||
, lfNameText <- LF.unExprValName lfName | ||
= not (LF.getIsTest dvalIsTest) | ||
&& not (T.null lfNameText) |
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.
Do we actually generate definitions with an empty name? I thought that wasn’t even allowed in DAML-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.
I removed this check anyway :) It's back to being
not ("$" `T.isPrefixOf` LF.unExprValName lfName)
Not yet tested! changelog_begin changelog_end
-- typeclasses, so we can assume there are no old-style | ||
-- typeclasses being referenced. HOWEVER, we don't support | ||
-- type synonyms here yet. TODO: Fix this, and change | ||
-- the above to False. |
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.
Changing the line above to True
causes us to not expose functions that rely on new-style typeclass constraints, as well. This is a temporary measure, and once we support new-style typeclasses in data-dependencies (in a separate PR) we can change it back to False
.
I added a test based on 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.
Awesome, thanks a lot!
shouldExposeDefValue :: LF.DefValue -> Bool | ||
shouldExposeDefValue LF.DefValue{..} | ||
| (lfName, lfType) <- dvalBinder | ||
= not (LF.getIsTest dvalIsTest) |
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.
Is there actually a problem with exposing scenarios? I could see it being useful, e.g., if you have some function to initialize the state in scenarios you might want to use it across upgrades.
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'll expose them in a separate PR :)
defDataTypeIsOldTypeClass :: LF.DefDataType -> Bool | ||
defDataTypeIsOldTypeClass LF.DefDataType{..} | ||
| LF.DataRecord fields <- dataCons | ||
= notNull fields && all isDesugarField fields |
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.
Fun fact: We have typeclasses with no methods in daml-stdlib
which this will not hit but it should be fine to not handle that and I don’t see a reasonable way of detecting those.
stableDalfPkgMap <- useNoFile_ GenerateStablePackages | ||
pure (dalfPkgMap, stableDalfPkgMap) | ||
|
||
let allDalfPkgs = |
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.
Not necessary to address this in this PR but some type signatures for these maps might be nice.
Now with tests!
changelog_begin
changelog_end
Pull Request Checklist
CHANGELOG_BEGIN
andCHANGELOG_END
tagsNOTE: 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.