2025/12/21

Newest at the top

2025-12-21 19:32:20 +0100 <c_wraith> it minimizes garbage collector churn
2025-12-21 19:30:33 +0100 <milan2> c_wraith: I think I understand what build does, so for chaining foldr multiple lists are created. But that should not matter as they are produced lazily?
2025-12-21 19:29:38 +0100 <c_wraith> https://www.joachim-breitner.de/publications/CallArity-TFP.pdf Well. Sometimes it gets called that.
2025-12-21 19:29:18 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 244 seconds)
2025-12-21 19:28:36 +0100 <c_wraith> that optimization was... uh.... "precise arity analysis"?
2025-12-21 19:28:00 +0100 <c_wraith> the @src database is older than the optimizations in GHC that allow foldl-via-foldr to be a good consumer.
2025-12-21 19:27:24 +0100 <probie> s/think/thing/
2025-12-21 19:27:08 +0100 <probie> which is the sort of think I was expecting to see
2025-12-21 19:27:02 +0100 <probie> Yeah, looking at the source for base `foldl k z0 xs = foldr (\(v::a) (fn::b->b) -> oneShot (\(z::b) -> fn (k z v))) (id :: b -> b) xs z0`
2025-12-21 19:25:30 +0100 <c_wraith> yeah, the @src database is not what GHC actually uses, either.
2025-12-21 19:24:59 +0100 <lambdabot> foldl f z (x:xs) = foldl f (f z x) xs
2025-12-21 19:24:59 +0100 <lambdabot> foldl f z [] = z
2025-12-21 19:24:59 +0100 <probie> @src foldl
2025-12-21 19:24:21 +0100 <milan2> Ty :)
2025-12-21 19:24:16 +0100 <c_wraith> build itself is documented at https://hackage-content.haskell.org/package/base-4.22.0.0/docs/GHC-List.html#v:build
2025-12-21 19:23:50 +0100 <c_wraith> see https://hackage-content.haskell.org/package/ghc-internal-9.1401.0/docs/src/GHC.Internal.Base.html#… for an example. In particular, pay attention to the long section of comments.
2025-12-21 19:23:14 +0100 <milan2> c_wraith: Now I am lost a little, could you elaborate on "build" or provide some documentation?
2025-12-21 19:22:32 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2025-12-21 19:22:19 +0100lambda_gibbon(~lambda_gi@2603:7080:ee00:37d8:dcc4:d31b:c3d9:56cd)
2025-12-21 19:22:04 +0100 <c_wraith> Participating in that on both sides requires using both foldr and build
2025-12-21 19:21:41 +0100 <c_wraith> I think what you're getting at is foldr/build fusion
2025-12-21 19:21:20 +0100 <milan2> c_wraith: Ok, so for reverse foldl is preferable.
2025-12-21 19:20:58 +0100 <milan2> chain of foldr should not traverse multiple times?
2025-12-21 19:19:45 +0100 <lambdabot> reverse = foldl (flip (:)) []
2025-12-21 19:19:45 +0100 <c_wraith> @src reverse
2025-12-21 19:19:26 +0100 <c_wraith> sure. What's the best for implementing reverse?
2025-12-21 19:19:25 +0100 <geekosaur> but it will depend on the exact intent
2025-12-21 19:19:18 +0100 <geekosaur> I think building lists from other lists is actually better done with difference lists in most cases, because folds will traverse the lists multiple times?
2025-12-21 19:19:12 +0100 <milan2> Even for purpose of producing new list from old lists?
2025-12-21 19:18:43 +0100 <c_wraith> "best" is vague.
2025-12-21 19:17:46 +0100 <milan2> foldr s3 . folrl s2 . foldl s1
2025-12-21 19:16:59 +0100 <milan2> If that is true then I should prefer that over foldl. However I had to use foldl, now does using foldr have meaning? I guess it still has right?
2025-12-21 19:15:51 +0100 <milan2> Hello guyz, I have a quastion based on assumption. So lets start with that. Is it true that it is best to build lists from other lists by use of foldr?
2025-12-21 19:11:19 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2025-12-21 19:06:47 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2025-12-21 19:04:19 +0100humasect(~humasect@dyn-192-249-132-90.nexicom.net) (Ping timeout: 246 seconds)
2025-12-21 19:01:49 +0100corecaps(~quassel@user/corecaps) corecaps
2025-12-21 19:00:14 +0100humasect(~humasect@dyn-192-249-132-90.nexicom.net)
2025-12-21 18:59:35 +0100vanishingideal(~vanishing@user/vanishingideal) (Ping timeout: 240 seconds)
2025-12-21 18:55:34 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 246 seconds)
2025-12-21 18:50:59 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2025-12-21 18:47:22 +0100tzh(~tzh@c-76-115-131-146.hsd1.or.comcast.net) tzh
2025-12-21 18:45:01 +0100corecaps(~quassel@user/corecaps) (Remote host closed the connection)
2025-12-21 18:39:49 +0100jmcantrell(~weechat@user/jmcantrell) (Ping timeout: 246 seconds)
2025-12-21 18:39:43 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2025-12-21 18:35:12 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2025-12-21 18:30:43 +0100GdeVolpiano(~GdeVolpia@user/GdeVolpiano) GdeVolpiano
2025-12-21 18:29:53 +0100GdeVolpiano(~GdeVolpia@user/GdeVolpiano) (Ping timeout: 250 seconds)
2025-12-21 18:28:04 +0100humasect(~humasect@dyn-192-249-132-90.nexicom.net) (Ping timeout: 260 seconds)
2025-12-21 18:26:54 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 260 seconds)