| TH already has type syntax, as I can examine: | | [| | f :: Num a => a -> a | f a = a + 1 | |] | | So I am not sure I understand which bit of syntax is missing? You'd like to be able to look at the Name 'a' and ask its type. Indeed, you'd like to know the type of an arbitrary sub-expression. So the change I had in mind was to attach a Type to a Name. | \x -> ($(do_something [| \y -> x |]), x::Int) | | The type could be " a -> a " ... IE just looking at the anonymous | functions it is fully polymorphic. | | You could veiw this as the most specific type available without | information from outside the meta-quote, which is the only definition | that makes sense to me at the moment. So if you had \(x::Int) -> ($(do_something [| \y -> x |]) you still want to get "a->a"? You definitely don't want to ignore the types of things defined outside -- think of 'map' and (+)! And what is this 'a' anyway? It's not bound anywhere. One can make pragmatic decisions about these things, but I'd prefer a principled approach.
Simon Peyton-Jones wrote:
So if you had \(x::Int) -> ($(do_something [| \y -> x |])
you still want to get "a->a"? You definitely don't want to ignore the types of things defined outside -- think of 'map' and (+)!
Okay, so it makes sense to include information from outside the quasi-quotes...
And what is this 'a' anyway? It's not bound anywhere.
I guess I mean: forall a . a -> a
One can make pragmatic decisions about these things, but I'd prefer a principled approach.
Possibly - but the type checker is deriving types for these functions already, so surely it just needs to be made visible to TH. Keean.
participants (2)
-
Keean Schupke -
Simon Peyton-Jones