Skip to content
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

Merged
13 commits merged into from
Jan 27, 2020
Merged

Converting functions in data dependencies. #4182

13 commits merged into from
Jan 27, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jan 23, 2020

Now with tests!

changelog_begin
changelog_end

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

@ghost ghost requested a review from cocreature January 23, 2020 14:28
@ghost ghost requested a review from hurryabit as a code owner January 23, 2020 14:28
Copy link
Contributor

@cocreature cocreature left a 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
Copy link
Contributor

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.

Copy link
Author

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. 😅

@digitalasset-cla
Copy link
Member

digitalasset-cla commented Jan 24, 2020

CLA assistant check
All committers have signed the CLA.

| (lfName, lfType) <- dvalBinder
, lfNameText <- LF.unExprValName lfName
= not (LF.getIsTest dvalIsTest)
&& not (T.null lfNameText)
Copy link
Contributor

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.

Copy link
Author

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)

@ghost ghost force-pushed the data-dep-fns branch from d653f45 to ed61993 Compare January 24, 2020 15:36
-- 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.
Copy link
Author

@ghost ghost Jan 24, 2020

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.

@ghost
Copy link
Author

ghost commented Jan 25, 2020

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.

I added a test based on this comment :-)

Copy link
Contributor

@cocreature cocreature left a 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)
Copy link
Contributor

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.

Copy link
Author

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
Copy link
Contributor

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 =
Copy link
Contributor

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.

@ghost ghost merged commit 3c93b5e into master Jan 27, 2020
@ghost ghost deleted the data-dep-fns branch January 27, 2020 10:05
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants