Skip to content

Template Haskell -ddump-splices lambda pretty printing bug

Parentheses are not placed around lambda expressions when dumping template haskell splices.

One strange thing about this bug is that it only occurs when using "-ddump-splices", and not when using Language.Haskell.TH.Ppr.pprint

x = mkName "x"

thb = QuasiQuoter (const [| $(return . LamE [VarP x] $ VarE x) . id |])
                  undefined undefined undefined 
ghci THPrettyBug.hs -ddump-splices -XQuasiQuotes
GHCi, version 7.2.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
[1 of 1] Compiling Main             ( THPrettyBug.hs, interpreted )
Ok, modules loaded: Main.
*Main> [thb| |]
Loading package pretty-1.1.0.0 ... linking ... done.
Loading package array-0.3.0.3 ... linking ... done.
Loading package containers-0.4.1.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
<interactive>:0:1-8: Splicing expression
    " " ======> (\ x -> x . id)

<interactive>:0:1:
    No instance for (Show (c0 -> c0))
      arising from a use of `print'
    Possible fix: add an instance declaration for (Show (c0 -> c0))
    In a stmt of an interactive GHCi command: print it
Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information