2026/06/28

Newest at the top

2026-06-28 13:03:25 +0000 <fp> I guess if I force users to put everything they want returned into an Rc first, that could work
2026-06-28 13:01:33 +0000 <tomsmeding> then as long as you don't create cycles, you get a "GC" like Haskell has
2026-06-28 13:01:15 +0000 <tomsmeding> fp: wrap everything everywhere in Rc<>?
2026-06-28 13:00:57 +0000 <fp> Maybe if I bring in a garbage collector it'll be easier, but I'm not sure it's possible to implement this otherwise
2026-06-28 13:00:03 +0000 <fp> mauke: Ok yeah that's basically what I tried at first. Unfortunately, Rust makes extending the lifetime of a capturing closure a major PITA
2026-06-28 12:58:26 +0000fp(~Thunderbi@46-133-26-225.mobile.vf-ua.net) fp
2026-06-28 12:54:47 +0000traxex(traxex@user/traxex) traxex
2026-06-28 12:53:05 +0000fp(~Thunderbi@178-133-117-157.mobile.vf-ua.net) (Ping timeout: 256 seconds)
2026-06-28 12:52:59 +0000bitdex(~bitdex@gateway/tor-sasl/bitdex) bitdex
2026-06-28 12:51:16 +0000Pozyomka(~pyon@user/pyon) pyon
2026-06-28 12:47:36 +0000Pozyomka(~pyon@user/pyon) (Quit: test)
2026-06-28 12:46:08 +0000 <mauke> (no 'print' because we're taking advantage of perl's implicit 'show')
2026-06-28 12:45:32 +0000 <mauke> I don't know rust, but I just prototyped it in perl: https://pt.gayr.at/p/akEXWseeFyQMI20qKUFlL479SHI
2026-06-28 12:43:30 +0000 <fp> So I guess I need to make a structure of closures and run it with an explicit command, like Io::ret(...).bind(...).run(). But Rust doesn't make that easy...
2026-06-28 12:39:35 +0000 <lambdabot> I :: t0 -> t1 -> t2 -> t3 -> String -> tVariable not in scope: suspectVari...
2026-06-28 12:39:35 +0000 <lambdabot> Data constructor not in scope:
2026-06-28 12:39:34 +0000 <fp> Yeah, or "hi\na\nb\nc3", but close enough
2026-06-28 12:39:34 +0000 <fp> > I suspect yours would give "hi\na\nb\nc\n"
2026-06-28 12:35:48 +0000weary-traveler(~user@user/user363627) user363627
2026-06-28 12:35:12 +0000weary-traveler(~user@user/user363627) (Quit: Konversation terminated!)
2026-06-28 12:33:03 +0000 <fp> So without the cheat, it would've said "hi\n5\n"
2026-06-28 12:32:31 +0000rensenwxre(~fwam@user/fwam) fwam
2026-06-28 12:31:33 +0000 <fp> But actually I had to cheat with the first one. I couldn't reuse the x variable for the two >>s, so I rewrote put_str_ln("hi")
2026-06-28 12:30:24 +0000 <mauke> I suspect yours would give "hi\na\nb\nc\n"
2026-06-28 12:30:23 +0000 <fp> For the first one, it's "hi\n5hi\nhi"
2026-06-28 12:30:02 +0000 <mauke> the correct output is "3\nhi\nhi\n"
2026-06-28 12:29:22 +0000 <mauke> main = let { x :: IO (); x = putStrLn "hi" } in print (length [putStrLn "a", putStrLn "b", putStrLn "c"]) >> x >> x
2026-06-28 12:28:48 +0000 <mauke> actually, we can do better
2026-06-28 12:28:10 +0000 <mauke> not sure about lists
2026-06-28 12:28:06 +0000 <mauke> fn main() { let x = put_str_ln("hi"); print(???).bind(|_| { x.bind(|_| { x }) }); }
2026-06-28 12:26:38 +0000 <mauke> let me guess at the syntax
2026-06-28 12:26:08 +0000 <mauke> if you do the equivalent thing in rust, what does it output?
2026-06-28 12:25:49 +0000 <mauke> fp: main = let { x :: IO (); x = putStrLn "hi" } in print (length [x, x, x, x, x]) >> x >> x
2026-06-28 12:25:37 +0000 <fp> Sure, but I have to fake it a bit since I'm not interested in implementing the low level IO
2026-06-28 12:24:15 +0000 <mauke> (because 'return x >>= f' is 'f x')
2026-06-28 12:23:51 +0000 <mauke> IO::ret(s).bind(|s| { ... }) is pointless; could just { ... } directly
2026-06-28 12:23:12 +0000 <mauke> can't be right
2026-06-28 12:22:31 +0000 <fp> Of course, mine uses Rust std to do I/O instead of syscalls, but I'm interested in if the interface I've made is basically similar
2026-06-28 12:21:26 +0000 <fp> So I've been trying to get my head around how =IO= works, so I decided that I would try making a basic implementation of it with Rust. How far, at the high level, is what I'm doing from what Haskell does? https://paste.rs/SIL3v.rs
2026-06-28 12:20:28 +0000Lord_of_Life(~Lord@user/lord-of-life/x-2819915) Lord_of_Life
2026-06-28 12:18:58 +0000Lord_of_Life(~Lord@user/lord-of-life/x-2819915) (Read error: Connection reset by peer)
2026-06-28 12:16:23 +0000fp(~Thunderbi@178-133-117-157.mobile.vf-ua.net) fp
2026-06-28 12:14:54 +0000Lord_of_Life(~Lord@user/lord-of-life/x-2819915) Lord_of_Life
2026-06-28 12:11:53 +0000weary-traveler(~user@user/user363627) user363627
2026-06-28 11:58:08 +0000tremon(~tremon@83-80-159-219.cable.dynamic.v4.ziggo.nl) tremon
2026-06-28 11:50:15 +0000Digit(~user@user/digit) Digit
2026-06-28 11:44:45 +0000emilym(~Thunderbi@user/emilym) emilym
2026-06-28 11:43:55 +0000emilym(~Thunderbi@user/emilym) (Ping timeout: 276 seconds)
2026-06-28 11:35:56 +0000Digit`(~user@195.144.208.46.dyn.plus.net) (Ping timeout: 256 seconds)
2026-06-28 11:35:01 +0000Lord_of_Life(~Lord@user/lord-of-life/x-2819915) (Excess Flood)