Understanding DsMeta module
Richard Eisenberg
eir at cis.upenn.edu
Wed Dec 17 19:24:18 UTC 2014
On Dec 17, 2014, at 12:29 PM, Jan Stolarek <jan.stolarek at p.lodz.pl> wrote:
>
> Why not implement repPlainTV like this: ?
>
> repPlainTV :: Core TH.Name -> DsM (Core TH.TyVarBndr)
> repPlainTV (MkC nm) = return $ MkC (TH.PlainTV nm)
>
In short, that's ill typed. We have
> newtype Core a = MkC CoreExpr
The idea behind this type is that its (phantom) type parameter tracks the type of the expression stored within. Of course, the thing within is always just a core expression. TH.PlainTV takes a TH.Name and produces a TH.TyVarBndr. But, nm is a CoreExpr and MkC is expecting a CoreExpr, so your suggestion wouldn't type check.
The higher-level answer is that you're mixing levels. The goal in DsMeta is *not* to create the TH AST. It's to create *core expressions* that create the TH AST.
Does this help?
Richard
More information about the ghc-devs
mailing list