Ticket #1240 (closed bug: invalid)

Opened 6 years ago

Last modified 6 years ago

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

Changed 6 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?

Changed 6 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 |] )

Changed 6 years ago by igloo

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

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.