diff options
author | Andreas Klebinger <klebinger.andreas@gmx.at> | 2021-01-20 05:25:45 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-05 19:10:41 -0500 |
commit | c5ace76008ae51e2bd124d3286266cc2a5ffcc0e (patch) | |
tree | 39fd11f584618a66e941cf6a8a4dd9ab7bf84ca7 /compiler/GHC/Utils | |
parent | c7922ced8f89e9c9ab4dae152a5d964aa8628858 (diff) | |
download | haskell-c5ace76008ae51e2bd124d3286266cc2a5ffcc0e.tar.gz |
Try eta expanding FCode (See #18202)
Also updates the note with the case of multi-argument lambdas.
Seems slightly beneficial based on the Cabal test:
-O0: -1MB allocations (out of 50GB)
-O : -1MB allocations (out of ~200GB)
Diffstat (limited to 'compiler/GHC/Utils')
-rw-r--r-- | compiler/GHC/Utils/Monad.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Monad.hs b/compiler/GHC/Utils/Monad.hs index da415ba44c..a65947e59e 100644 --- a/compiler/GHC/Utils/Monad.hs +++ b/compiler/GHC/Utils/Monad.hs @@ -344,6 +344,17 @@ it is more elaborate. The pattern synonym approach is due to Sebastian Graaf (#18238) +Do note that for monads for multiple arguments more than one oneShot +function might be required. For example in FCode we use: + + newtype FCode a = FCode' { doFCode :: CgInfoDownwards -> CgState -> (a, CgState) } + + pattern FCode :: (CgInfoDownwards -> CgState -> (a, CgState)) + -> FCode a + pattern FCode m <- FCode' m + where + FCode m = FCode' $ oneShot (\cgInfoDown -> oneShot (\state ->m cgInfoDown state)) + Derived instances ~~~~~~~~~~~~~~~~~ One caveat of both approaches is that derived instances don't use the smart |