Quantcast

[GHC] #6062: TH treats non-functions in function position inconsistently

classic Classic list List threaded Threaded
3 messages Options
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GHC] #6062: TH treats non-functions in function position inconsistently

GHC
#6062: TH treats non-functions in function position inconsistently
------------------------------+---------------------------------------------
 Reporter:  heisenbug         |          Owner:                  
     Type:  bug               |         Status:  new            
 Priority:  normal            |      Component:  Compiler        
  Version:  7.5               |       Keywords:                  
       Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown      |       Testcase:                  
Blockedby:                    |       Blocking:                  
  Related:                    |  
------------------------------+---------------------------------------------
 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.

--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6062>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #6062: TH treats non-functions in function position inconsistently

GHC
#6062: TH treats non-functions in function position inconsistently
---------------------------------+------------------------------------------
    Reporter:  heisenbug         |       Owner:                  
        Type:  bug               |      Status:  new            
    Priority:  normal            |   Milestone:                  
   Component:  Compiler          |     Version:  7.5            
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by simonpj):

  * difficulty:  => Unknown


Comment:

 Read:
 [http://hackage.haskell.org/trac/ghc/blog/Template%20Haskell%20Proposal]
 which tackles precisely the question you raise.

 I guess you are another customer for this work, which is (still) pending.

 Simon

--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6062#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
GHC
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GHC] #6062: TH treats non-functions in function position inconsistently

GHC
In reply to this post by GHC
#6062: TH treats non-functions in function position inconsistently
---------------------------------+------------------------------------------
    Reporter:  heisenbug         |       Owner:  simonpj        
        Type:  bug               |      Status:  new            
    Priority:  normal            |   Milestone:  7.8.1          
   Component:  Compiler          |     Version:  7.5            
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by igloo):

  * owner:  => simonpj
  * milestone:  => 7.8.1


--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6062#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Loading...