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

Change placeholder unit viewtypes to empty records #14656

Merged
merged 15 commits into from
Aug 10, 2022
Merged

Conversation

dylant-da
Copy link
Contributor

No description provided.

@dylant-da dylant-da force-pushed the non-unit-viewtypes branch from 006e7dd to 9795f46 Compare August 9, 2022 15:32
@dylant-da dylant-da requested review from cocreature and removed request for ray-roestenburg-da August 10, 2022 13:23
Copy link
Collaborator

@remyhaemmerle-da remyhaemmerle-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@@ -7,9 +7,11 @@ module Interface where

import DA.Assert ((===))

data EmptyInterfaceView = EmptyInterfaceView
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This declares an enum, not a record, so it should be

Suggested change
data EmptyInterfaceView = EmptyInterfaceView
data EmptyInterfaceView = EmptyInterfaceView {}

You can tell because the desugared version of this declaration has the "stupid theta" GHC.Types.DamlEnum:

data GHC.Types.DamlEnum => EmptyInterfaceView = EmptyInterfaceView

Tangentially, I had a vague memory of the compiler failing with data declarations like this one, suggesting to make it explicitly a record with empty braces or explicitly a variant with empty parens. The docs do mention this restriction, but I wasn't able to replicate it even with sdk-version: 1.14.0 - turns out this restriction was removed in 0.13.33 (2019-11-06)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Digging a bit more, that is the reason for the GHC.Types.DamlEnum stupid theta: it's only used for single-constructor enums to differentiate them from variants and records, while enums with more constructors don't need it, see #3345

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced all using sed -i 's/data EmptyInterfaceView = EmptyInterfaceView/data EmptyInterfaceView = EmptyInterfaceView {}/' $(ag 'data EmptyInterfaceView = EmptyInterfaceView' -l), fingers crossed

Copy link
Contributor

@akrmn akrmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve the idea behind this PR but to meet the requirement that an interface viewtype must be a record you will need to change the EmptyInterfaceView data declarations to make them explicitly records, otherwise the compiler will treat them as enums.

Hopefully it should be enough to search and replace s/(data EmptyInterfaceView = EmptyInterfaceView)/$1 {}/ and then refresh the golden files.

@dylant-da
Copy link
Contributor Author

Hopefully it should be enough to search and replace

fingers crossed!

Copy link
Contributor

@carrielaben-da carrielaben-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on the documentation end.

@dylant-da dylant-da enabled auto-merge (squash) August 10, 2022 14:41
@dylant-da dylant-da merged commit 0d37134 into main Aug 10, 2022
@dylant-da dylant-da deleted the non-unit-viewtypes branch August 10, 2022 16:45
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.

4 participants