[Haskell-cafe] Working with the code For "Typing Haskell In Haskell"
tom at pledger.gen.nz
Wed Oct 26 04:16:31 CEST 2011
Patrick LeBoutillier <patrick.leboutillier <at> gmail.com> writes:
> exprt = Ap (Const mapt) (Const idt)
> test = runTI $ tiExpr initialEnv  exprt
> When I execute the test function above in ghci I get:
> (,TVar (Tyvar "v3" Star)).
> I was expecting someting like below for the type part:
> TAp tList (TGen 0) `fn` TAp tList (TGen 0)
The short answer is that you need to use a higher-level inference function than
Here's the code I ended up with:
t4 = (putStrLn . pretty . runTI)
[("map_id", [(, Var "map" `Ap` Var "id")])])
It gets the desired result:
(TAp tList (TGen 0) `fn` TAp tList (TGen 0)))])
Var is for referring by name to type assumptions you already have. Const is
intended for other things such as data constructors, so I avoided it in this
case, even though Const mapt `Ap` Const idt also works.
The tiImpls function performs the 'quantify' step, which adds the Forall and
converts TVar to TGen, whereas tiExpr doesn't. I can't see offhand why tiExpr
doesn't seem to work in isolation - but maybe that part of a Haskell typer
wouldn't work in isolation either!
More information about the Haskell-Cafe