2024/11/19

Newest at the top

2024-11-19 14:40:00 +0100 <dminuoso> bwe: (I have added the constraint just as an example, since many uses of Proxy usually only make sense together with a constraint)
2024-11-19 14:39:53 +0100 <hellwolf> but it was fun to discover the N ways of doing the same thing.
2024-11-19 14:39:52 +0100rvalue(~rvalue@user/rvalue) rvalue
2024-11-19 14:39:42 +0100 <hellwolf> Leary: in that case, I still think either has lower requirement of for Haskell knowledge for readability
2024-11-19 14:39:35 +0100bitdex(~bitdex@gateway/tor-sasl/bitdex) (Quit: = "")
2024-11-19 14:39:31 +0100 <[exa]> Is there any "good natural" way to make an instances for `Ord (Tree a)` other than what is in Data.Tree? The one there is the automatic one obtained with `deriving`, i.e. basically follows the syntax. I feel like that ordering is very left-subtree-biased but no idea how to compensate for that (and esp. if there's some ground reason for why not).
2024-11-19 14:39:29 +0100 <dminuoso> Which is essentially just `f :: forall proxy a. HasFoo a => proxy a -> ...`
2024-11-19 14:39:10 +0100 <dminuoso> bwe: i.e. `f :: HasFoo a => proxy a -> ...`
2024-11-19 14:38:44 +0100 <dminuoso> bwe: No, as a type variable.
2024-11-19 14:38:41 +0100 <Leary> hellwolf: All approaches should optimise to pretty much the same code; it shouldn't matter.
2024-11-19 14:38:38 +0100 <bwe> dminuoso: Do you mean I should define `proxy` as my own function? I don't find `proxy` in https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-Proxy.html
2024-11-19 14:38:37 +0100 <hellwolf> I mean, okay, what is the second example of proxy? from a differenr base, perhaps?
2024-11-19 14:38:20 +0100 <dminuoso> hellwolf: It allows for arbitrary parameterized types.
2024-11-19 14:38:05 +0100 <hellwolf> dminuoso: I never understood that. I see base code having lower case proxy in many places. why?
2024-11-19 14:37:54 +0100L29Ah(~L29Ah@wikipedia/L29Ah) ()
2024-11-19 14:37:15 +0100 <dminuoso> bwe: For extra points parameterize by `proxy Foo` rather than `Proxy `Foo`
2024-11-19 14:37:07 +0100 <hellwolf> is Const a r Coercible with a?
2024-11-19 14:36:45 +0100 <dminuoso> bwe: Yeah, just use Proxy.
2024-11-19 14:36:24 +0100 <dminuoso> Leary: That `find (const True)` is cunning. :-)
2024-11-19 14:36:20 +0100 <bwe> dminuoso: that's exactly where I am stuck right now: applying a function wrapped in a Const to values wrapped in Const
2024-11-19 14:36:09 +0100 <hellwolf> Leary: I could balance between readability (which is subjective, up to the code reader's knowledge about all these instances) and performance; so what about any performance consideration?
2024-11-19 14:35:48 +0100rvalue(~rvalue@user/rvalue) (Ping timeout: 265 seconds)
2024-11-19 14:35:23 +0100 <dminuoso> And it will probably require using ScopedTypeVariables and some annoyances.
2024-11-19 14:35:11 +0100 <dminuoso> Const will constantly (the pun!) be in the way because you need to wrap/unwrap potentially many times
2024-11-19 14:34:51 +0100 <dminuoso> bwe: Id say Proxy is the least akward and most common way.
2024-11-19 14:34:21 +0100 <Leary> Personally, I would go with `asum`. Either way, get them from `Data.Foldable`; a `Data.List` import suggests list specialisation (which could actually happen at some point).
2024-11-19 14:31:48 +0100 <hellwolf> import Data.List (find) is required though
2024-11-19 14:31:38 +0100 <hellwolf> hard to choose :)
2024-11-19 14:31:00 +0100 <hellwolf> either (const Nothing) (Just . ADDR) (S.decode b)
2024-11-19 14:30:59 +0100 <hellwolf> or
2024-11-19 14:30:53 +0100 <hellwolf> fmap ADDR . find (const True) $ S.decode b
2024-11-19 14:28:28 +0100 <hellwolf> Left elements are mempty, right elements are actually "foldable"
2024-11-19 14:28:05 +0100 <hellwolf> it all hinges all the fact of the Foldable Either instance.
2024-11-19 14:27:46 +0100 <hellwolf> that's very cute, indeed
2024-11-19 14:19:34 +0100housemate(~housemate@2a04:9dc0:0:162::5d91:d7ed) housemate
2024-11-19 14:10:18 +0100housemate(~housemate@2a04:9dc0:0:162::5d91:d7ed) (Ping timeout: 244 seconds)
2024-11-19 14:07:17 +0100 <Leary> hellwolf: ^
2024-11-19 14:07:14 +0100 <yahb2> find \_ -> True :: Foldable t => t a -> Maybe a
2024-11-19 14:07:14 +0100 <Leary> % :t find \_ -> True
2024-11-19 14:07:08 +0100 <Leary> Oh, bit late, but I thought of something cute and silly!
2024-11-19 14:05:37 +0100sand-witch(~m-mzmz6l@vmi833741.contaboserver.net)
2024-11-19 14:01:28 +0100ash3en(~Thunderbi@2a03:7846:b6eb:101:93ac:a90a:da67:f207) (Remote host closed the connection)
2024-11-19 14:01:21 +0100ash3en(~Thunderbi@2a03:7846:b6eb:101:93ac:a90a:da67:f207) ash3en
2024-11-19 14:01:13 +0100acidjnk_new(~acidjnk@p200300d6e7283f33f1310e0154b357f3.dip0.t-ipconnect.de) acidjnk
2024-11-19 14:01:03 +0100ash3en(~Thunderbi@2a03:7846:b6eb:101:93ac:a90a:da67:f207) (Quit: ash3en)
2024-11-19 14:00:27 +0100Digit(~user@user/digit) Digit
2024-11-19 13:56:49 +0100acidjnk_new(~acidjnk@p200300d6e7283f33f1310e0154b357f3.dip0.t-ipconnect.de) (Ping timeout: 248 seconds)
2024-11-19 13:56:10 +0100tromp(~textual@92-110-219-57.cable.dynamic.v4.ziggo.nl) (Quit: My iMac has gone to sleep. ZZZzzz…)
2024-11-19 13:56:06 +0100lxsameer(~lxsameer@Serene/lxsameer) (Ping timeout: 252 seconds)
2024-11-19 13:52:13 +0100 <hellwolf> right. I also misread the original question, in the first place.