It’s expected but unfortunate.
Template Haskell runs *during*
type checking. So when you reify a local type, it may not yet be fully worked
out. In this case it would be worse if you said
let a=10
in ( $(…reify ‘a…),
a+1::Int )
Here it’s “clear” that
a has type Int, but it won’t be clear to Template Haskell until after it’s
typechecked the whole expression. But it has to run the splice before that!
That’s a shortcoming I don’t
know how to solve at the moment.
Simon
From:
template-haskell-bounces@haskell.org
[mailto:template-haskell-bounces@haskell.org] On
Behalf Of Oleg Mürk
Sent: 23 April 2006 22:53
To: template-haskell@haskell.org
Subject: [Template-haskell] Type
inference
Hello,
I have the following problem. I'd like to infer types of local bindings using
'reify':
------------------------------------
testValue =
let
a = 10
in
$(do
VarI _ t _ _ <-
reify 'a
lift (pprint t)
)
-------------------------------------
But this code prints only:
-------------------------------------
*Debug> testValue
"t_0"
-------------------------------------
Is this intended behavior? Are there any workarounds?
Things work fine if symbol is defined in another module.
I do realise that in general $(...) may add additional constraints on local
variables.