2026/04/06

Newest at the top

2026-04-06 12:03:21 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-06 12:02:34 +0000TimWolla(~timwolla@2a01:4f8:150:6153:beef::6667) (Remote host closed the connection)
2026-04-06 12:01:21 +0000craunts795335385(~craunts@152.32.99.2) (Quit: The Lounge - https://thelounge.chat)
2026-04-06 11:57:16 +0000TimWolla(~timwolla@2a01:4f8:150:6153:beef::6667) TimWolla
2026-04-06 11:52:09 +0000merijn(~merijn@62.45.136.136) (Ping timeout: 248 seconds)
2026-04-06 11:51:36 +0000 <ski> np
2026-04-06 11:50:54 +0000 <fp`> Cool. Thank you so much for all the help!
2026-04-06 11:47:12 +0000 <ski> fp` ^
2026-04-06 11:47:09 +0000 <lambdabot> https://hackage.haskell.org/package/simple-reflect
2026-04-06 11:47:09 +0000 <ski> @hackage simple-reflect
2026-04-06 11:45:32 +0000 <ski> so, the example above is the same as `any (> 10) [0 ..]'
2026-04-06 11:45:27 +0000merijn(~merijn@62.45.136.136) merijn
2026-04-06 11:45:17 +0000 <lambdabot> or = foldr (||) False
2026-04-06 11:45:17 +0000 <ski> @src or
2026-04-06 11:45:16 +0000 <lambdabot> any p = or . map p
2026-04-06 11:45:16 +0000 <ski> @src any
2026-04-06 11:45:08 +0000 <fp`> Also, where does lambdabot's Expr type come from? That would be quite useful to me
2026-04-06 11:44:28 +0000TimWolla(~timwolla@2a01:4f8:150:6153:beef::6667) (Quit: Bye)
2026-04-06 11:41:46 +0000 <ski> (you could pass the same list to two different places. one might use `_' (not forcing), while the other might force it, naming)
2026-04-06 11:41:43 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds)
2026-04-06 11:40:45 +0000 <ski> of course, if it's not named, then you're not forcing it (unless you use a strictness annotation, e.g. `!_'), so it's not forced unless someone else is forcing it, elsewhere
2026-04-06 11:40:34 +0000 <fp`> I see
2026-04-06 11:40:03 +0000 <ski> what matters is whether the parameter is used/demanded/forced, not really whether it's named
2026-04-06 11:39:42 +0000 <ski> it would also have ignored `x', still short-circuiting
2026-04-06 11:39:33 +0000 <ski> True || x = True
2026-04-06 11:39:27 +0000 <ski> but if it had said
2026-04-06 11:39:24 +0000 <ski> yes, in this case
2026-04-06 11:39:19 +0000 <ski> the short-circuiting is not built-in, is just a consequence of how `||' is defined, and how lazy evaluation works
2026-04-06 11:39:03 +0000 <fp`> So the `_' is what causes the short circuiting?
2026-04-06 11:34:43 +0000 <ski> that short-circuits, does not evaluate the right parameter, in case the left is `True'
2026-04-06 11:34:27 +0000 <lambdabot> False || x = x
2026-04-06 11:34:27 +0000 <lambdabot> True || _ = True
2026-04-06 11:34:26 +0000 <ski> @src (||)
2026-04-06 11:34:22 +0000 <ski> but yes, the implementor of `||' (or whichever callback you're using)
2026-04-06 11:33:54 +0000 <ski> there is no `:' is the result of `foldr'
2026-04-06 11:33:44 +0000 <ski> not quite that
2026-04-06 11:33:41 +0000merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-04-06 11:33:26 +0000tromp(~textual@2001:1c00:340e:2700:795f:6a6f:7cb5:ecd6) (Quit: My iMac has gone to sleep. ZZZzzz…)
2026-04-06 11:29:38 +0000 <fp`> and the short-circuiting logic is down to... the implementor of (||)? Or ghc? Or is there even a runtime component?
2026-04-06 11:28:42 +0000 <fp`> foldr f acc x:xs = (f x acc) : (foldr f acc xs)
2026-04-06 11:28:41 +0000 <fp`> So foldr looks something like this (with an additional boundary condition)
2026-04-06 11:28:22 +0000 <lambdabot> True
2026-04-06 11:28:21 +0000 <ski> > foldr (||) False (map (> 10) [0 ..]) -- this hands over control to `||', which decides whether to continye with the next recursive `foldr' call or not
2026-04-06 11:26:50 +0000 <ski> `foldl' keeps control, until it reaches the end of the list
2026-04-06 11:26:25 +0000 <ski> `foldr' hands over control to the callback, and lets it decide if and when to continue with the `foldr' recursive call (being the second parameter passed to the callback)
2026-04-06 11:25:44 +0000 <lambdabot> f a (f b (f c z))
2026-04-06 11:25:42 +0000 <ski> > foldr f z [a,b,c] :: Expr
2026-04-06 11:25:40 +0000 <lambdabot> f (f (f z a) b) c
2026-04-06 11:25:39 +0000 <ski> > foldl f z [a,b,c] :: Expr
2026-04-06 11:25:25 +0000 <ski> both `foldl' and `foldr' start "from the left". what differs is the way it "associates" the callback (to the left, like `((z - a) - b) - c', for `foldl (-) z [a,b,c]', vs. to the right, like `a - (b - (c - z))', for `foldr (-) z [a,b,c]'). `foldl' keeps adding to, growing, the accumulator, while `foldr' wraps its recursive calls inside calls to the callback