3 ms·
Of course, that's not actually the implementation in GHC. When you start writing code that's used everywhere, it pays off to learn and use every optimization av
by chowells 2y ago
Of course, that's not actually the implementation in GHC. When you start writing code that's used everywhere, it pays off to learn and use every optimization available. And the list fusion optimizations are relevant on both sides. Consume the input with foldr, produce the output with build. But be sure to change to a more direct implementation in a later optimization phase if list fusion doesn't fire.
No matter what language you're using, things get complicated when you're using every bit of low-level knowledge you've got to eke out every tenth of a percentage point.
- mrkeen 2y agohttps://hackage.haskell.org/package/ghc-internal-9.1001.0/docs/src/GHC.Internal.Base.html#map https://hackage.haskell.org/package/ghc-internal-9.1001.0/do...
- chowells 2y agoI'm uncertain if you think you are contradicting me or are showing others how complex the details of the real implementation are. Either way: Be sure to check out all those relevant rewrites in the RULES pragma a few lines further!
- lolive 2y agoSpoil from Java: look at the implementation of ArrayList and HashMap, and be HAPPY that all those dirty tricks have been there forever, but hidden behind such a simple interface.