Skip to content

HExp missing record selectors #419

Open
@aavogt

Description

@aavogt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions