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

What type role should NF's parameter have? #3

Closed
treeowl opened this issue Jul 21, 2016 · 3 comments
Closed

What type role should NF's parameter have? #3

treeowl opened this issue Jul 21, 2016 · 3 comments

Comments

@treeowl
Copy link
Collaborator

treeowl commented Jul 21, 2016

Currently, we let GHC infer

type role NF representational

I think there's a minor potential problem here. Suppose we have

data T = ...
newtype U = U T

instance NFData T where ...
instance NFData U where ... -- Something *different*

We can coerce from NF T (which is in T-normal form) to NF U (which claims to be in U-normal form). It's not quite clear to me whose problem this is. Should whoever defined U be expected to hide its constructor? Or should we have type role NF nominal?

In practice, I suspect this to come up rather rarely, since types are generally expected to have just one notion of normal form, but there could be exceptions out there.

@ezyang
Copy link
Owner

ezyang commented Jul 21, 2016

Hey @treeowl, I added you to the repo. I think nominal is more correct, so feel free to commit this change.

@treeowl
Copy link
Collaborator Author

treeowl commented Jul 21, 2016

@ezyang, thanks! I don't really feel strongly about it, but it seems to be the safer choice.

treeowl added a commit to treeowl/nf that referenced this issue Jul 21, 2016
Also add `nfCoercion` to work around the role annotation as
needed.

Fixes ezyang#3
@treeowl
Copy link
Collaborator Author

treeowl commented Jul 21, 2016

@ezyang, I opened up a pull request for this. I also added a coercion to work around the role annotation locally. For now, I put it in a separate Data.NF.Coercion module. Does that make sense to you, or should it go in Data.NF?

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

No branches or pull requests

2 participants