When I try to use label
as the name of a field in a record, and try to reference it using a.label
syntax (via OverloadedRecordDot
), I get a parse error. If I use any other legal identifier name for the field, there's no parse error.
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}
module Scratch where
data A = A { label :: Int }
getLabel :: A -> Int
getLabel a = a.label
$ cabal build
cabal build
Build profile: -w ghc-9.2.2 -O1
In order, the following will be built (use -v for more details):
- scratch-0.1.0.0 (lib) (file src/Scratch.hs changed)
- scratch-0.1.0.0 (exe:scratch) (dependency rebuilt)
Preprocessing library for scratch-0.1.0.0..
Building library for scratch-0.1.0.0..
[1 of 1] Compiling Scratch ( src/Scratch.hs, /Users/ben/experiments/scratch/dist-newstyle/build/x86_64-osx/ghc-9.2.2/scratch-0.1.0.0/build/Scratch.o, /Users/ben/experiments/scratch/dist-newstyle/build/x86_64-osx/ghc-9.2.2/scratch-0.1.0.0/build/Scratch.dyn_o )
src/Scratch.hs:10:16: error: parse error on input ‘label’
|
10 | getLabel a = a.label
| ^^^^^
cabal: Failed to build scratch-0.1.0.0 (which is required by exe:scratch from
scratch-0.1.0.0).
I expect the code to compile and for there to be no parse error.
Optional:
Oops. Seems to be, sorry!
When I try to use label
as the name of a field in a record, and try to reference it using a.label
syntax (via OverloadedRecordDot
), I get a parse error. If I use any other legal identifier name for the field, there's no parse error.
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}
module Scratch where
data A = A { label :: Int }
getLabel :: A -> Int
getLabel a = a.label
$ cabal build
cabal build
Build profile: -w ghc-9.2.2 -O1
In order, the following will be built (use -v for more details):
- scratch-0.1.0.0 (lib) (file src/Scratch.hs changed)
- scratch-0.1.0.0 (exe:scratch) (dependency rebuilt)
Preprocessing library for scratch-0.1.0.0..
Building library for scratch-0.1.0.0..
[1 of 1] Compiling Scratch ( src/Scratch.hs, /Users/ben/experiments/scratch/dist-newstyle/build/x86_64-osx/ghc-9.2.2/scratch-0.1.0.0/build/Scratch.o, /Users/ben/experiments/scratch/dist-newstyle/build/x86_64-osx/ghc-9.2.2/scratch-0.1.0.0/build/Scratch.dyn_o )
src/Scratch.hs:10:16: error: parse error on input ‘label’
|
10 | getLabel a = a.label
| ^^^^^
cabal: Failed to build scratch-0.1.0.0 (which is required by exe:scratch from
scratch-0.1.0.0).
I expect the code to compile and for there to be no parse error.
Optional: