From 7727fbe6684ff12815f84085dd078074f9bd22de Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Fri, 15 Mar 2024 18:47:52 -0600 Subject: [PATCH] correctly apply substs --- src/Rlp/HindleyMilner.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Rlp/HindleyMilner.hs b/src/Rlp/HindleyMilner.hs index 7b72730..9696300 100644 --- a/src/Rlp/HindleyMilner.hs +++ b/src/Rlp/HindleyMilner.hs @@ -136,7 +136,7 @@ infer1' g1 e = do ((t,j) :< _) <- annotate e g2 <- unify (j ^. constraints) g <- unionContextWithKeyM unifyTypes g1 g2 - pure $ ifoldlOf (contextVars . itraversed) subst t g + pure $ ifoldrOf (contextVars . itraversed) subst t g where -- intuitively, we'd return mgu(s,t) but the union is left-biased making `s` -- the user-specified type: prioritise her. @@ -211,6 +211,7 @@ typeCheckRlpProgR p = tc p etaExpandAll = programDecls . each %~ etaExpand etaExpand :: Decl b (RlpExpr b) -> Decl b (RlpExpr b) +etaExpand (FunD n [] e) = FunD n [] e etaExpand (FunD n as e) | Right as' <- allVarP as = FunD n [] (Finl . LamF as' $ e)