TH treats non-functions in function position inconsistently
I start GHCi like this:
```
~/bin/ghci -XTemplateHaskell
```
My aim is to use TH to rewrite certain application-looking (syntactically) constructs to semantically valid haskell code, that passes the type-checker (c.f. Conor McBride's "idiom brackets").
But I already fail at very simple things, because GHC seems to type-check the TH quotation's innards...
This works:
```
Prelude> :t [| id id |]
[| id id |]
:: Language.Haskell.TH.Syntax.Q Language.Haskell.TH.Syntax.Exp
```
This is also accepted, though it is clearly not typeable:
```
Prelude> :t [| 1 1 |]
[| 1 1 |]
:: Language.Haskell.TH.Syntax.Q Language.Haskell.TH.Syntax.Exp
```
Encouraged by this I try:
```
Prelude> :t [| False True |]
<interactive>:1:4:
Couldn't match expected type `Bool -> t0' with actual type `Bool'
The function `False' is applied to one argument,
but its type `Bool' has none
In the Template Haskell quotation [| False True |]
In the expression: [| False True |]
```
Bummer! Somehow the type-checker does get into business with "expressions" inside quotations.
I believe this is a bug, and a quotation should be built for `[| False True |]` in spite of `False True` not being typeable.
I know that using quasi-quotations I can build my own parser and rewrite engine around this, but that is a tad heavyweight for me and I'd like to understand the root of the above inconsistency and why the type checker gets active in some cases above, but not in others.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"TH treats non-functions in function position inconsistently","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"I start GHCi like this:\r\n{{{\r\n~/bin/ghci -XTemplateHaskell\r\n}}}\r\n\r\nMy aim is to use TH to rewrite certain application-looking (syntactically) constructs to semantically valid haskell code, that passes the type-checker (c.f. Conor McBride's \"idiom brackets\").\r\n\r\nBut I already fail at very simple things, because GHC seems to type-check the TH quotation's innards...\r\n\r\nThis works:\r\n{{{\r\nPrelude> :t [| id id |]\r\n[| id id |]\r\n :: Language.Haskell.TH.Syntax.Q Language.Haskell.TH.Syntax.Exp\r\n}}}\r\n\r\nThis is also accepted, though it is clearly not typeable:\r\n{{{\r\nPrelude> :t [| 1 1 |]\r\n[| 1 1 |]\r\n :: Language.Haskell.TH.Syntax.Q Language.Haskell.TH.Syntax.Exp\r\n}}}\r\n\r\nEncouraged by this I try:\r\n{{{\r\nPrelude> :t [| False True |]\r\n<interactive>:1:4:\r\n Couldn't match expected type `Bool -> t0' with actual type `Bool'\r\n The function `False' is applied to one argument,\r\n but its type `Bool' has none\r\n In the Template Haskell quotation [| False True |]\r\n In the expression: [| False True |]\r\n}}}\r\n\r\nBummer! Somehow the type-checker does get into business with \"expressions\" inside quotations.\r\n\r\nI believe this is a bug, and a quotation should be built for {{{[| False True |]}}} in spite of {{{False True}}} not being typeable.\r\n\r\nI know that using quasi-quotations I can build my own parser and rewrite engine around this, but that is a tad heavyweight for me and I'd like to understand the root of the above inconsistency and why the type checker gets active in some cases above, but not in others.","type_of_failure":"OtherFailure","blocking":[]} -->
issue