From 290ec750343a340d5f2cef8bf844f3822c9629e0 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 2 Aug 2012 13:37:57 +0100 Subject: [PATCH] Add a comment to explain why the FCode monad is lazy --- compiler/codeGen/StgCmmBind.hs | 3 ++- compiler/codeGen/StgCmmMonad.hs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/codeGen/StgCmmBind.hs b/compiler/codeGen/StgCmmBind.hs index a0fcc1ac5d..148d53a4e3 100644 --- a/compiler/codeGen/StgCmmBind.hs +++ b/compiler/codeGen/StgCmmBind.hs @@ -113,7 +113,8 @@ cgBind (StgRec pairs) ; addBindsC new_binds ; emit (catAGraphs inits <*> body) } -{- Recursive let-bindings are tricky. +{- Note [cgBind rec] + Recursive let-bindings are tricky. Consider the following pseudocode: let x = \_ -> ... y ... y = \_ -> ... z ... diff --git a/compiler/codeGen/StgCmmMonad.hs b/compiler/codeGen/StgCmmMonad.hs index 287302fb0a..eb6b9a988f 100644 --- a/compiler/codeGen/StgCmmMonad.hs +++ b/compiler/codeGen/StgCmmMonad.hs @@ -143,6 +143,13 @@ thenFC (FCode m) k = FCode ( in kcode info_down new_state ) + -- Note: this is a lazy monad. We can't easily make it strict due + -- to the use of fixC for compiling recursive bindings (see Note + -- [cgBind rec]). cgRhs returns a CgIdInfo which is fed back in + -- via the CgBindings, and making the monad strict means that we + -- can't look at the CgIdInfo too early. Things seem to just + -- about work when the monad is lazy. I hate this stuff --SDM + listFCs :: [FCode a] -> FCode [a] listFCs = Prelude.sequence -- GitLab