
I'm also generating code at the same time, and might have gotten confused
by that interaction :)
In the meantime I guess I'll implement HM. The world will be a much better
place when TTG is finished and we have ghc-as-an-easy-to-use-library :)
On Thu, Mar 19, 2020 at 2:51 AM Richard Eisenberg
Good to see you around, Sandy!
On Mar 18, 2020, at 6:54 PM, Sandy Maguire
wrote: I mean if `insert :: a -> Container a -> Container a`, and I call it with `[e| insert 5 True |]`, the quote will fail.
I don't observe this. Specifically, when I compile
{-# LANGUAGE TemplateHaskellQuotes #-}
module Bug where
import Prelude ( Bool(..), undefined )
data Container a
insert :: a -> Container a -> Container a insert = undefined
quote = [e| insert 5 True |]
GHC happily succeeds.
I think what you want, though, is reasonable: you want the ability to send an expression through GHC's type-checker. I think we'd need to extend TH to be able to support this, and it will be hard to come up with a good design, I think. (Specifically, I'm worried about interactions with top-level defined entities, whose types might not really be known by the time of splice processing.) This might all be worthwhile -- singletons would be able to be improved with this, for example -- but it's not cheap, sadly.
Richard