[Haskell-cafe] Dynamically typing TH.Exp at runtime

Martin Hofmann martin.hofmann at uni-bamberg.de
Thu Mar 12 12:47:26 EDT 2009


This is what hint does, isn't it? However, this still leaves it to me to
infer what type [|a|] in [| reverse (a:b:[]) = (b:a:[]) |] is. 

Thanks a lot anyway.

Martin

On Thu, 2009-03-12 at 12:59 -0200, Daniel Gorín wrote:
> would using ghc-as-a-library to type (strings with) haskell  
> expressions at runtime help?
> 
> On Mar 12, 2009, at 12:37 PM, Martin Hofmann wrote:
> 
> > 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
> >
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list