Ticket #3415 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

Peculiar anomaly with record style data types and deriving Read

Reported by: DinoMorelli Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.10.4
Keywords: Cc:
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

-- Given this data type

data Foo = Foo { foo :: Int } deriving (Read, Show)

-- this fails

bar :: Foo

bar = read "Foo 42"

-- However, non-record-style construction is allowed:

baz :: Foo

baz = Foo 42

Change History

Changed 4 years ago by igloo

  • status changed from new to closed
  • difficulty set to Unknown
  • resolution set to invalid

Thanks for the report; however, this is not a bug.

The  Haskell Report, section 10.4 says

If the constructor is defined using record syntax, the derived Read
will parse only the record-syntax form, and furthermore, the fields
must be given in the same order as the original declaration.
Note: See TracTickets for help on using tickets.