Opened 7 years ago

Closed 7 years ago

#1240 closed bug (invalid)

Template Haskell only accepts semicolons not newlines in data declaration quotations

Reported by: greenrd@… Owned by:
Priority: low Milestone:
Component: Template Haskell Version: 6.6
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

GHC 6.6 rejects a declaration quotation (i.e. [|d ... |]) containing multiple lines, but it accepts it if you change all newlines to semicolons. The latter makes code harder to read.

Change History (3)

comment:1 Changed 7 years ago by igloo

You can certainly say something like this:

import Language.Haskell.TH

$( do ds <- [d|
                foo = 'a'
                bar = 'b'
              |]
      runIO $ putStrLn $ pprint ds
      return ds
 )

Have you got an example that doesn't work how you'd expect?

comment:2 Changed 7 years ago by greenrd

  • Summary changed from Template Haskell only accepts semicolons not newlines in declaration quotations to Template Haskell only accepts semicolons not newlines in data declaration quotations

Woops, I knew I should have attached a test case.

$(id [d|data Foo
data Bar |] )

comment:3 Changed 7 years ago by igloo

  • Resolution set to invalid
  • Status changed from new to closed

That code has incorrect layout. Similarly, with plain old Haskell,

    data Foo
data Bar

would be rejected. All the declarations need to be aligned (or use explicit braces and semi-colons, as you said).

Thanks

Ian

Note: See TracTickets for help on using tickets.