Newest at the top
2024-10-14 03:19:37 +0200 | <dolio> | Oh. Well, you can parameterize the map functor multiple ways, I think. But it's not going to happen very locally. |
2024-10-14 03:18:46 +0200 | <geekosaur> | within the same module |
2024-10-14 03:18:39 +0200 | <geekosaur> | local open, I think, so you can parameteerize different maps differently? |
2024-10-14 03:18:33 +0200 | alexherbo2 | (~alexherbo@2a02-8440-3108-bfa0-ddfb-d52c-f0fd-2cc2.rev.sfr.net) alexherbo2 |
2024-10-14 03:18:04 +0200 | <dolio> | What part can't backpack do? Not that it's nice to do this. |
2024-10-14 03:17:35 +0200 | <monochrom> | But here is a clean hack someone and I thought up: https://mail.haskell.org/pipermail/haskell-cafe/2017-May/127147.html |
2024-10-14 03:17:22 +0200 | alexherbo2 | (~alexherbo@2a02-8440-3108-bfa0-f1d8-4d0f-e5fc-d7b0.rev.sfr.net) (Remote host closed the connection) |
2024-10-14 03:15:57 +0200 | <monochrom> | I think it is the whole point. When some abuses have just causes and don't count as abuses. |
2024-10-14 03:15:21 +0200 | <monochrom> | Yes it totally can. |
2024-10-14 03:15:07 +0200 | <geekosaur> | I did for a moment wonder if that could be abused to do this… |
2024-10-14 03:15:03 +0200 | <probie> | Haskell's way means I can't safely use a `Double` as a key in a `Map` without needing to wrap it in a newtype |
2024-10-14 03:14:58 +0200 | raehik | (~raehik@rdng-25-b2-v4wan-169990-cust1344.vm39.cable.virginm.net) raehik |
2024-10-14 03:14:58 +0200 | <monochrom> | :( :) |
2024-10-14 03:14:47 +0200 | <c_wraith> | And if you *really* need bad hacks, just remember there's always the reflection package! |
2024-10-14 03:13:56 +0200 | <geekosaur> | (I like SML/NJ's approach, but not so much that I'm abandoning Haskell for it…) |
2024-10-14 03:13:32 +0200 | <monochrom> | Eh, I think Haskell has a nice way and SML has a nice way. |
2024-10-14 03:13:07 +0200 | <probie> | s/" does/does"/ |
2024-10-14 03:12:34 +0200 | <monochrom> | A user will have to do everything under the same instantiate call. user = let m{empty, insert, union} = instantiate myCompare in union (insert 2 (insert 3 empty)) (insert 1 (insert 2 empty))) |
2024-10-14 03:12:15 +0200 | <geekosaur> | right, I meant the latter |
2024-10-14 03:12:10 +0200 | tonyday567 | (~tonyday56@125-63-10-162.ip4.superloop.au) |
2024-10-14 03:11:53 +0200 | <probie> | I think we're probably all in agreement about every fact here. I just misinterpreted intent and mistook the comment as "Haskell should do what SML/NJ" does, not "SML/NJ does this in a nice a way, unlike Haskell" |
2024-10-14 03:11:18 +0200 | <geekosaur> | Inst did earlier hint that he thought we were trying to find ways to emulate OOP in Haskell. (No, we aren't. OOP is something else. If I want OOP, I'll use an OO language, not Haskell; I have and use multiple tools.) |
2024-10-14 03:10:28 +0200 | merijn | (~merijn@128-137-045-062.dynamic.caiway.nl) (Ping timeout: 252 seconds) |
2024-10-14 03:10:02 +0200 | <monochrom> | instantiate :: (a -> a -> Ordering) -> M a; instantiate cmp = M{empty = ... ; insert = ... use cmp ..., union = ... use cmp ..., etc} |
2024-10-14 03:08:48 +0200 | <monochrom> | data M a = forall t. M{empty :: t, insert :: a -> t -> t, union :: t -> t -> a, etc etc} |
2024-10-14 03:08:14 +0200 | zmt00 | (~zmt00@user/zmt00) zmt00 |
2024-10-14 03:07:13 +0200 | <monochrom> | I will also need existential type. |
2024-10-14 03:06:40 +0200 | <geekosaur> | and I don't think Backpack can quite pull off emulating this, for all its pretensions toward providing MLish "functors" |
2024-10-14 03:06:09 +0200 | <geekosaur> | that was my point: you don't. we use a typeclass hack instead |
2024-10-14 03:06:05 +0200 | <monochrom> | Haskell doesn't have SML's parameterized module system. OK OK I will emulate it. |
2024-10-14 03:05:38 +0200 | <probie> | But how do you do that in Haskell? |
2024-10-14 03:05:25 +0200 | <monochrom> | So use the same suite to create two maps and use the same suite to union the two maps. |
2024-10-14 03:04:57 +0200 | <geekosaur> | right |
2024-10-14 03:04:48 +0200 | <monochrom> | Recall that an instantiated module gives you a suite of map functions, not a map. |
2024-10-14 03:04:16 +0200 | <monochrom> | You can union two maps created from the same instantiated module. |
2024-10-14 03:03:47 +0200 | merijn | (~merijn@128-137-045-062.dynamic.caiway.nl) merijn |
2024-10-14 03:03:41 +0200 | <geekosaur> | isn't that kinda the point, though? |
2024-10-14 03:03:15 +0200 | <probie> | geekosaur: without the one true Ord instance for a type, how do you efficiently union two maps? SML/NJ sidesteps this because two maps instantiated with different ORD_KEYs will be different types. |
2024-10-14 02:58:15 +0200 | <monochrom> | Perhaps the misguided want of localized unexported instances comes from mistaking type classes for OO interfaces. |
2024-10-14 02:55:29 +0200 | peterbecich | (~Thunderbi@syn-047-229-123-186.res.spectrum.com) peterbecich |
2024-10-14 02:52:52 +0200 | merijn | (~merijn@128-137-045-062.dynamic.caiway.nl) (Ping timeout: 252 seconds) |
2024-10-14 02:48:45 +0200 | <Square> | jackdk, thanks |
2024-10-14 02:47:58 +0200 | merijn | (~merijn@128-137-045-062.dynamic.caiway.nl) merijn |
2024-10-14 02:45:03 +0200 | Guest66 | (~Guest66@2601:152:4a80:2300:c948:b43e:8f75:aa7b) (Quit: Client closed) |
2024-10-14 02:40:49 +0200 | <geekosaur> | *not determined by |
2024-10-14 02:39:31 +0200 | <geekosaur> | (the Ord instance equivalent is owned by the Map, not by what Ord instance is in scope at use sites) |
2024-10-14 02:38:24 +0200 | <geekosaur> | well, for that one it's actually something of a hack. IMO SML/NJ does it the right way |
2024-10-14 02:37:47 +0200 | <jackdk> | IMHO no. That way lies madness, like the producer and consumer of a `Ord k => Map k v` disagreeing on which `Ord` to use for `k`. And then you just can't find entries which you are 100% certain that you put into your map. |
2024-10-14 02:37:38 +0200 | <geekosaur> | and the only way to prevent incoherence is to force instances to be global |
2024-10-14 02:37:19 +0200 | <geekosaur> | not when it leads to incoherence, no |