6.5.2. Traditional record syntax

TraditionalRecordSyntax
Since:

7.4.1

Status:

Enabled by default.

Allow traditional record syntax (e.g. C {f = x}).

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.

© 2002–2007 The University Court of the University of Glasgow. All rights reserved.
Licensed under the Glasgow Haskell Compiler License.
https://downloads.haskell.org/~ghc/9.12.1/docs/users_guide/exts/traditional_record_syntax.html