GHC issues
https://gitlab.haskell.org/ghc/ghc/-/issues
2019-07-07T18:20:07Z
https://gitlab.haskell.org/ghc/ghc/-/issues/13776
-ddump-splices produces unnecessarily qualified names for tuple and list types
2019-07-07T18:20:07Z
Ryan Scott
-ddump-splices produces unnecessarily qualified names for tuple and list types
If you compile this:
```hs
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where
import Language.Haskell.TH
f :: $(conT ''(,) `appT` conT ''Int `appT` conT ''Int)
f = (1,2)
g :: $(conT ''[] `appT` conT ...
If you compile this:
```hs
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where
import Language.Haskell.TH
f :: $(conT ''(,) `appT` conT ''Int `appT` conT ''Int)
f = (1,2)
g :: $(conT ''[] `appT` conT ''Int)
g = []
```
You'll get some unsavory output:
```
Bug.hs:10:8-34: Splicing type
conT ''[] `appT` conT ''Int ======> GHC.Types.[] Int
Bug.hs:7:8-53: Splicing type
conT ''(,) `appT` conT ''Int `appT` conT ''Int
======>
GHC.Tuple.(,) Int Int
```
It's unsavory because if you actually try to use the spliced output in Haskell code:
```hs
module Bug2 where
f :: GHC.Tuple.(,) Int Int
f = (1,2)
g :: GHC.Types.[] Int
g = []
```
Then it won't parse.
Expressions have the same problem:
```hs
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug3 where
import Language.Haskell.TH
f :: (Int, Int)
f = $(conE '(,) `appE` litE (integerL 1) `appE` litE (integerL 1))
g :: [Int]
g = $(conE '[])
```
```
Bug3.hs:8:7-65: Splicing expression
conE '(,) `appE` litE (integerL 1) `appE` litE (integerL 1)
======>
(GHC.Tuple.(,) 1) 1
Bug3.hs:11:7-14: Splicing expression conE '[] ======> GHC.Types.[]
```
And patterns:
```hs
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug4 where
import Language.Haskell.TH
f :: (Int, Int) -> ()
f $(conP '(,) [litP (integerL 1), litP (integerL 1)]) = ()
g :: [Int] -> ()
g $(conP '[] []) = ()
```
```
Bug4.hs:8:5-52: Splicing pattern
conP '(,) [litP (integerL 1), litP (integerL 1)]
======>
GHC.Tuple.(,) 1 1
Bug4.hs:11:5-15: Splicing pattern conP '[] [] ======> GHC.Types.[]
```
<details><summary>Trac metadata</summary>
| 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 | |
</details>
<!-- {"blocked_by":[],"summary":"-ddump-splices produces unnecessarily qualified names for tuple and list types","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":["newcomer"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If you compile this:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# OPTIONS_GHC -ddump-splices #-}\r\nmodule Bug where\r\n\r\nimport Language.Haskell.TH\r\n\r\nf :: $(conT ''(,) `appT` conT ''Int `appT` conT ''Int)\r\nf = (1,2)\r\n\r\ng :: $(conT ''[] `appT` conT ''Int)\r\ng = []\r\n}}}\r\n\r\nYou'll get some unsavory output:\r\n\r\n{{{\r\nBug.hs:10:8-34: Splicing type\r\n conT ''[] `appT` conT ''Int ======> GHC.Types.[] Int\r\nBug.hs:7:8-53: Splicing type\r\n conT ''(,) `appT` conT ''Int `appT` conT ''Int\r\n ======>\r\n GHC.Tuple.(,) Int Int\r\n}}}\r\n\r\nIt's unsavory because if you actually try to use the spliced output in Haskell code:\r\n\r\n{{{#!hs\r\nmodule Bug2 where\r\n\r\nf :: GHC.Tuple.(,) Int Int\r\nf = (1,2)\r\n\r\ng :: GHC.Types.[] Int\r\ng = []\r\n}}}\r\n\r\nThen it won't parse.\r\n\r\nExpressions have the same problem:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# OPTIONS_GHC -ddump-splices #-}\r\nmodule Bug3 where\r\n\r\nimport Language.Haskell.TH\r\n\r\nf :: (Int, Int)\r\nf = $(conE '(,) `appE` litE (integerL 1) `appE` litE (integerL 1))\r\n\r\ng :: [Int]\r\ng = $(conE '[])\r\n}}}\r\n\r\n{{{\r\nBug3.hs:8:7-65: Splicing expression\r\n conE '(,) `appE` litE (integerL 1) `appE` litE (integerL 1)\r\n ======>\r\n (GHC.Tuple.(,) 1) 1\r\nBug3.hs:11:7-14: Splicing expression conE '[] ======> GHC.Types.[]\r\n}}}\r\n\r\nAnd patterns:\r\n\r\n{{{#!hs\r\n{-# LANGUAGE TemplateHaskell #-}\r\n{-# OPTIONS_GHC -ddump-splices #-}\r\nmodule Bug4 where\r\n\r\nimport Language.Haskell.TH\r\n\r\nf :: (Int, Int) -> ()\r\nf $(conP '(,) [litP (integerL 1), litP (integerL 1)]) = ()\r\n\r\ng :: [Int] -> ()\r\ng $(conP '[] []) = ()\r\n}}}\r\n\r\n{{{\r\nBug4.hs:8:5-52: Splicing pattern\r\n conP '(,) [litP (integerL 1), litP (integerL 1)]\r\n ======>\r\n GHC.Tuple.(,) 1 1\r\nBug4.hs:11:5-15: Splicing pattern conP '[] [] ======> GHC.Types.[]\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->
8.6.1
mrkgnao
mrkgnao