GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:37:54Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/10019GHCi cannot reify a custom data constructor with Template Haskell on the firs...2019-07-07T18:37:54ZRyan ScottGHCi cannot reify a custom data constructor with Template Haskell on the first attemptI've uncovered an unusual bug with Template Haskell inside of GHCi. To duplicate it, load GHCi, create a data type, then attempt to reify one of its constructors. It will fail the first time, but succeed the second time.
```
$ ghci -XTe...I've uncovered an unusual bug with Template Haskell inside of GHCi. To duplicate it, load GHCi, create a data type, then attempt to reify one of its constructors. It will fail the first time, but succeed the second time.
```
$ ghci -XTemplateHaskell
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> import Language.Haskell.TH
λ> data Option a = Some a | None
λ> $(reify 'Some >>= stringE . show)
Failed to load interface for ‘Ghci1’
no package matching ‘interactive’ was found
λ> $(reify 'Some >>= stringE . show)
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
"DataConI Ghci1.Some (ForallT [PlainTV a_1627392303] [] (AppT (AppT ArrowT (VarT a_1627392303)) (AppT (ConT Ghci1.Option) (VarT a_1627392303)))) Ghci1.Option (Fixity 9 InfixL)"
```
Curiously, this doesn't happen when you reify a data constructor in `base`, such as `Just`:
```
$ ghci -XTemplateHaskell
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
λ> import Language.Haskell.TH
λ> $(reify 'Just >>= stringE . show)
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
"DataConI Data.Maybe.Just (ForallT [PlainTV a_1627398816] [] (AppT (AppT ArrowT (VarT a_1627398816)) (AppT (ConT Data.Maybe.Maybe) (VarT a_1627398816)))) Data.Maybe.Maybe (Fixity 9 InfixL)"
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 7.8.4 |
| 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":"GHCi cannot reify a custom data constructor with Template Haskell on the first attempt","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.8.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I've uncovered an unusual bug with Template Haskell inside of GHCi. To duplicate it, load GHCi, create a data type, then attempt to reify one of its constructors. It will fail the first time, but succeed the second time.\r\n\r\n{{{\r\n$ ghci -XTemplateHaskell\r\nGHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help\r\nLoading package ghc-prim ... linking ... done.\r\nLoading package integer-gmp ... linking ... done.\r\nLoading package base ... linking ... done.\r\nλ> import Language.Haskell.TH\r\nλ> data Option a = Some a | None\r\nλ> $(reify 'Some >>= stringE . show)\r\nFailed to load interface for ‘Ghci1’\r\nno package matching ‘interactive’ was found\r\nλ> $(reify 'Some >>= stringE . show)\r\nLoading package array-0.5.0.0 ... linking ... done.\r\nLoading package deepseq-1.3.0.2 ... linking ... done.\r\nLoading package containers-0.5.5.1 ... linking ... done.\r\nLoading package pretty-1.1.1.1 ... linking ... done.\r\nLoading package template-haskell ... linking ... done.\r\n\"DataConI Ghci1.Some (ForallT [PlainTV a_1627392303] [] (AppT (AppT ArrowT (VarT a_1627392303)) (AppT (ConT Ghci1.Option) (VarT a_1627392303)))) Ghci1.Option (Fixity 9 InfixL)\"\r\n}}}\r\n\r\nCuriously, this doesn't happen when you reify a data constructor in {{{base}}}, such as {{{Just}}}:\r\n\r\n{{{\r\n$ ghci -XTemplateHaskell\r\nGHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help\r\nLoading package ghc-prim ... linking ... done.\r\nLoading package integer-gmp ... linking ... done.\r\nLoading package base ... linking ... done.\r\nλ> import Language.Haskell.TH\r\nλ> $(reify 'Just >>= stringE . show)\r\nLoading package array-0.5.0.0 ... linking ... done.\r\nLoading package deepseq-1.3.0.2 ... linking ... done.\r\nLoading package containers-0.5.5.1 ... linking ... done.\r\nLoading package pretty-1.1.1.1 ... linking ... done.\r\nLoading package template-haskell ... linking ... done.\r\n\"DataConI Data.Maybe.Just (ForallT [PlainTV a_1627398816] [] (AppT (AppT ArrowT (VarT a_1627398816)) (AppT (ConT Data.Maybe.Maybe) (VarT a_1627398816)))) Data.Maybe.Maybe (Fixity 9 InfixL)\"\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/9738Handle ANN pragmas in declaration splices2019-07-07T18:39:15ZRichard Eisenbergrae@richarde.devHandle ANN pragmas in declaration splicesIf I say
```
$( do decs <- [d| data T = MkT
{-# ANN type T "hi!" #-}
|]
runIO $ putStrLn $ pprint decs
return decs )
```
I get
```
data T_0 = MkT_1
```
No `ANN`. :(
<details><summary>Tra...If I say
```
$( do decs <- [d| data T = MkT
{-# ANN type T "hi!" #-}
|]
runIO $ putStrLn $ pprint decs
return decs )
```
I get
```
data T_0 = MkT_1
```
No `ANN`. :(
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 7.8.3 |
| 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":"Handle ANN pragmas in declaration splices","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"7.10.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"If I say\r\n\r\n{{{\r\n$( do decs <- [d| data T = MkT\r\n {-# ANN type T \"hi!\" #-}\r\n |]\r\n runIO $ putStrLn $ pprint decs\r\n return decs )\r\n}}}\r\n\r\nI get\r\n\r\n{{{\r\ndata T_0 = MkT_1\r\n}}}\r\n\r\nNo `ANN`. :(","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/9032Panic with self-import2019-07-07T18:42:13ZJan Stolarekjan.stolarek@ed.ac.ukPanic with self-importA test in the `singletons` package leads to a panic when run:
```
ghc: panic! (the 'impossible' happened)
(GHC version 7.8.2 for x86_64-unknown-linux):
tcIfaceGlobal (local): not found:
singletons-1.0:Singletons.Star.TFCo:...A test in the `singletons` package leads to a panic when run:
```
ghc: panic! (the 'impossible' happened)
(GHC version 7.8.2 for x86_64-unknown-linux):
tcIfaceGlobal (local): not found:
singletons-1.0:Singletons.Star.TFCo:R:DemoteRep*KProxy{tc r0}
[]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Edit: see [ticket:9032\#comment:83149](https://gitlab.haskell.org//ghc/ghc/issues/9032#note_83149) for a testcase.7.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/8807Variable constraints not handled properly in TH2019-07-07T18:43:21ZRichard Eisenbergrae@richarde.devVariable constraints not handled properly in THWhen I compile
```
{-# LANGUAGE TemplateHaskell, ConstraintKinds #-}
module Scratch where
import Data.Proxy
foo :: $( [t| a b => Proxy a -> b -> b |] )
foo = undefined
```
I get
```
Illegal type constructor or class name: ‛a’
...When I compile
```
{-# LANGUAGE TemplateHaskell, ConstraintKinds #-}
module Scratch where
import Data.Proxy
foo :: $( [t| a b => Proxy a -> b -> b |] )
foo = undefined
```
I get
```
Illegal type constructor or class name: ‛a’
When splicing a TH type:
forall a_0 b_1 . a_0 b_1 => Data.Proxy.Proxy a_0 -> b_1 -> b_1
In the splice: $([t| a b => Proxy a -> b -> b |])
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 7.9 |
| 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":"Variable constraints not handled properly in TH","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"7.10.1","resolution":"Unresolved","owner":{"tag":"OwnedBy","contents":"goldfire"},"version":"7.9","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"When I compile\r\n\r\n{{{\r\n{-# LANGUAGE TemplateHaskell, ConstraintKinds #-}\r\n\r\nmodule Scratch where\r\n\r\nimport Data.Proxy\r\n\r\nfoo :: $( [t| a b => Proxy a -> b -> b |] )\r\nfoo = undefined\r\n}}}\r\n\r\nI get\r\n\r\n{{{\r\n Illegal type constructor or class name: ‛a’\r\n When splicing a TH type:\r\n forall a_0 b_1 . a_0 b_1 => Data.Proxy.Proxy a_0 -> b_1 -> b_1\r\n In the splice: $([t| a b => Proxy a -> b -> b |])\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1Richard Eisenbergrae@richarde.devRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/7863Verbosity level for quieter Template Haskell2019-07-07T18:47:46ZdolioVerbosity level for quieter Template HaskellIn projects with large numbers of dependencies, use of template haskell can cause very large amounts of output that aren't particularly interesting. However, it seems that the only verbosity level that quiets template haskell output is -...In projects with large numbers of dependencies, use of template haskell can cause very large amounts of output that aren't particularly interesting. However, it seems that the only verbosity level that quiets template haskell output is -v0, which also turns off normal indications of build progress. It would be pleasant to have a way to turn off template haskell loading messages while retaining the rest of -v1 output.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 7.6.3 |
| Type | FeatureRequest |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Verbosity level for quieter Template Haskell","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.6.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"FeatureRequest","description":"In projects with large numbers of dependencies, use of template haskell can cause very large amounts of output that aren't particularly interesting. However, it seems that the only verbosity level that quiets template haskell output is -v0, which also turns off normal indications of build progress. It would be pleasant to have a way to turn off template haskell loading messages while retaining the rest of -v1 output.","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1Herbert Valerio Riedelhvr@gnu.orgHerbert Valerio Riedelhvr@gnu.orghttps://gitlab.haskell.org/ghc/ghc/-/issues/7484Template Haskell allows building invalid record fields/names2019-07-07T18:49:32ZIustin Popiustin@k1024.orgTemplate Haskell allows building invalid record fields/namesThis is not really a bug, more like a unintuitive behaviour.
Due to a bug in my definitions, I was passing a name like `"opTestDelay "` (note extra space) to a TH splice builder, which ended up with:
```
data OpCode
= OpTestDelay {op...This is not really a bug, more like a unintuitive behaviour.
Due to a bug in my definitions, I was passing a name like `"opTestDelay "` (note extra space) to a TH splice builder, which ended up with:
```
data OpCode
= OpTestDelay {opDelayDuration :: Double,
opDelayOnMaster :: Bool,
opDelayOnNodes :: [Ganeti.Types.NonEmptyString],
opDelayRepeat :: Ganeti.Types.NonNegative Int}
```
Note the double space around the first record field. This results in the actual accessor functions having the space in the name, which makes them unusable from normal code.
This seems to be allowed as well in other TH constructs:
```
λ> runQ $ return (ValD (VarP (mkName "a ") ) (NormalB (LitE (IntegerL 5))) [])
ValD (VarP a ) (NormalB (LitE (IntegerL 5))) []
```
I think that names should not be allowed to contain invalid identifiers (that would make them non-usable in normal Haskell code), but I'm not sure - maybe TH is designed to allow you to shoot yourself in the foot indeed. Anyway, opening this bug just in case.
Tested and behaves the same both on 6.12 and 7.6.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 7.6.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":"Template Haskell allows building invalid record fields/names","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This is not really a bug, more like a unintuitive behaviour.\r\n\r\nDue to a bug in my definitions, I was passing a name like `\"opTestDelay \"` (note extra space) to a TH splice builder, which ended up with:\r\n\r\n{{{\r\ndata OpCode\r\n = OpTestDelay {opDelayDuration :: Double,\r\n opDelayOnMaster :: Bool,\r\n opDelayOnNodes :: [Ganeti.Types.NonEmptyString],\r\n opDelayRepeat :: Ganeti.Types.NonNegative Int}\r\n}}}\r\n\r\nNote the double space around the first record field. This results in the actual accessor functions having the space in the name, which makes them unusable from normal code.\r\n\r\nThis seems to be allowed as well in other TH constructs:\r\n\r\n{{{\r\nλ> runQ $ return (ValD (VarP (mkName \"a \") ) (NormalB (LitE (IntegerL 5))) [])\r\nValD (VarP a ) (NormalB (LitE (IntegerL 5))) []\r\n}}}\r\n\r\nI think that names should not be allowed to contain invalid identifiers (that would make them non-usable in normal Haskell code), but I'm not sure - maybe TH is designed to allow you to shoot yourself in the foot indeed. Anyway, opening this bug just in case.\r\n\r\nTested and behaves the same both on 6.12 and 7.6.","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1https://gitlab.haskell.org/ghc/ghc/-/issues/7200template-haskell-2.7.0.0 fails to build with GHC 7.0.4 due to missing pragma2019-07-07T18:50:53Ztibbetemplate-haskell-2.7.0.0 fails to build with GHC 7.0.4 due to missing pragmaIt looks like there's a missing pragma:
```
[1 of 7] Compiling Language.Haskell.TH.Syntax.Internals ( Language/Haskell/TH/Syntax/Internals.hs, dist/build/Language/Haskell/TH/Syntax/Internals.o )
[2 of 7] Compiling Language.Haskell.TH.Sy...It looks like there's a missing pragma:
```
[1 of 7] Compiling Language.Haskell.TH.Syntax.Internals ( Language/Haskell/TH/Syntax/Internals.hs, dist/build/Language/Haskell/TH/Syntax/Internals.o )
[2 of 7] Compiling Language.Haskell.TH.Syntax ( Language/Haskell/TH/Syntax.hs, dist/build/Language/Haskell/TH/Syntax.o )
[3 of 7] Compiling Language.Haskell.TH.PprLib ( Language/Haskell/TH/PprLib.hs, dist/build/Language/Haskell/TH/PprLib.o )
Language/Haskell/TH/PprLib.hs:55:10:
Illegal instance declaration for `Show Doc'
(All instance types must be of the form (T t1 ... tn)
where T is not a synonym.
Use -XTypeSynonymInstances if you want to disable this.)
In the instance declaration for `Show Doc'
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 7.0.4 |
| 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":"template-haskell-2.7.0.0 fails to build with GHC 7.0.4 due to missing pragma","status":"New","operating_system":"","component":"Template Haskell","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.0.4","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"It looks like there's a missing pragma:\r\n\r\n{{{\r\n[1 of 7] Compiling Language.Haskell.TH.Syntax.Internals ( Language/Haskell/TH/Syntax/Internals.hs, dist/build/Language/Haskell/TH/Syntax/Internals.o )\r\n[2 of 7] Compiling Language.Haskell.TH.Syntax ( Language/Haskell/TH/Syntax.hs, dist/build/Language/Haskell/TH/Syntax.o )\r\n[3 of 7] Compiling Language.Haskell.TH.PprLib ( Language/Haskell/TH/PprLib.hs, dist/build/Language/Haskell/TH/PprLib.o )\r\n\r\nLanguage/Haskell/TH/PprLib.hs:55:10:\r\n Illegal instance declaration for `Show Doc'\r\n (All instance types must be of the form (T t1 ... tn)\r\n where T is not a synonym.\r\n Use -XTypeSynonymInstances if you want to disable this.)\r\n In the instance declaration for `Show Doc'\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1duncanduncanhttps://gitlab.haskell.org/ghc/ghc/-/issues/1476Template Haskell: splicing types and patterns2019-07-07T19:13:23ZIan Lynagh <igloo@earth.li>Template Haskell: splicing types and patternsIn http://www.haskell.org/pipermail/template-haskell/2003-February/000021.html Simon Peyton Jones writes:
```
We claim to allow you to write splices in (a) types and (b) patterns.
I'm very dubious about (b). Consider]
x = 4
...In http://www.haskell.org/pipermail/template-haskell/2003-February/000021.html Simon Peyton Jones writes:
```
We claim to allow you to write splices in (a) types and (b) patterns.
I'm very dubious about (b). Consider]
x = 4
y :: Patt
y = [p| ... |]
f $y = x
Question: where is x bound? It looks as though x can be bound by the
spliced-in pattern or by the top-level binding. You can't tell without
knowing what $y expands to. We argue in our paper against non-top-level
declaration splices because that would lead to ambiguity of exactly this
sort.
It turns out that it's very inconvenient to implement pattern splices in
GHC, for exactly this reason. We can't figure out the binding structure
till we expand the splice. We can't expand the splice till typechecking
time. But the renamer currently fixes the binding structure before type
checking. Changing this would be a big upheaval.
Conclusion: pattern splices are hard to implement, and dubious from a
programming point of view. I propose to drop them, for now at least.
Type splices have some similar echoes. Consider
y :: Type
y = [t| a -> a |]
f :: $y
What is f polymorphic in? The trouble concerns Haskell's implicit
quantification. I guess there are three possibilities:
a) $y expands to "a -> a", and that is implicitly universally quantified
to "forall a. a->a".
b) The implicit quantification happens at the [t| ...|] brackets, so
that $y expands to
"forall a. a->a"
c) $y expands to "a -> a" with no implicit quantification anywhere.
I'm pretty sure that we should adopt (b). After all, we want a
lexical-scoping rule for TH, so we have to say where 'a' is bound.
That would still in principle allow
y :: Type
y = return (Tvar "a" `Arrow` Tvar "a")
Since it's the renamer that does implicit quantification, it'd be quite
awkward to make the implicit quantification at the splice site "see" the
free variables 'a'.
The link with the pattern stuff is this. If you see
f :: $y -> b
then what are the implicit for-alls? My answer: the implicit for-alls
are just for "b", not for any free vars of $y.
```
Since then, the only solution for pattern splices I recall seeing is
```
f ${x,z}y = x
```
which asserts that the splice introduces the set of identifiers `{x,z}`.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ---------------- |
| Version | 6.6.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Template Haskell |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | Unknown |
| Architecture | Unknown |
</details>
<!-- {"blocked_by":[],"summary":"Template Haskell: splicing types and patterns","status":"New","operating_system":"Unknown","component":"Template Haskell","related":[],"milestone":"6.10 branch","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"6.6.1","keywords":[],"differentials":[],"test_case":"","architecture":"Unknown","cc":[""],"type":"Bug","description":"In http://www.haskell.org/pipermail/template-haskell/2003-February/000021.html Simon Peyton Jones writes:\r\n{{{\r\nWe claim to allow you to write splices in (a) types and (b) patterns.\r\nI'm very dubious about (b). Consider]\r\n x = 4\r\n \r\n y :: Patt \r\n y = [p| ... |]\r\n\r\n f $y = x\r\n\r\nQuestion: where is x bound? It looks as though x can be bound by the\r\nspliced-in pattern or by the top-level binding. You can't tell without\r\nknowing what $y expands to. We argue in our paper against non-top-level\r\ndeclaration splices because that would lead to ambiguity of exactly this\r\nsort.\r\n\r\nIt turns out that it's very inconvenient to implement pattern splices in\r\nGHC, for exactly this reason. We can't figure out the binding structure\r\ntill we expand the splice. We can't expand the splice till typechecking\r\ntime. But the renamer currently fixes the binding structure before type\r\nchecking. Changing this would be a big upheaval.\r\n\r\nConclusion: pattern splices are hard to implement, and dubious from a\r\nprogramming point of view. I propose to drop them, for now at least.\r\n\r\n\r\nType splices have some similar echoes. Consider\r\n \r\n y :: Type \r\n y = [t| a -> a |]\r\n\r\n f :: $y\r\n\r\nWhat is f polymorphic in? The trouble concerns Haskell's implicit\r\nquantification. I guess there are three possibilities:\r\n\r\na) $y expands to \"a -> a\", and that is implicitly universally quantified\r\nto \"forall a. a->a\".\r\nb) The implicit quantification happens at the [t| ...|] brackets, so\r\nthat $y expands to\r\n \"forall a. a->a\"\r\nc) $y expands to \"a -> a\" with no implicit quantification anywhere.\r\n\r\nI'm pretty sure that we should adopt (b). After all, we want a\r\nlexical-scoping rule for TH, so we have to say where 'a' is bound.\r\n\r\nThat would still in principle allow\r\n \r\n y :: Type\r\n y = return (Tvar \"a\" `Arrow` Tvar \"a\")\r\n\r\nSince it's the renamer that does implicit quantification, it'd be quite\r\nawkward to make the implicit quantification at the splice site \"see\" the\r\nfree variables 'a'.\r\n\r\nThe link with the pattern stuff is this. If you see\r\n f :: $y -> b\r\n\r\nthen what are the implicit for-alls? My answer: the implicit for-alls\r\nare just for \"b\", not for any free vars of $y.\r\n}}}\r\n\r\nSince then, the only solution for pattern splices I recall seeing is\r\n{{{\r\nf ${x,z}y = x\r\n}}}\r\nwhich asserts that the splice introduces the set of identifiers `{x,z}`.","type_of_failure":"OtherFailure","blocking":[]} -->7.10.1