tweag / HaskellR

The full power of R in Haskell.

Home Page:https://tweag.github.io/HaskellR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HExp missing record selectors

aavogt opened this issue · comments

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