The definition of cseProgram

Simon Peyton Jones simonpj at microsoft.com
Mon Aug 18 22:02:08 UTC 2014


Yes, we could

From: ghc-devs [mailto:ghc-devs-bounces at haskell.org] On Behalf Of David Feuer
Sent: 18 August 2014 22:42
To: ghc-devs
Subject: The definition of cseProgram


Currently, it's defined like this:

cseProgram :: CoreProgram -> CoreProgram
cseProgram binds = cseBinds emptyCSEnv binds

cseBinds :: CSEnv -> [CoreBind] -> [CoreBind]
cseBinds _ [] = []
cseBinds env (b:bs) = (b':bs')
                    where
                      (env1, b') = cseBind env b
                      bs' = cseBinds env1 bs

Couldn't we replace all that with the following? (Thanks to Cale for suggesting mapAccumL—I was using scanl because I knew it, but it was not a great fit.)

cseProgram = snd . mapAccumL cseBind emptyCSEnv

David Feuer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140818/91fe5bfc/attachment.html>


More information about the ghc-devs mailing list