
Relevant paper to typed quotation:
http://repository.cmu.edu/cgi/viewcontent.cgi?article=2969&context=compsci
I'm very interested in metaprogramming in typed languages, and this paper
seems to suggest that it is a Hard Problem™.
On Thu Dec 18 2014 at 1:41:07 PM adam vogt
On Thu, Dec 18, 2014 at 12:43 PM, Tom Ellis
wrote: This is a great idea and looks very useful, which raises the following question: Why hasn't this already been done? Is there some fundamental obstruction? Perhaps someone who has tried this has some wisdom to share.
Sometimes I found myself using:
foldl appE :: ExpQ -> [ExpQ] -> ExpQ
If you try that with appE_, you end up with a type error "Occurs check: cannot construct the infinite type: t1 ~ t -> t1". It would type check if it was a foldl over a hlist, but I don't think that would be a preferred solution. Since appE_ doesn't work when you don't know how many times it will be used, I think people would just inline one possible definition:
appE_ :: Q (TExp (a -> b)) -> Q (TExp a) -> Q (TExp b) appE_ f x = [|| $$f $$x ||]
Secondly, it looks like you can only make a value of type "L String" by using stringL_, and only consume them with litE_, so I think that intermediate type does not really help. In other words, I think it is better to just use the following:
liftString_ :: String -> Q (TExp String) liftString_ = litE_ . stringL_
or just inline the following more general function:
lift_ :: Lift t => t -> Q (TExp t) lift_ x = [|| x ||]
I don't see those extra functions providing something that the typed bracket / quotation syntax doesn't already provide in a prettier way.
Regards, Adam _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe