#5463: SPECIALISE pragmas generated from Template Haskell are ignored
---------------------------------+------------------------------------------
Reporter: NickSmallbone | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Template Haskell | Version: 7.2.1
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by simonpj):
What is happening is this.
* GHC compiles all decls down to, but not including the first splice
* Then it runs the splice
* Then it combines the result of the splice with all decls following,
down to the ''next'' splice, and compiles them
* And so on
In your case, then, the SPECIALISE pragma is getting compiled after the
decl to which it refers has been compiled. This isn't expected, and
should probably generate an error message, but doesn't. But it turns into
a no-op as you found.
A workaround would be to generate the pragma ''before'' the defn to which
it applies.
{{{
$(specialise (mkName "three"))
{-# NOINLINE three #-}
three :: Monad m => m Int
three = return 3
}}}
But since that defn would not be in scope when the splice is run, you have
to use `mkName` which is messy.
Alternatively, maybe you can pass the decl to the function thus:
{{{
$(specialise
[d| three :: Monad m => m Int
three = return 3
|])
}}}
In truth, what you originally wrote should really work. But there are so
many other things to do. By all means say how important or otherwise this
is, and enourage others to do the same.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5463#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs