
Did you get a reply?
I’m not 100% certain of your question, but consider the
bar = show <expr>
for some expression e. In the input to the type type checker the syntax tree for the RHS will be something like
HsApp (HsVar “show”) <syntax tree for expr>
(The “show” isn’t really a string, it’s the Name for the class method.)
After typechecking the syntax tree is augmented (or “elaborated”) with type and dictionary application. So in concrete form it might look like
bar = show @Foo dShowFoo <expr>
Because show :: forall a. Show a => a -> String, so show is apply to the type of its argument, and then to the dictionary.
In HsSyn this part is done with a HsWrapper See TcEvidence.HsWrapper. The elaborated syntax tree look like
HsApp (HsWrap <wrapper> (HsVar “show”))
<syntax tree for elaborated expr>
The <wrapper> part expresses the type and dictionary application. In this case it’ll look like
WpEvApp dShowFoo (WpTyApp Foo WpHole)
See the notes with `HsWrapper` in TcEvidence.
Does that help?
It would be great to augment the https://ghc.haskell.org/trac/ghc/wiki/Commentary with this sort of info (insofar as it doesn’t have it already). If you augment I can review. Email is quickly lost.
Simon
From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Robin Palotai
Sent: 19 September 2017 06:39
To: GHC developers