Skip to content

HasField should allow unlifted record fields

If I say

data Rec = MkRec { field :: Int# }

I should be able to write

f :: Rec -> Int
f r = I# r.field

(with -XOverloadedRecordDot). But I get a kind error here. I think it would be somewhat straightforward to change HasField to be more general:

class HasField (label :: k) (record :: TYPE record_rep) (field :: field_rep) | label record -> field field_rep where
  getField :: record -> field

Surprises always lurk, but my instinct is that this would Just Work.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information