- -- unnecessarily. It even causes a bug to do so if we have
- -- y = writeArr# a n (let x = e in b)
- -- because the y binding is an expr-ok-for-speculation one.
- -- [SLPJ Dec 01: I don't understand this last comment;
- -- writeArr# is not ok-for-spec because of its side effect]
+ -- unnecessarily. But we first test for values or trival rhss,
+ -- because (in particular) we don't want to insert new bindings between
+ -- the "=" and the "\". E.g.
+ -- f = \x -> let <bind> in <body>
+ -- We do not want
+ -- f = let <bind> in \x -> <body>
+ -- (a) The simplifier will immediately float it further out, so we may
+ -- as well do so right now; in general, keeping rhss as manifest
+ -- values is good
+ -- (b) If a float-in pass follows immediately, it might add yet more
+ -- bindings just after the '='. And some of them might (correctly)
+ -- be strict even though the 'let f' is lazy, because f, being a value,
+ -- gets its demand-info zapped by the simplifier.
+ if exprIsHNF arg' || exprIsTrivial arg' then
+ (fsa, floats, arg')
+ else
+ case (partitionByMajorLevel lvl floats) of { (floats', heres) ->