[GHC] #13856: "Zero-argument" lambda expressions from pretty-print strangely
GHC
ghc-devs at haskell.org
Wed Jun 21 16:35:50 UTC 2017
#13856: "Zero-argument" lambda expressions from pretty-print strangely
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template | Version: 8.0.1
Haskell |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
An amusing corner case of the language is that you can constructor lambdas
with zero arguments using Template Haskell:
{{{#!hs
{-# LANGUAGE TemplateHaskell #-}
import Language.Haskell.TH
f :: Int
f = $(lamE [] [| 42 |])
}}}
But if you try to compile that with `-ddump-splices` on, it'll look quite
funny:
{{{
$ /opt/ghc/8.2.1/bin/ghci Bug.hs -ddump-splices
GHCi, version 8.2.0.20170616: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Main ( Bug.hs, interpreted )
Bug.hs:6:7-22: Splicing expression lamE [] [| 42 |] ======> \ -> 42
Ok, modules loaded: Main.
}}}
Oh dear, `\ -> 42` isn't a valid expression at all. The same thing happens
with the Template Haskell pretty-printer:
{{{
λ> import Language.Haskell.TH
λ> :set -XTemplateHaskell
λ> putStrLn $(lamE [] [| 42 |] >>= stringE . pprint)
<interactive>:4:12-48: Splicing expression
lamE [] [| 42 |] >>= stringE . pprint ======> "\ -> 42"
\ -> 42
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13856>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list