Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,801,874 events total
2025-12-05 08:12:13 annamalai joins (~annamalai@157.32.204.27)
2025-12-05 08:12:28 × Sgeo quits (~Sgeo@user/sgeo) (Read error: Connection reset by peer)
2025-12-05 08:13:34 <dminuoso> lucabtz: Do you just intend to define <*> but not pure?
2025-12-05 08:14:21 <dminuoso> https://hackage.haskell.org/package/semigroupoids-6.0.1/docs/Data-Functor-Apply.html#t:Apply
2025-12-05 08:14:53 <dminuoso> And in case you just care about pure, https://hackage.haskell.org/package/pointed-5.0.5/docs/Data-Pointed.html#t:Pointed
2025-12-05 08:16:01 <[exa]> reading the wiki here https://wiki.haskell.org/index.php?title=Top_level_mutable_state it says "In contrast, other 'approved' uses of unsafePerformIO are perfectly safe."
2025-12-05 08:16:08 <[exa]> ...is that a joke? (can't tell)
2025-12-05 08:16:54 <[exa]> lucabtz: probably depends on how much partial
2025-12-05 08:17:44 <dminuoso> [exa]: Of course "approved" is quite a nebulous term. If "approved" means "perfectly safe", that statement is absolutely correct.
2025-12-05 08:17:54 <jackdk> lucabtz: I would write code against a different typeclass (class Apply from semigroupoids, for example) or provide a different named function. The benefit of a programming culture where people only write complete and lawful instances, is that anyone writing polymorphic code can expect their code to work for any instance, instead of for "any instance except a growing list of exceptions"
2025-12-05 08:18:03 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-12-05 08:18:57 <dminuoso> Plus, you may later refactor and reuse some other library that imposes a `Applicative` constraint - it may not even be obvious that you're tapping into a bottom. It's a mine waiting to be stepped on.
2025-12-05 08:19:24 <jackdk> I personally also shy away from using `class Pointed`, for reasons Ed writes about at https://wiki.haskell.org/Why_not_Pointed%3F
2025-12-05 08:21:53 <ski> > (0 :: Natural) - 1
2025-12-05 08:21:57 <lambdabot> *Exception: arithmetic underflow
2025-12-05 08:22:10 <[exa]> naturally...
2025-12-05 08:22:49 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds)
2025-12-05 08:24:43 <[exa]> dminuoso: well that gives kinda circular definition of approved :D
2025-12-05 08:24:53 <dminuoso> Of course.
2025-12-05 08:25:12 <[exa]> "it works"
2025-12-05 08:30:11 tromp joins (~textual@2001:1c00:3487:1b00:4ec:c6c9:2447:6676)
2025-12-05 08:30:55 <lucabtz> dminuoso no both pure and <*>, but <*> will be a partial function
2025-12-05 08:32:19 <lucabtz> i have a type Grid a which is a grid of data and i want something similar to numpy's broadcasting
2025-12-05 08:33:26 <lucabtz> i need a function Grid (a -> b) -> Grid a -> Grid b which is <*>, but this needs to work only if broadcasting is possible (so for some conditions over the grids width and height)
2025-12-05 08:33:33 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-12-05 08:33:36 <lucabtz> pure can just embed in a 1x1 Grid
2025-12-05 08:35:02 <lucabtz> by partial i mean it will call error if broadcasting is not possible
2025-12-05 08:35:41 <lucabtz> maybe it is just better to have another function for all of this so i can put HasCallStack too, even if it will have the same signature as <*>
2025-12-05 08:37:29 <ski> when is it possible/impossible ?
2025-12-05 08:38:20 lambda_gibbon joins (~lambda_gi@2603:7080:ee00:37d8:35d4:1aac:9a2f:cd11)
2025-12-05 08:39:01 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds)
2025-12-05 08:39:07 <lucabtz> either widths are equal or some are 1 and same for height
2025-12-05 08:39:53 <lucabtz> if you have say (w, 1) (w, h) the result is (w, h) and the first one is broadcasted to (w, h) by repeating the row h times over the columns
2025-12-05 08:40:28 <lucabtz> technically i suppose you could weaken the constraint with divisibility instead of 1, but it is not like that in numpy
2025-12-05 08:40:41 <lucabtz> *instead of equality to 1
2025-12-05 08:40:49 <ski> (m0 == m1 || any (1 ==) [m0,m1]) && (n0 == n1 || any (1 ==) [n0,n1]) -- ?
2025-12-05 08:41:05 <lucabtz> yep
2025-12-05 08:42:24 <ski> if you take assocative law, such that all applications on one side satisfies this condition, do the ones on the other side also satisfy it ?
2025-12-05 08:42:56 × lambda_gibbon quits (~lambda_gi@2603:7080:ee00:37d8:35d4:1aac:9a2f:cd11) (Ping timeout: 256 seconds)
2025-12-05 08:43:44 <ski> (and similarly for the other laws)
2025-12-05 08:44:39 <ski> it'd be annoying, if rewriting a total use, with one of the laws, would give a partial use
2025-12-05 08:45:16 <ski> btw, i'd probably just define a separate function
2025-12-05 08:45:49 <ski> (i don't much like this kind of implicit broadcasting)
2025-12-05 08:49:21 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-12-05 08:52:46 × tzh quits (~tzh@c-76-115-131-146.hsd1.or.comcast.net) (Quit: zzz)
2025-12-05 08:53:55 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 265 seconds)
2025-12-05 08:54:32 × peterbecich quits (~Thunderbi@172.222.148.214) (Ping timeout: 244 seconds)
2025-12-05 08:55:06 <lucabtz> im a bit confused by what associative law you are speaking about
2025-12-05 08:55:18 <lucabtz> <*> is not associative
2025-12-05 08:55:39 <lucabtz> though i agree it would make more sense to keep it a separate function
2025-12-05 08:57:45 acidjnk joins (~acidjnk@p200300d6e7171916e981ce74d2c64e2e.dip0.t-ipconnect.de)
2025-12-05 09:01:19 × trickard quits (~trickard@cpe-85-98-47-163.wireline.com.au) (Read error: Connection reset by peer)
2025-12-05 09:01:33 trickard_ joins (~trickard@cpe-85-98-47-163.wireline.com.au)
2025-12-05 09:03:03 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-12-05 09:03:12 fp joins (~Thunderbi@130.233.70.22)
2025-12-05 09:03:21 bggd joins (~bgg@2a01:e0a:fd5:f510:b178:c96:453a:4d0f)
2025-12-05 09:08:25 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds)
2025-12-05 09:08:28 <ski> u <*> (v <*> w) = pure (.) <*> u <*> v <*> w -- <https://wiki.haskell.org/Typeclassopedia#Laws_2>
2025-12-05 09:08:40 <ski> that law is a kind of associativity law
2025-12-05 09:09:00 chele joins (~chele@user/chele)
2025-12-05 09:09:33 × emmanuelux quits (~emmanuelu@user/emmanuelux) (Remote host closed the connection)
2025-12-05 09:10:50 <lucabtz> if you mean that it does satisfy it i believe, the constraint becomes for each width and height that all the ones that are not equal to each other are 1
2025-12-05 09:12:43 <ski> (do note that `pure (.) <*> u <*> v <*> w' means `((pure (.) <*> u) <*> v) <*> w', so that that side is left-associated)
2025-12-05 09:13:05 <ski> liftA2 (\a (b,c) -> (a,b,c)) ia (liftA2 (,) ib ic) = liftA2 (\(a,b) c -> (a,b,c)) (liftA2 (,) ia ib) ic -- same law, in terms of `liftA2', and tuples, might make the name "associativity" more reasonable
2025-12-05 09:13:16 <lucabtz> yeah i get what you mean
2025-12-05 09:14:47 <ski> liftA2 (uncurry . f) ia (liftA2 (,) ib ic) = liftA2 (uncurry f) (liftA2 (,) ia ib) ic -- or, with an arbitrary function `f', rather than triples
2025-12-05 09:15:16 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-12-05 09:15:38 <lucabtz> it's okay i understood already from u <*> (v <*> w) = pure (.) <*> u <*> v <*> w
2025-12-05 09:16:16 <lucabtz> it's not literal associativity of <*> but i get it makes sense to call is associativity
2025-12-05 09:16:53 <lucabtz> literal associativity of <*> makes no sense because the domains of the operator on the left and right are different
2025-12-05 09:17:38 <ski> anyway, the question is whether in `(M * N) * O' and `M * (N * O)', where `*' is some operation doing this kind of broadcasting, whether `M * N' and then `(M * N) * O' is well-defined is equivalent to `N * O' and then `M * (N * O)' being well-defined
2025-12-05 09:19:03 <lucabtz> i still think it is satified by broadcasting, for example say in order you have (w, 1) <*> (1, h) <*> (w, h), associating on the left you have (w, 1) <*> (1, h) = (w, h) and then (w, h) <*> (w, h) = (w, h), on the right (1, h) <*> (w, h) = (w, h) and then (w, 1) <*> (w, h) = (w, h)
2025-12-05 09:19:49 <ski> (yea .. in terms of `liftA2 (,) :: Applicative i => i a -> i b -> i (a,b)', we're asking whether this operation is associative, up to reassociating the `((a,b),c)' vs. `(a,(b,c))' in the result. it's just that we then have rexpressed this (not "on the nose") associative law in terms of its equivalent condition in terms of `(<*>)')
2025-12-05 09:20:07 × merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2025-12-05 09:22:21 <ski> hm, yea, i think you're right (after pondering the conditions)
2025-12-05 09:22:24 <lucabtz> i dont see why associativity wouldnt be satified here because this is just about tiling up the grids to match the bigger grid, if the grids are all equal then associativity is a consequence of associativity of ., if some have dimension 1 it shouldn't matter when you tile them bigger
2025-12-05 09:23:01 <lucabtz> though honestly idk if it is so trivial to come up with an actual proof, maybe it is
2025-12-05 09:23:12 merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl)
2025-12-05 09:28:10 lambda_gibbon joins (~lambda_gi@2603:7080:ee00:37d8:35d4:1aac:9a2f:cd11)
2025-12-05 09:28:35 <ski> you just have to handle all the cases
2025-12-05 09:28:58 <lucabtz> i suppose maybe it can be shown for 1D grids where there a are few cases and then handled inductively for all dimensions
2025-12-05 09:29:45 <ski> since it is uniform in the dimensions, you only need to consider an arbitrary dimension, yes
2025-12-05 09:32:36 × lambda_gibbon quits (~lambda_gi@2603:7080:ee00:37d8:35d4:1aac:9a2f:cd11) (Ping timeout: 252 seconds)
2025-12-05 09:33:37 trickard_ is now known as trickard
2025-12-05 09:43:15 humasect joins (~humasect@dyn-192-249-132-90.nexicom.net)
2025-12-05 09:44:11 × humasect quits (~humasect@dyn-192-249-132-90.nexicom.net) (Remote host closed the connection)
2025-12-05 09:44:56 humasect joins (~humasect@dyn-192-249-132-90.nexicom.net)
2025-12-05 09:52:31 × xff0x quits (~xff0x@fsb6a9491c.tkyc517.ap.nuro.jp) (Ping timeout: 264 seconds)
2025-12-05 10:06:26 __monty__ joins (~toonn@user/toonn)
2025-12-05 10:20:13 × tromp quits (~textual@2001:1c00:3487:1b00:4ec:c6c9:2447:6676) (Quit: My iMac has gone to sleep. ZZZzzz…)
2025-12-05 10:23:10 × trickard quits (~trickard@cpe-85-98-47-163.wireline.com.au) (Read error: Connection reset by peer)
2025-12-05 10:23:24 trickard_ joins (~trickard@cpe-85-98-47-163.wireline.com.au)
2025-12-05 10:23:50 tromp joins (~textual@2001:1c00:3487:1b00:4ec:c6c9:2447:6676)
2025-12-05 10:24:30 chencheng joins (~chencheng@38.207.158.7)
2025-12-05 10:24:44 × chencheng quits (~chencheng@38.207.158.7) (Changing host)
2025-12-05 10:24:44 chencheng joins (~chencheng@user/chencheng)
2025-12-05 10:33:25 lambda_gibbon joins (~lambda_gi@2603:7080:ee00:37d8:35d4:1aac:9a2f:cd11)
2025-12-05 10:33:37 × trickard_ quits (~trickard@cpe-85-98-47-163.wireline.com.au) (Ping timeout: 264 seconds)
2025-12-05 10:34:08 × chencheng quits (~chencheng@user/chencheng) (Quit: Client closed)
2025-12-05 10:34:40 trickard_ joins (~trickard@cpe-85-98-47-163.wireline.com.au)

All times are in UTC.