
Patrick LeBoutillier
[...]
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)
[...] Hi Patrick. The short answer is that you need to use a higher-level inference function than tiExpr. Here's the code I ended up with: t4 = (putStrLn . pretty . runTI) (tiImpls initialEnv [mapt, idt] [("map_id", [([], Var "map" `Ap` Var "id")])]) It gets the desired result: *PLB_thih> t4 ([], ["map_id" :>: Forall [Star] ([] :=> (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! Regards, Tom