GHC: Ticket Query
http://ghc.haskell.org/trac/ghc/query?status=!closed&keywords=~template&order=priority
The Glasgow Haskell Compileren-USGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/query?status=!closed&keywords=~template&order=priority
Trac 1.0.1
http://ghc.haskell.org/trac/ghc/ticket/8031
http://ghc.haskell.org/trac/ghc/ticket/8031#8031: Template Haskell gets confused with kind variables introduced in separate forallsTue, 02 Jul 2013 22:36:59 GMTgoldfire<p>
The following file compiles without complaint:
</p>
<pre class="wiki">{-# LANGUAGE TemplateHaskell, RankNTypes, PolyKinds, DataKinds, TypeOperators,
GADTs #-}
module S2 where
import Language.Haskell.TH
data Proxy a = Proxy
data SList :: [k] -> * where
SCons :: Proxy h -> Proxy t -> SList (h ': t)
dec :: Q [Dec]
dec = [d| foo :: forall (a :: k). Proxy a -> forall (b :: [k]). Proxy b -> SList (a ': b)
foo a b = SCons a b |]
foo' :: forall (a :: k). Proxy a -> forall (b :: [k]). Proxy b -> SList (a ': b)
foo' a b = SCons a b
</pre><p>
Note that <tt>foo</tt> and <tt>foo'</tt> are identical, just at different compilation stages. However, the following module does not compile:
</p>
<pre class="wiki">{-# LANGUAGE TemplateHaskell, DataKinds, PolyKinds, RankNTypes #-}
module S3 where
import S2
$(dec)
</pre><p>
The error is
</p>
<pre class="wiki">S3.hs:7:3:
Couldn't match kind ‛k’ with ‛k1’
‛k’ is a rigid type variable bound by
the type signature for
foo :: Proxy k a0
-> forall (k1 :: BOX) (b0 :: [k1]).
Proxy [k1] b0 -> SList k1 ((':) k1 a0 b0)
at S3.hs:7:3
‛k1’ is a rigid type variable bound by
the type signature for
foo :: Proxy k a0 -> Proxy [k1] b -> SList k1 ((':) k1 a0 b)
at S3.hs:7:3
Expected type: SList k1 ((':) k1 a0 b)
Actual type: SList k ((':) k a0 b)
Relevant bindings include
foo :: Proxy k a0
-> forall (k1 :: BOX) (b0 :: [k1]).
Proxy [k1] b0 -> SList k1 ((':) k1 a0 b0)
(bound at S3.hs:7:3)
a_aTCB :: Proxy k a0 (bound at S3.hs:7:3)
b_aTCC :: Proxy [k1] b (bound at S3.hs:7:3)
In the expression: SCons a_aTCB b_aTCC
In an equation for ‛foo’: foo a_aTCB b_aTCC = SCons a_aTCB b_aTCC
</pre><p>
If I change the nested <tt>forall</tt>s in the definition of <tt>foo</tt> to be just one top-level <tt>forall</tt>, the problem goes away.
</p>
<p>
This may seem terribly esoteric, but it's easier to generate nested <tt>forall</tt>s than to float them all to the top-level after processing a type. I received an email requesting that I get the <tt>singletons</tt> library to compile with HEAD, and this seems to be why it doesn't.
</p>
<p>
This is a regression error: the code compiles fine with 7.6.3 but not with HEAD.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/8031#changelog
http://ghc.haskell.org/trac/ghc/ticket/4899
http://ghc.haskell.org/trac/ghc/ticket/4899#4899: Non-standard compile plus Template Haskell produces spurious "unknown symbol" linker errorTue, 18 Jan 2011 00:44:27 GMTjepst<p>
Programs that use Template Haskell fail to link when doing a "non-standard" compile. Specifically, compilations with -prof and -dynamic produce this bug, although other flags may as well; it seems that compilations that require the two-stage -osuf flag produce this bug. The error message is always "unknown symbol" but the specific symbol that is allegedly missing varies. Removing the TH block from the code makes the problem go away.
</p>
<p>
I've provided a minimal example of a program that can reproduce this bug, in the enclosed files Bug1.hs and Main.hs. A typescript demonstrating the error message is also included.
</p>
<p>
Tested on GHC 7.0.1 and 6.12.1, running under Ubuntu 10.04, both 64-bit and 32-bit. Also tested with 6.12.3 under 32-bit Windows 7.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4899#changelog