bind VarP after pats

This commit is contained in:
crumbtoo
2024-02-12 11:52:48 -07:00
parent af42d4fbd6
commit 7b271e5265

View File

@@ -125,11 +125,11 @@ exprToCore (LitE l) = litToCore l
letToCore :: forall es. (NameSupply :> es) letToCore :: forall es. (NameSupply :> es)
=> Rec -> [Rlp.Binding' RlpcPs] -> RlpExpr' RlpcPs -> Eff es Expr' => Rec -> [Rlp.Binding' RlpcPs] -> RlpExpr' RlpcPs -> Eff es Expr'
letToCore r bs e = do letToCore r bs e = do
-- TODO: preserve binder order.
(bs',as) <- getParts (bs',as) <- getParts
e' <- appKendo (foldMap Kendo as) <=< exprToCore $ unXRec e let insbs | null bs' = pure
if null bs' | otherwise = pure . Let r bs'
then pure e' appKendo (foldMap Kendo (as `snoc` insbs)) <=< exprToCore $ unXRec e
else pure $ Let r bs' e'
where where
-- partition & map the list of binders into: -- partition & map the list of binders into:
-- bs' : the let-binds that may be directly translated to Core -- bs' : the let-binds that may be directly translated to Core