Good to see you around, Sandy!

On Mar 18, 2020, at 6:54 PM, Sandy Maguire <sandy@sandymaguire.me> 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