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

HExp missing record selectors #419

Open
aavogt opened this issue Aug 1, 2023 · 0 comments
Open

HExp missing record selectors #419

aavogt opened this issue Aug 1, 2023 · 0 comments

Comments

@aavogt
Copy link

aavogt commented Aug 1, 2023

Language.R.HExp.HExp has a wrong comment: "Because this is in fact a GADT, the use of named record fields is not possible here. Named record fields give rise to functions for whom it is not possible to assign a reasonable type (existentially quantified type variables would escape)."
Ghc does in fact have some support for named fields of gads:

data Ty a where Con :: Num a => { tag :: a } -> Ty Int

f :: Ty a -> Ty a
f Con { tag = n } = Con { tag = n + 1 }

-- g = tag -- `g` being illegal doesn't make `f` and `Con` illegal

I suggest either (A) adding the selectors and removing the comment, or (B) changing the comment to:

Named record fields are not used here because they are too limited for GADTs. Specifically, selector functions are not produced. That is, f List{cons = x } = g x would be allowed, but f = g . cons would produce an error Cannot use record selector ‘cons’ as a function due to escaped type variables Probable fix: use pattern-matching syntax instead

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

1 participant