Logs: liberachat/#haskell
| 2025-10-21 15:10:06 | → | annamalai joins (~annamalai@157.49.253.239) |
| 2025-10-21 15:15:36 | → | Googulator11 joins (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) |
| 2025-10-21 15:16:10 | × | Googulator quits (~Googulato@92-249-221-245.pool.digikabel.hu) (Quit: Client closed) |
| 2025-10-21 15:16:43 | <bwe> | updated: https://paste.tomsmeding.com/ahtW4uic |
| 2025-10-21 15:20:02 | <Leary> | bwe: Why are you trying to use a typeclass for this in the first place? Just `case` on the `SiteName`. |
| 2025-10-21 15:23:49 | <bwe> | Leary: Well, I have a bunch of functions with same name for different SiteName. How would I do it in a straightforward way with case? Also for code organisation, I can put SiteA in a single file. |
| 2025-10-21 15:25:47 | → | machinedgod joins (~machinedg@d75-159-126-101.abhsia.telus.net) |
| 2025-10-21 15:27:32 | Googulator11 | is now known as Googulator |
| 2025-10-21 15:32:50 | <Leary> | By making them different branches of the same function. |
| 2025-10-21 15:37:29 | <kuribas> | bwe: why does it take a proxy? |
| 2025-10-21 15:37:44 | <kuribas> | detFieldA (SiteADto dto) <= not a proxy. |
| 2025-10-21 15:38:45 | × | tromp quits (~textual@2001:1c00:3487:1b00:75ad:6ea9:b519:8422) (Quit: My iMac has gone to sleep. ZZZzzz…) |
| 2025-10-21 15:38:51 | <bwe> | Leary: I feel it might even organise the code better, but still, having each variant completely defined under a type instance has some appeal. |
| 2025-10-21 15:39:11 | <bwe> | kuribas: I corrected it in the updated paste: https://paste.tomsmeding.com/ahtW4uic |
| 2025-10-21 15:39:11 | <kuribas> | bwe: don't you want lenses, instead of type classes? |
| 2025-10-21 15:39:32 | × | Zemy_ quits (~Zemy@12.50.240.58) (Read error: Connection reset by peer) |
| 2025-10-21 15:39:33 | → | Zemy joins (~Zemy@2600:100c:b0a1:1595:d8dd:61ff:fe3f:6089) |
| 2025-10-21 15:39:57 | → | Frostillicus joins (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) |
| 2025-10-21 15:40:02 | <kuribas> | I would avoid typeclasses, and just pattern match on the cases. |
| 2025-10-21 15:40:03 | → | Zemy_ joins (~Zemy@syn-192-154-181-091.biz.spectrum.com) |
| 2025-10-21 15:40:26 | <kuribas> | Just rename your functions, instead of having the same name. |
| 2025-10-21 15:40:39 | → | Googulator43 joins (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) |
| 2025-10-21 15:40:39 | × | Googulator quits (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-21 15:41:01 | <bwe> | kuribas: lenses to avoid the case, I get that now. |
| 2025-10-21 15:42:39 | <bwe> | kuribas: So, in the end, you advise me to branch within the function between the different implementations, correct? Of course, the implementations could live in their own functions that are defined elsewhere. |
| 2025-10-21 15:43:27 | <kuribas> | lenses to extract data. |
| 2025-10-21 15:43:38 | <kuribas> | Pattern matching if you have a closed set of alternatives. |
| 2025-10-21 15:43:50 | → | inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 15:44:22 | × | Zemy quits (~Zemy@2600:100c:b0a1:1595:d8dd:61ff:fe3f:6089) (Ping timeout: 260 seconds) |
| 2025-10-21 15:44:59 | <kuribas> | Otherwise a typeclass HasFoo a => a -> Foo, where Foo is the data you want to extract (can be a sumtype). |
| 2025-10-21 15:45:49 | × | inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Max SendQ exceeded) |
| 2025-10-21 15:46:14 | → | inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 15:47:08 | × | inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Max SendQ exceeded) |
| 2025-10-21 15:47:33 | → | inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 15:48:33 | × | inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Client Quit) |
| 2025-10-21 15:48:38 | <bwe> | kuribas: But in my case I've got a standardised `a`, namely `SiteDto`, over all alternatives (and the variants are differentiated inside the `SiteDto`). I am not sure whether I understand your take on typeclass. It sounds that it's working differently than my attempt, is it? |
| 2025-10-21 15:48:43 | → | marinelli joins (~weechat@gateway/tor-sasl/marinelli) |
| 2025-10-21 15:49:20 | × | akegalj quits (~akegalj@189-192.dsl.iskon.hr) (Quit: leaving) |
| 2025-10-21 15:49:29 | <kuribas> | I honestly have no idea what you are trying to do... |
| 2025-10-21 15:50:03 | <kuribas> | If you only have SiteDto, why do you need typeclasses? |
| 2025-10-21 15:51:09 | <bwe> | Basically, I have a set of functions for each SiteName that take `SiteDto` in and switch between different implementations of the functions depending on `SiteName`. |
| 2025-10-21 15:52:18 | <bwe> | kuribas: As mentioned above, I'd have this way all implementations for one variant in one place / file / module. |
| 2025-10-21 15:52:55 | <kuribas> | So siteFoo siteStuff = case siteName siteStuff of "site1" -> foo1 siteStuff; "site2" -> foo2 siteStuff; ... |
| 2025-10-21 15:53:03 | → | inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 15:54:08 | × | Zemy_ quits (~Zemy@syn-192-154-181-091.biz.spectrum.com) (Read error: Connection reset by peer) |
| 2025-10-21 15:54:09 | → | Zemy joins (~Zemy@2600:100c:b0a1:1595:88ce:68ff:fe2b:a820) |
| 2025-10-21 15:54:24 | × | inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Max SendQ exceeded) |
| 2025-10-21 15:54:36 | <kuribas> | or build "siteConfig :: HashMap Text SiteImpl", and pass that around? |
| 2025-10-21 15:54:39 | → | Zemy_ joins (~Zemy@12.50.240.58) |
| 2025-10-21 15:55:14 | → | inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 15:56:00 | <bwe> | kuribas: I think I need to turn to the pattern matching / case variant. And from that experience I can move on. |
| 2025-10-21 15:56:06 | × | Zemy_ quits (~Zemy@12.50.240.58) (Read error: Connection reset by peer) |
| 2025-10-21 15:56:13 | → | Zemy_ joins (~Zemy@2600:100c:b0a1:1595:c07:48ff:fee4:974) |
| 2025-10-21 15:56:29 | inline | is now known as Guest8492 |
| 2025-10-21 15:56:47 | <bwe> | Well, ten functions means ten times pattern matching on SiteName, right? Any idea how to simplify this? |
| 2025-10-21 15:56:53 | → | Core3629 joins (~Zemy@syn-192-154-181-091.biz.spectrum.com) |
| 2025-10-21 15:57:07 | <kuribas> | It's simple enough, no? |
| 2025-10-21 15:57:24 | <kuribas> | I don't think going typelevel strings is simpler. |
| 2025-10-21 15:57:31 | <bwe> | Me neither :). |
| 2025-10-21 15:58:28 | × | Zemy quits (~Zemy@2600:100c:b0a1:1595:88ce:68ff:fe2b:a820) (Ping timeout: 246 seconds) |
| 2025-10-21 15:58:49 | → | Inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 15:59:15 | <bwe> | That's actually one advantage of type class version: I don't have to pattern match for each function anew. Well, actually I also do this in the type signatures using `proxy SiteDtoA`. |
| 2025-10-21 15:59:43 | <bwe> | So, thanks for your inputs and encouragement to keep things simple Leary and kuribas. |
| 2025-10-21 15:59:48 | × | Guest8492 quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Ping timeout: 256 seconds) |
| 2025-10-21 16:00:35 | <kuribas> | bwe: you still need to pattern match, you just use a complex mechanism (type instance inference) for it. |
| 2025-10-21 16:00:56 | × | Zemy_ quits (~Zemy@2600:100c:b0a1:1595:c07:48ff:fee4:974) (Ping timeout: 256 seconds) |
| 2025-10-21 16:01:22 | → | jmcantrell joins (~weechat@user/jmcantrell) |
| 2025-10-21 16:03:46 | → | tromp joins (~textual@2001:1c00:3487:1b00:75ad:6ea9:b519:8422) |
| 2025-10-21 16:04:20 | × | Inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Remote host closed the connection) |
| 2025-10-21 16:04:59 | → | Inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 16:06:31 | × | Inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Max SendQ exceeded) |
| 2025-10-21 16:07:06 | → | Inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 16:07:36 | <bwe> | kuribas: That's so true. Are LambdaCase and ViewPattern (and how lenses) here of any help to pattern match on a record that carries `SiteName`? |
| 2025-10-21 16:07:51 | × | Inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Remote host closed the connection) |
| 2025-10-21 16:08:13 | → | Inline joins (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) |
| 2025-10-21 16:09:39 | <kuribas> | Maybe. |
| 2025-10-21 16:10:08 | <kuribas> | I would keep "case siteName siteStuff of "site1" -> foo1 siteStuff; "site2" -> foo2 siteStuff; ..." |
| 2025-10-21 16:11:50 | <kuribas> | Or siteNameDispatch :: Text -> SiteFoo; siteGetFoo :: SiteDta -> SiteFoo; siteGetFoo siteDta = siteNameDispatch $ siteName siteDta |
| 2025-10-21 16:12:33 | <Leary> | bwe: You can re-order the pattern matching and function selection by collecting the site-specific functions into a record: https://play.haskell.org/saved/6BAZ0p1J |
| 2025-10-21 16:13:58 | × | chromoblob quits (~chromoblo@user/chromob1ot1c) (Ping timeout: 256 seconds) |
| 2025-10-21 16:17:21 | × | kuribas quits (~user@ip-188-118-57-242.reverse.destiny.be) (Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.3)) |
| 2025-10-21 16:21:54 | <bwe> | Leary: That's actually a nice approach, to consider, too. |
| 2025-10-21 16:22:18 | × | marinelli quits (~weechat@gateway/tor-sasl/marinelli) (Remote host closed the connection) |
| 2025-10-21 16:22:40 | → | marinelli joins (~weechat@gateway/tor-sasl/marinelli) |
| 2025-10-21 16:22:50 | × | Inline quits (~inline@2a02:8071:57a1:1260:9dcf:d8b:a04d:1320) (Remote host closed the connection) |
| 2025-10-21 16:22:51 | <bwe> | Instead of rolling the type instance, I am rolling a record that holds the functions. Yet still the switching is done by simple case. |
| 2025-10-21 16:23:10 | <bwe> | Leary: Thanks for coming up with that refreshing approach. |
| 2025-10-21 16:25:59 | → | Googulator20 joins (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) |
| 2025-10-21 16:26:02 | × | Square quits (~Square4@user/square) (Ping timeout: 248 seconds) |
| 2025-10-21 16:26:04 | × | Googulator43 quits (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-21 16:26:47 | → | chromoblob joins (~chromoblo@user/chromob1ot1c) |
| 2025-10-21 16:37:41 | × | chromoblob quits (~chromoblo@user/chromob1ot1c) (Read error: Connection reset by peer) |
| 2025-10-21 16:38:02 | → | chromoblob joins (~chromoblo@user/chromob1ot1c) |
| 2025-10-21 16:38:11 | × | Frostillicus quits (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) (Ping timeout: 250 seconds) |
| 2025-10-21 16:42:46 | × | tromp quits (~textual@2001:1c00:3487:1b00:75ad:6ea9:b519:8422) (Quit: My iMac has gone to sleep. ZZZzzz…) |
| 2025-10-21 16:42:49 | × | sord937 quits (~sord937@gateway/tor-sasl/sord937) (Quit: sord937) |
| 2025-10-21 16:45:35 | → | Googulator12 joins (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) |
| 2025-10-21 16:45:35 | × | Googulator20 quits (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-21 16:56:26 | → | notzmv joins (~umar@user/notzmv) |
| 2025-10-21 17:01:51 | → | Zemy joins (~Zemy@2600:100c:b0a1:1595:f890:feff:fef8:faa8) |
All times are in UTC.