2026/02/24

Newest at the top

2026-02-25 00:53:41 +0100 <int-e> I've implemented quite a few breadth first searches in Haskell and I've never materialized the tree; only levels (usually as lists because it's convenient, or as sets because I expected a significant number of transpositions.)
2026-02-25 00:53:22 +0100 <lantti> mauke: oh, now i see. so the "otherwise" only worked because any identifier would have worked there
2026-02-25 00:53:16 +0100peterbecich(~Thunderbi@71.84.33.135) peterbecich
2026-02-25 00:53:06 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds)
2026-02-25 00:51:56 +0100earthy(~arthurvl@2a02-a469-f5e2-1-83d2-ca43-57a2-dc81.fixed6.kpn.net) (Ping timeout: 268 seconds)
2026-02-25 00:51:32 +0100 <int-e> Leary: I don't know whether we have one. My main point was that it's abuse.
2026-02-25 00:50:57 +0100 <Comstar> that'll be fun to explore
2026-02-25 00:50:56 +0100 <Leary> int-e: Do we not have a (foldable) binary tree to search? And yes, I agree, but specialising the code to a binary tree means we can kill the evil.
2026-02-25 00:50:56 +0100 <int-e> it is
2026-02-25 00:50:51 +0100 <Comstar> oh it's prob the LambdaCase language extension
2026-02-25 00:50:40 +0100 <Comstar> Leary, oh wow line 25 in `Search.hs` is really interesting, I didn't know you could do `\case` like that, does that trick have a name?
2026-02-25 00:50:18 +0100 <int-e> (and it's an abuse because that Semigroup instance isn't lawful)
2026-02-25 00:49:31 +0100 <int-e> Leary: that task is related but abuses Foldable on an infinite tree that you already have as a value.
2026-02-25 00:48:15 +0100 <Leary> Comstar: There was a haskell challenge for this a while back. This was my solution: https://gist.github.com/LSLeary/5083d1dfe403d1562e7778713d97b22a
2026-02-25 00:47:54 +0100 <int-e> "history" being the path through the underlying tree
2026-02-25 00:47:36 +0100 <Comstar> yeah that makes sense
2026-02-25 00:47:13 +0100 <int-e> Comstar: If you have a state S and function branch :: S -> [S] then the list monad's bind (aka concatMap) can produce the next level of a tree from the previous one. (This gets a bit awkward if you also want to record history, but you can make that part of S)
2026-02-25 00:46:25 +0100chenjf(~chenjf@68.64.178.54) (Quit: WeeChat 4.8.1)
2026-02-25 00:46:11 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-02-25 00:45:49 +0100 <Comstar> I feel like I could probably find some neat code examples searching around github &al
2026-02-25 00:45:29 +0100 <Comstar> do y'all know of a more pure approach? I guess I could do like, some folding magic
2026-02-25 00:44:58 +0100 <Comstar> I can't think of a way to implement breadth-first searches (for the sake of discussion assume for a binary tree) that doesn't use a `Control.Monad.State` implementation
2026-02-25 00:41:15 +0100bjs(sid190364@user/bjs) bjs
2026-02-25 00:40:59 +0100bjs(sid190364@user/bjs) (Server closed connection)
2026-02-25 00:40:00 +0100tamer(~tamer@5.2.74.82)
2026-02-25 00:39:39 +0100tamer(~tamer@user/tamer) (Server closed connection)
2026-02-25 00:38:57 +0100chenjf(~chenjf@68.64.178.54)
2026-02-25 00:37:02 +0100 <int-e> (but then you'd have to accumulate a full result before printing anything)
2026-02-25 00:36:15 +0100emmanuelux(~em@user/emmanuelux) emmanuelux
2026-02-25 00:36:05 +0100 <int-e> mauke: Yeah that looks like the best solution. Kind of sad; the simple greedy algorithm for the knapsack problem would work here.
2026-02-25 00:35:05 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 248 seconds)
2026-02-25 00:34:09 +0100emmanuelux(~em@user/emmanuelux) (Quit: bye)
2026-02-25 00:33:54 +0100acidsys(~crameleon@openSUSE/member/crameleon) crameleon
2026-02-25 00:33:39 +0100acidsys(~crameleon@openSUSE/member/crameleon) (Server closed connection)
2026-02-25 00:33:05 +0100Comstar(~Comstar@user/Comstar) Comstar
2026-02-25 00:32:16 +0100 <lantti> should I use _ -> as the catch all case then? I'm not working with haskell all that much as one may notice
2026-02-25 00:30:47 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-02-25 00:29:25 +0100 <lantti> (which I can recommend to anyone with children in the 1-3 primary school or earlier)
2026-02-25 00:26:53 +0100 <lantti> (and the term "step squad" comes from the BBC childrens series called Numberblocks)
2026-02-25 00:25:38 +0100 <lantti> (the previous version used length on the generated lists)
2026-02-25 00:25:00 +0100 <lantti> but looking at my code now I do admit that there are some decisions that only make sense if you consider that they were the smallest change to the previous version, like the decision to include the lengths of the sets in the same list as the sets themselves
2026-02-25 00:23:50 +0100saolsen(sid26430@id-26430.lymington.irccloud.com) saolsen
2026-02-25 00:23:39 +0100saolsen(sid26430@id-26430.lymington.irccloud.com) (Server closed connection)
2026-02-25 00:22:21 +0100 <lantti> guards, even
2026-02-25 00:21:44 +0100 <lantti> mauke: is it not meant to be used like that? is it only for gurads then?
2026-02-25 00:21:11 +0100snek(sid280155@id-280155.lymington.irccloud.com) snek
2026-02-25 00:20:59 +0100snek(sid280155@id-280155.lymington.irccloud.com) (Server closed connection)
2026-02-25 00:19:45 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 246 seconds)
2026-02-25 00:19:15 +0100 <mauke> lantti: I suggest changing "otherwise" to "print" for even more confusion
2026-02-25 00:15:24 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn