RE: Type inference
"Simon Peyton-Jones" <[email protected]> Tue, 25 Apr 2006 08:52:35 +0100
| Newsgroups | gmane.comp.lang.haskell.template |
|---|---|
| Message-ID | <036EAC76E7F5EC4996A3B3C3657D41160535387D@EUR-MSG-21.europe.corp.microsoft.com> |
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: [email protected] [mailto:[email protected]] On Behalf Of Oleg Mürk
Sent: 23 April 2006 22:53
To: [email protected]
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.
OM
_______________________________________________
template-haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/template-haskell