From 7b271e5265e7eecafec8bdb8d9c3559507b6549a Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Mon, 12 Feb 2024 11:52:48 -0700 Subject: [PATCH] bind VarP after pats --- src/Rlp2Core.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Rlp2Core.hs b/src/Rlp2Core.hs index 70ac008..b938b74 100644 --- a/src/Rlp2Core.hs +++ b/src/Rlp2Core.hs @@ -125,11 +125,11 @@ exprToCore (LitE l) = litToCore l letToCore :: forall es. (NameSupply :> es) => Rec -> [Rlp.Binding' RlpcPs] -> RlpExpr' RlpcPs -> Eff es Expr' letToCore r bs e = do + -- TODO: preserve binder order. (bs',as) <- getParts - e' <- appKendo (foldMap Kendo as) <=< exprToCore $ unXRec e - if null bs' - then pure e' - else pure $ Let r bs' e' + let insbs | null bs' = pure + | otherwise = pure . Let r bs' + appKendo (foldMap Kendo (as `snoc` insbs)) <=< exprToCore $ unXRec e where -- partition & map the list of binders into: -- bs' : the let-binds that may be directly translated to Core