
I am doing meta-programming at runtime. So my program gets a full Haskell declaration in expression quotation ([d|...|]) modifies it and returns the modified expression. Therefore, I need type information of this expression, and any subexpression, at _runtime_ ! For example: [d| reverse x1 = y1 |] - rewrites_to -> [d| reverse x2:xs = y2:ys |] - rewrites_to -> [d| reverse x:xs = reverse xs ++ [x] |] reverse :: [a] -> [a] implies x2,y2 :: a x1,y1,xs,ys :: [a] TH.reify is not applicable, because I need the information at runtime and I am in IO. I suppose Data.Dynamic does not work either, because [| xs|] :: ExpQ and not [a]. So it looks like I need my own type checker and inference and tag each subexpression with its type. If so, I can even omit TH and use my own data type for the abstract syntax tree. This annoys me a bit, because for me it seems that all I need is already there. Did anybody have similar problems, because I shouldn't be the only one doing dynamic typing in a static language? Is there a Haskell implementation of the paper "Typing Dynamic Typing" by Baars and Swierstra (http://people.cs.uu.nl/arthurb/dynamic.html ), so I can try out if this helps me? Any help, comments, and how-to-suggestions are highly welcome. Thanks a lot, Martin
participants (1)
-
Martin Hofmann