[GHC] #4230: Template Haskell: less type checking in quotations?

GHC cvs-ghc at haskell.org
Wed May 8 22:18:05 CEST 2013


#4230: Template Haskell: less type checking in quotations?
---------------------------------+------------------------------------------
    Reporter:  simonpj           |       Owner:                              
        Type:  feature request   |      Status:  new                         
    Priority:  low               |   Milestone:  7.6.2                       
   Component:  Compiler          |     Version:  7.6.3                       
    Keywords:                    |          Os:  Unknown/Multiple            
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown                
  Difficulty:                    |    Testcase:                              
   Blockedby:                    |    Blocking:  4124, 4125, 4128, 4135, 4170
     Related:                    |  
---------------------------------+------------------------------------------
Changes (by carter):

  * version:  6.12.3 => 7.6.3


Comment:

 One use case / example /motivation  I  encountered this week is the
 following:

 To make the LLVM-Base library work with cabal versions 1.16 and cabal
 head,  I wanted to  write the following code

 {{{
 --- what i'd like to write, but can't because template haskell rejecting
 the branch that has the wrong api version
 extractCLBI x=
     $(if cabalVersion >= Version [1,17,0] []
         then [|  getComponentLocalBuildInfo 'x CLibName  |]
         else  [|      let   LocalBuildInfo  { libraryConfig = Just clbi }
 = 'x in clbi |]
    )

 }}}

 {{{
 --- horrible hack to support cabal versions both above and below 1.17
 extractCLBI x=
     $(if cabalVersion >= Version [1,17,0] []
         then  appE (appE  ( varE $ mkName "getComponentLocalBuildInfo") (
 varE 'x) ) (conE ( mkName "CLibName"))

         else  letE
                 [valD  (recP
                             (mkName "LocalBuildInfo" )
                             [fieldPat (mkName "libraryConfig")
                              (conP (mkName "Just")    [varP $ mkName
 "clbi"] ) ] )
                     (normalB $ varE 'x)   []    ]
                  (varE $ mkName "clbi")  )
 }}}

 In this case, I need to explicitly write out the AST so that template
 haskell doesn't barf.

 Would one near term solution  be to

  1. do the harmonization between haskell-src-exts and TH (as suggested /
 discussed elsewhere)
  2. provide untypedExp, Dec, etc quasiquoters ?


 this would be a pretty happy balance of allowing both the stronger and
 weaker typings, and might be a reasonable first step towards actually
 working on MetaHaskell

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



More information about the ghc-tickets mailing list