"Zero-argument" lambda expressions from pretty-print strangely
An amusing corner case of the language is that you can constructor lambdas with zero arguments using Template Haskell:
{-# 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
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |