Quantcast

[GHC] #5854: TH: INLINABLE pragma support (patch)

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

[GHC] #5854: TH: INLINABLE pragma support (patch)

GHC
#5854: TH: INLINABLE pragma support (patch)
--------------------------------+-------------------------------------------
 Reporter:  mikhail.vorozhtsov  |          Owner:                  
     Type:  feature request     |         Status:  new            
 Priority:  normal              |      Component:  Template Haskell
  Version:  7.4.1               |       Keywords:                  
       Os:  Unknown/Multiple    |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown        |       Testcase:                  
Blockedby:                      |       Blocking:                  
  Related:                      |  
--------------------------------+-------------------------------------------
 I needed it for my [https://github.com/mvv/data-dword data-dword] library,
 so here it is:
 {{{
 GHCi, version 7.5.20120206: 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
 λ> (mapM_ print =<<) $ runQ [d| f1 = id; {-# NOINLINE f1 #-}; f2 = id; {-#
 INLINE f2 #-}; f3 = id; {-# INLINABLE f3 #-} |]
 Loading package array-0.3.0.3 ... linking ... done.
 Loading package deepseq-1.2.0.1 ... linking ... done.
 Loading package containers-0.4.2.0 ... linking ... done.
 Loading package pretty-1.1.1.0 ... linking ... done.
 Loading package template-haskell ... linking ... done.
 ValD (VarP f1_2) (NormalB (VarE GHC.Base.id)) []
 PragmaD (InlineP f1_2 (InlineSpec NoInline False Nothing))
 ValD (VarP f2_1) (NormalB (VarE GHC.Base.id)) []
 PragmaD (InlineP f2_1 (InlineSpec Inline False Nothing))
 ValD (VarP f3_0) (NormalB (VarE GHC.Base.id)) []
 PragmaD (InlineP f3_0 (InlineSpec Inlinable False Nothing))
 }}}
 The other way around:
 {{{
 {-# LANGUAGE UnicodeSyntax #-}

 module TH where

 import Language.Haskell.TH

 noInlineP ∷ Name → DecsQ
 noInlineP n = fmap return $ pragInlD n $ inlineSpecNoPhase NoInline False

 inlineP ∷ Name → DecsQ
 inlineP n = fmap return $ pragInlD n $ inlineSpecNoPhase Inline False

 inlinableP ∷ Name → DecsQ
 inlinableP n = fmap return $ pragInlD n $ inlineSpecNoPhase Inlinable
 False
 }}}
 {{{
 {-# LANGUAGE UnicodeSyntax #-}
 {-# LANGUAGE TemplateHaskell #-}

 import TH

 f1, f2, f3 ∷ α → α
 f1 = id
 f2 = id
 f3 = id

 $(noInlineP 'f1)
 $(inlineP 'f2)
 $(inlinableP 'f3)

 main = return ()
 }}}
 {{{
 $ ghc-stage2 -ddump-splices -fforce-recomp TH.hs Main.hs
 [1 of 2] Compiling TH               ( TH.hs, TH.o )
 [2 of 2] Compiling Main             ( Main.hs, Main.o )
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Loading package pretty-1.1.1.0 ... linking ... done.
 Loading package array-0.3.0.3 ... linking ... done.
 Loading package deepseq-1.2.0.1 ... linking ... done.
 Loading package containers-0.4.2.0 ... linking ... done.
 Loading package template-haskell ... linking ... done.
 Main.hs:1:1: Splicing declarations
     noInlineP 'f1
   ======>
     Main.hs:11:3-15
     {-# NOINLINE f1 #-}
 Main.hs:1:1: Splicing declarations
     inlineP 'f2
   ======>
     Main.hs:12:3-13
     {-# INLINE f2 #-}
 Main.hs:1:1: Splicing declarations
     inlinableP 'f3
   ======>
     Main.hs:13:3-16
     {-# INLINABLE[ALWAYS] f3 #-}
 Linking Main ...
 }}}
 Please review the patches.

--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5854>
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
star

Re: [GHC] #5854: TH: INLINABLE pragma support (patch)

GHC
#5854: TH: INLINABLE pragma support (patch)
--------------------------------+-------------------------------------------
 Reporter:  mikhail.vorozhtsov  |          Owner:                  
     Type:  feature request     |         Status:  patch          
 Priority:  normal              |      Component:  Template Haskell
  Version:  7.4.1               |       Keywords:                  
       Os:  Unknown/Multiple    |   Architecture:  Unknown/Multiple
  Failure:  None/Unknown        |       Testcase:                  
Blockedby:                      |       Blocking:                  
  Related:                      |  
--------------------------------+-------------------------------------------
Changes (by mikhail.vorozhtsov):

  * status:  new => patch


--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5854#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
star

Re: [GHC] #5854: TH: INLINABLE pragma support (patch)

GHC
In reply to this post by GHC
#5854: TH: INLINABLE pragma support (patch)
---------------------------------+------------------------------------------
  Reporter:  mikhail.vorozhtsov  |          Owner:                  
      Type:  feature request     |         Status:  closed          
  Priority:  normal              |      Milestone:                  
 Component:  Template Haskell    |        Version:  7.4.1          
Resolution:  fixed               |       Keywords:                  
        Os:  Unknown/Multiple    |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown        |     Difficulty:  Unknown        
  Testcase:                      |      Blockedby:                  
  Blocking:                      |        Related:                  
---------------------------------+------------------------------------------
Changes (by simonpj):

  * status:  patch => closed
  * difficulty:  => Unknown
  * resolution:  => fixed


Comment:

 Mikhail, I'm sorry this has taken so long, but I've now committed your
 changes more or less exactly as you offered them. Thanks!

 Simon

 To the compiler
 {{{
 commit b6bf6abe2b5729137391a88c8deb4cc7ed851375
 Author: Simon Peyton Jones <[hidden email]>
 Date:   Fri May 18 10:10:02 2012 +0100

     Allow INLINABLE pragmas in TH

     Thanks to mikhail.vorozhtsov for doing the work

  compiler/deSugar/DsMeta.hs |   55
 +++++++++++++++++++++++++++++++------------
  compiler/hsSyn/Convert.lhs |   11 ++++----
  2 files changed, 45 insertions(+), 21 deletions(-)
 }}}
 And in `template-haskell`:
 {{{
 commit 6c0b59b8d9db5ce12e5b566a2c3cf6889a00aca4
 Author: Simon Peyton Jones <[hidden email]>
 Date:   Fri May 18 10:03:50 2012 +0100

     Add INLINABLE pragmas in Template Haskell

     Thanks to mikhail.vorozhtsov for doing the work

  Language/Haskell/TH.hs        |   12 ++++++------
  Language/Haskell/TH/Lib.hs    |    4 ++--
  Language/Haskell/TH/Ppr.hs    |   10 ++++++++--
  Language/Haskell/TH/Syntax.hs |   13 +++++++++----
  4 files changed, 25 insertions(+), 14 deletions(-)
 }}}

--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5854#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...