Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,049 events total
2025-09-16 02:00:28 <StatisticalIndep> yin: Well, the cases in point would be things like Control.Arrow, the regex libraries, the printf function, or the entire generics/SYB black magic. But even basic Foldable/Traversable have some nasty catches, where it is just implied you know that that seemingly entirely unrelated more generic function, in this case, works to do the job of a common
2025-09-16 02:00:28 <StatisticalIndep> expected function that seems to be just missing. Without a guide, that is impossible to find! … And that the types can tell you what a function does, seems to be an old mantra, but really, even basic math operations prove that wrong. (What does (Int -> Int -> Int) do? XD) Unless you make a `type` for each of them, to give them descriptive
2025-09-16 02:00:28 <StatisticalIndep> identifiers, of course. ;) …
2025-09-16 02:01:21 <StatisticalIndep> geekosaur: Parsec was a positive exception indeed. I liked it quite a lot.
2025-09-16 02:02:25 <StatisticalIndep> geekosaur: Though we should really get rid of that “Parsec from Temu” that forms the basis of the Read class. I actually thought it was meant to be used outside of GHC’s automatic deriving! ;)
2025-09-16 02:04:18 arandombit joins (~arandombi@user/arandombit)
2025-09-16 02:04:20 <StatisticalIndep> geekosaur: Amen to your comment about research papers. (I wish there was an easy way to learn what it takes to write a research paper. It seems to require a whole basket of arcane rituals to be acceptable. ;)
2025-09-16 02:04:27 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 250 seconds)
2025-09-16 02:06:17 poscat0x04 joins (~poscat@user/poscat)
2025-09-16 02:07:41 × poscat quits (~poscat@user/poscat) (Ping timeout: 244 seconds)
2025-09-16 02:11:48 <StatisticalIndep> BTW: Am I using the wrong language, for trying to write a library that offers persistent variable? As in: Can be used like a variable (ok maybe IORef), but is a pointer (and size) in a file on disk. It seems Haskell is very averse to the strategy of just loading a chunk of data from disk into RAM and then setting a pointer to a data structure to
2025-09-16 02:11:49 <StatisticalIndep> that chunk. Making it hard, but possibly necessary to retain Haskell’s reliability guarantees?
2025-09-16 02:13:53 <jackdk> StatisticalIndep: does https://hackage.haskell.org/package/mmap-0.5.9/docs/System-IO-MMap.html look like it might solve your problem? I'm not sure I understand what problem you're trying to solve yet
2025-09-16 02:15:18 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-09-16 02:16:25 <StatisticalIndep> jackdk: Ultimately, to leave a mark on the universe that improves the wisdom and happiness of humanity. 😁
2025-09-16 02:16:49 <jackdk> StatisticalIndep: a fine ultimate goal, but do you have a subgoal in-between?
2025-09-16 02:16:53 × nschoe quits (~nschoe@2a01:e0a:8e:a190:eb80:e362:f8e1:aa2f) (Quit: ZNC 1.8.2 - https://znc.in)
2025-09-16 02:17:10 nschoe joins (~nschoe@82-65-202-30.subs.proxad.net)
2025-09-16 02:20:01 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 248 seconds)
2025-09-16 02:21:55 × Alleria quits (~Alleria@user/alleria) (Quit: Textual IRC Client: www.textualapp.com)
2025-09-16 02:31:06 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-09-16 02:36:05 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds)
2025-09-16 02:38:02 × arandombit quits (~arandombi@user/arandombit) (Ping timeout: 260 seconds)
2025-09-16 02:40:12 <StatisticalIndep> jackdk: To stop people from always assuming the thing I said I want is not the right solution for the thing I want it for. (The “XY problem” fallacy.) 😁 … (Or in this case, there is no deeper reason. I want to explore writing a library that offers transparently persistent variables. Nothing more.)
2025-09-16 02:42:48 <jackdk> StatisticalIndep: Well I'd probably look at building something that used the https://hackage.haskell.org/package/StateVar interface, and then back it with either the mmap link from before (remember to use a `bracket` function to ensure that you unmap even if an exception is thrown) or some other file io
2025-09-16 02:43:49 <StatisticalIndep> System.IO.MMap looks pretty good, btw. If only there was no marshalling.
2025-09-16 02:45:10 arandombit joins (~arandombi@2603:7000:4600:ffbe:21ee:ceac:8353:7a15)
2025-09-16 02:45:10 × arandombit quits (~arandombi@2603:7000:4600:ffbe:21ee:ceac:8353:7a15) (Changing host)
2025-09-16 02:45:10 arandombit joins (~arandombi@user/arandombit)
2025-09-16 02:45:18 <StatisticalIndep> Ah, yes, StateVar was a pretty nice experience, when I used SDL. Comes really close to it, indeed.
2025-09-16 02:46:31 <StatisticalIndep> jackdk: Thanks a lot!
2025-09-16 02:46:53 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-09-16 02:47:21 <geekosaur> re marshaling: requiring STorable doesn't seem like much of an issue, and you would need it anyway because Haskell values aren't designed to be meaningful outside of Haskell's heap
2025-09-16 02:48:24 <StatisticalIndep> Interesting: The Storable instances for basic types seem to be implemented inside GHC, and the libraries just use stuff like (writeWordOffAddr# = writeWordOffAddr#). So there is probably no actual marshalling work, and it’s fast and 1:1.
2025-09-16 02:50:15 <StatisticalIndep> geekosaur: Yes, that’s probably my core pet peeve with how Haskell in implemented. It makes interoperation hard. But I get why it was chosen. The whole point was that all types should be checked at compile time, not at runtime. (Hence also things like dynamic libraries and variants with types that aren’t know at compile time yet, being hard or
2025-09-16 02:50:15 <StatisticalIndep> impossible.)
2025-09-16 02:51:37 <geekosaur> not only that, but Haskell's implementation of types allows for laziness in the form of thunks, which wouldn't be meaningful to non-Haskell code (a "value" can be a Haskell function that computes the value when demanded)
2025-09-16 02:51:38 <StatisticalIndep> geekosaur: That was what I needed to hear btw: Marshalling is needed in _any_ case. Because the values don’t have type info attached to them and it’s not that simple anyway within Haskell. :)
2025-09-16 02:51:43 <StatisticalIndep> Yup.
2025-09-16 02:52:01 <geekosaur> which also requires that everything live in Haskell's heap and non-Haskell code not have access to that heap
2025-09-16 02:52:09 <StatisticalIndep> And after all, those are all things I came to Haskell for, because I liked them. So now I have to live with it.:D
2025-09-16 02:52:47 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 265 seconds)
2025-09-16 02:53:31 <StatisticalIndep> Internally though, the fully evaluated values are of course just normal pointers and words and such, right? Just boxed in boxed boxes that are boxed more than the boss on boxyourboss.com was. ;)
2025-09-16 02:53:42 <geekosaur> actually I don't see how "doesn't have type information" is related. it's not like C values do
2025-09-16 02:53:58 <StatisticalIndep> OK, true.
2025-09-16 02:54:39 <geekosaur> they are… until ADTs get involved. (what representation do you expect a Data.Map to have?)
2025-09-16 02:54:58 <StatisticalIndep> I guess my mindset came from having seen diagrams of how GHC stores data in memory. Like how lists are linked lists of boxed values. Lots more pointers than one would think.
2025-09-16 02:54:59 <geekosaur> *Data.Map.Map
2025-09-16 02:55:22 × arandombit quits (~arandombi@user/arandombit) (Ping timeout: 256 seconds)
2025-09-16 02:55:56 <geekosaur> right, and all those pointers introduce places where a value could be computed lazily
2025-09-16 02:56:28 <geekosaur> (if you don't have optimization enabled, even the strict values have them, but optimization unboxes whenever possible)
2025-09-16 02:58:26 <StatisticalIndep> I probably expect a Map to internally be stored as an array of pointers, with pointers to keys and to values being interleaved? Or something a bit smarter with fewer pointers. ;)
2025-09-16 02:58:38 × StatisticalIndep quits (~Statistic@2a02:3035:666:b7d5:4e00:1517:7b0c:d0aa) (Quit: Client closed)
2025-09-16 02:58:50 StatisticalIndep joins (~Statistic@2a02:3035:666:b7d5:4e00:1517:7b0c:d0aa)
2025-09-16 02:59:35 <geekosaur> Maps are actually more complex than that: "The implementation of Map is based on size balanced binary trees (or trees of bounded balance)" (from the documentation)
2025-09-16 02:59:48 <StatisticalIndep> Ah, yes, i remembered something like that!
2025-09-16 03:00:55 <geekosaur> which is another reason you must marshal/unmarshal, because it's asking far too much for other languages to have to figure out how Map is a size-balanced binary tree or Seq is a fingertree, etc.
2025-09-16 03:01:15 <StatisticalIndep> Yep.
2025-09-16 03:01:51 <hololeap> makes sense that Map is a binary tree, given the (Ord k) constraint on most operations
2025-09-16 03:03:14 <StatisticalIndep> I just wish I could tell Haskell: to point every pointer to an Int, in e.g. a fixey list of Ints, to a pointer location in a block of mmapped data that contains unboxed ints in exactly the same format as GHC expects them.
2025-09-16 03:03:56 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-09-16 03:04:08 <geekosaur> hypothetically could be done. would really complicate GC, though
2025-09-16 03:04:25 arandombit joins (~arandombi@2603:7000:4600:ffbe:21ee:ceac:8353:7a15)
2025-09-16 03:04:25 × arandombit quits (~arandombi@2603:7000:4600:ffbe:21ee:ceac:8353:7a15) (Changing host)
2025-09-16 03:04:25 arandombit joins (~arandombi@user/arandombit)
2025-09-16 03:04:28 <geekosaur> and probably make it a lot more expensive, if it has to check if every pointer actually lives in the heap or not
2025-09-16 03:04:31 <StatisticalIndep> hololeap: It also makes sense from a standpoint of variables being constants in Haskell, and there hence being no such thing as an “insertion”. (The tree has to be reconstructed from the zipper instead.)
2025-09-16 03:05:50 <StatisticalIndep> geekosaur: Oh, I forgot about GC. Okay, that seals the deal. All those features are more valuable than having that bit of non-marshalled mapping elegance.
2025-09-16 03:07:21 <geekosaur> we do actually have such a thing as pinned memory, but it's only applicable to ByteArray# and it's handled via an exception list (and I seem to recall hearing of programs that heavily use ByteStrings getting slow because the exception list isn't very efficient?)
2025-09-16 03:08:33 <geekosaur> GC assumes pinned memory is an exception, not the rule
2025-09-16 03:08:40 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 245 seconds)
2025-09-16 03:10:38 aforemny joins (~aforemny@2001:9e8:6cce:4800:55ab:c43e:17dc:ff6c)
2025-09-16 03:11:14 × aforemny_ quits (~aforemny@i59F4C711.versanet.de) (Ping timeout: 256 seconds)
2025-09-16 03:13:13 <hololeap> made me remember this: https://www.channable.com/tech/lessons-in-managing-haskell-memory
2025-09-16 03:16:56 <StatisticalIndep> In any case, (mmapWithFilePtr "mm" ReadWrite Nothing $ \ (p, _) -> sequence_ $ zipWith (\ c i -> poke (plusPtr p i) c) "ME GO TOO FAR!" [0..]) works nicely enough. ;) (Yes, I know this will break with multi-byte chars.)
2025-09-16 03:19:43 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-09-16 03:22:12 dtman34 joins (~dtman34@c-73-242-68-179.hsd1.mn.comcast.net)
2025-09-16 03:24:50 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds)
2025-09-16 03:25:22 × xff0x quits (~xff0x@fsb6a9491c.tkyc517.ap.nuro.jp) (Remote host closed the connection)
2025-09-16 03:32:13 <StatisticalIndep> hololeap: Wow, they practically went to managing their memory manually, but with the GC becoming more of a problem than a use. So as if one would write it in C, but with a GC ghost attacking at night and reaping souls. XD … Yeah, definitely not the route I want to go. XD
2025-09-16 03:35:55 <hololeap> it's cool they got it working as well as they did, but yeah, it seems like it was a huge hassle
2025-09-16 03:37:07 <hololeap> geekosaur: do compact regions only work with ByteArray#
2025-09-16 03:37:29 <geekosaur> they work with anything but they're again special-cased
2025-09-16 03:38:08 <geekosaur> and the nature of that special casing is why they have so many restrictions, so they don't mess up GC too much (since the whole point of them is to get stuff out of GC's mitts)
2025-09-16 03:39:05 <geekosaur> in particular, once a pointer is found to point into a compact region, it's immediately dropped from consideration
2025-09-16 03:39:22 <hololeap> do they work with IORefs?
2025-09-16 03:39:31 <geekosaur> not usefully
2025-09-16 03:39:46 <geekosaur> I mean, they "do" but the contents of the IORef must also be in the same compact region
2025-09-16 03:39:57 <geekosaur> which makes them effectively immmutable
2025-09-16 03:40:06 <hololeap> I see
2025-09-16 03:40:17 <hololeap> that makes sense
2025-09-16 03:44:44 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-09-16 03:45:03 × Axman6 quits (~Axman6@user/axman6) (Ping timeout: 240 seconds)
2025-09-16 03:45:06 × meinside quits (uid24933@id-24933.helmsley.irccloud.com) (Quit: Connection closed for inactivity)
2025-09-16 03:48:18 <StatisticalIndep> I wonder if it’s possible to be very cheeky, and point a … uuum… completely unrelated (I swear) pointer to that same compact region, and write different values into variables, without telling the runtime. :D
2025-09-16 03:48:18 <hololeap> I recently discovered the Haskell Interlude podcast
2025-09-16 03:49:15 <hololeap> I'd never typed "haskell" into the search bar for podcasts before that
2025-09-16 03:49:32 <jreicher> StatisticalIndep: you want to go behind the back of the runtime providing you the safety that draws you to it in the first place? (Or have I misunderstood?)
2025-09-16 03:49:46 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 256 seconds)
2025-09-16 03:49:59 peterbecich joins (~Thunderbi@syn-172-222-149-049.res.spectrum.com)

All times are in UTC.