6.5.1. Traditional record syntax¶
-
NoTraditionalRecordSyntax
¶ Since: 7.4.1 Disallow use of record syntax.
Traditional record syntax, such as C {f = x}
, is enabled by default.
To disable it, you can use the NoTraditionalRecordSyntax
extension.
Under NoTraditionalRecordSyntax
, it is not permitted to define a
record datatype or use record syntax in an expression. For example, the
following all require TraditionalRecordSyntax
:
data T = MkT { foo :: Int } -- record datatype definition
x = MkT { foo = 3 } -- construction
y = x { foo = 3 } -- update
f (MkT { foo = i }) = i -- pattern matching
However, if a field selector function is in scope, it may be used normally.
(This arises if a module using NoTraditionalRecordSyntax
imports a
module that defined a record with TraditionalRecordSyntax
enabled).
If you wish to suppress field selector functions, use the
NoFieldSelectors
extension.