OverloadedRecordDot: "type" can't be used as a field name
Summary
- I cannot use "type" as a field name.
- Looks like same problem as #21226 (closed) #20723 (closed) but looks like it didn't fix the problem for all others reserved keywords in
reservedid
Steps to reproduce
Given following code:
{-# LANGUAGE OverloadedRecordDot, DataKinds #-}
module Main where
import GHC.Records ( HasField(..) )
data Product = Product
{ prodName :: String
, prodType :: String
}
sampleProduct :: Product
sampleProduct = Product "Foo" "Sport"
instance HasField "type" Product String where
getField :: Product -> String
getField = prodType
main :: IO ()
main = putStrLn sampleProduct.type
I got compilation error:
[1 of 2] Compiling Main ( main.hs, main.o ) [Source file changed]
main.hs:19:31: error: [GHC-58481] parse error on input ‘type’
|
19 | main = putStrLn sampleProduct.type
Expected behavior
Compile and run successfully.
Environment
- GHC version used: 9.6.3
Optional:
- Operating System: MacOS-14.4
- System Architecture: