Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,800,755 events total
2026-01-02 19:17:25 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 264 seconds)
2026-01-02 19:28:02 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 19:30:56 × rbdr quits (~rbdr@2a02:3100:23ad:aa00:e7fe:1cac:4507:3685) (Quit: rbdr)
2026-01-02 19:32:40 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 244 seconds)
2026-01-02 19:35:31 Lord_of_Life_ joins (~Lord@user/lord-of-life/x-2819915)
2026-01-02 19:36:15 × Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 240 seconds)
2026-01-02 19:36:28 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 19:36:48 Lord_of_Life_ is now known as Lord_of_Life
2026-01-02 19:37:38 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 19:42:55 × Inline quits (~User@cgn-195-14-221-74.nc.de) (Ping timeout: 240 seconds)
2026-01-02 19:43:34 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 19:46:03 Milan_Vanca joins (~milan@user/Milan-Vanca:32634)
2026-01-02 19:46:27 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 19:47:39 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 19:48:15 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2026-01-02 19:53:19 <Milan_Vanca> Hello guyz. I know that !! for lists needs to traverse list to find index. But my question is let l = [0..] in (l !! 10^6 + 1) + ( l !! 10^6 + 2) + ... Will this traverse list multiple times? Or will reuse "iteration"?
2026-01-02 19:55:52 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 19:56:41 <ncf> l will be shared
2026-01-02 19:57:07 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 19:57:47 <ncf> see https://en.wikibooks.org/wiki/Haskell/Graph_reduction
2026-01-02 19:58:21 Inline joins (~User@cgn-195-14-221-74.nc.de)
2026-01-02 19:59:22 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 19:59:38 <Milan_Vanca> I know l is shared and wont be created multiple times.. but to access element l !! bigIndex we need to traverse linken list. But will this list be traversed 2 times from start? Or will it traverse once till first Index and then just do one hop to second Index?
2026-01-02 20:02:34 <geekosaur> the former
2026-01-02 20:02:35 <ncf> i'd be very surprised if GHC was smart enough to optimise the second traversal
2026-01-02 20:02:55 <geekosaur> there are ways to get the latter, I think, but that's not one of them
2026-01-02 20:02:55 <tomsmeding> yep, l will be traversed 2 times from the start
2026-01-02 20:03:55 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2026-01-02 20:04:43 <Milan_Vanca> Oookey so I guess I should use Data.IntMap instead even tho every element of this map will be used in successive computations?
2026-01-02 20:05:34 × img quits (~img@user/img) (Quit: ZNC 1.10.1 - https://znc.in)
2026-01-02 20:05:47 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 20:06:49 img joins (~img@user/img)
2026-01-02 20:07:30 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 20:07:39 <Milan_Vanca> If you look at page 5 of this document https://www.rfc-editor.org/rfc/rfc1321 There T[i] is value from list. I probably can't use `map` as function is always different. Or maybe I could zip it with index and then have case of to use correct function.
2026-01-02 20:09:22 <ncf> well you could extract the indices you need in one run
2026-01-02 20:10:00 pavonia joins (~user@user/siracusa)
2026-01-02 20:13:21 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 20:14:17 <Milan_Vanca> hmm
2026-01-02 20:16:16 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 20:16:59 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 20:17:03 epitron joins (epi@user/epitron)
2026-01-02 20:18:07 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2026-01-02 20:20:45 <monochrom> This is more nuisanced than one single boolean "is/not shared". (But you just need a multitude of booleans.)
2026-01-02 20:21:09 <monochrom> l is shared. That actually is worse news than you think.
2026-01-02 20:22:14 <monochrom> The common subexpression "l !! bignumber" is unlikely to be shared. This is at the whim of the code optimizer, but I bet unlikely. (But you should check empirically.)
2026-01-02 20:24:06 mmohammadi9812 joins (~mohammad@104.28.214.168)
2026-01-02 20:24:17 <monochrom> If "l !! bignumber" is not shared but l is, then what happens is the worst of both worlds. First time, l is expanded and occupies 10^6 units of memory, and since it is to be shared, it won't be freed. Second time, you traverse that existing allocated memory from start to finish again.
2026-01-02 20:24:29 <monochrom> So you lose both memory and time. Congratulations.
2026-01-02 20:25:41 L29Ah parts (~L29Ah@wikipedia/L29Ah) ()
2026-01-02 20:26:25 <monochrom> If you want something reused but don't want to bet, "let x = l !! bignumber in x + x" is the way. (Or "where".)
2026-01-02 20:27:51 <Milan_Vanca> So by introducing new function I can enforce what is shared.
2026-01-02 20:28:15 L29Ah joins (~L29Ah@wikipedia/L29Ah)
2026-01-02 20:28:58 <Milan_Vanca> Imagine I would split this big list at 10^6 index and then only used everithing after. Could from start to split be garbage collected if it is not used in other functions?
2026-01-02 20:29:08 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 20:29:26 <monochrom> Then yes the prefix can be freed.
2026-01-02 20:29:55 <Milan_Vanca> I didn't expect that! This is really cool.
2026-01-02 20:34:54 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 20:35:35 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2026-01-02 20:36:13 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 20:41:47 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 20:43:30 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 20:46:51 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 20:47:11 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 20:48:05 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 20:49:44 kuribas joins (~user@2a02-1810-2825-6000-f2d4-59c7-29a4-df97.ip6.access.telenet.be)
2026-01-02 20:50:01 × califax quits (~califax@user/califx) (Remote host closed the connection)
2026-01-02 20:50:37 <kuribas> > [y | x <- [Just 1, Nothing, Just 2], let Just y = x]
2026-01-02 20:50:59 califax joins (~califax@user/califx)
2026-01-02 20:51:02 <monochrom> Oh lambdabot is away
2026-01-02 20:51:09 <monochrom> % 1+1
2026-01-02 20:51:09 <yahb2> 2
2026-01-02 20:51:15 <monochrom> % [y | x <- [Just 1, Nothing, Just 2], let Just y = x]
2026-01-02 20:51:16 <yahb2> *** Exception: <interactive>:143:42-51: Non-exhaustive patterns in Just y ; ; ; HasCallStack backtrace: ; collectBacktraces, called at libraries/ghc-internal/src/GHC/Internal/Exception.hs:169:1...
2026-01-02 20:51:43 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2026-01-02 20:52:23 <kuribas> Shouldn't it partial match on Just?
2026-01-02 20:53:01 <kuribas> % [y | x <- [Just 1, Nothing, Just 2], Just y <- [x]]
2026-01-02 20:53:01 <yahb2> [1,2]
2026-01-02 20:56:47 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 20:57:56 × kuribas quits (~user@2a02-1810-2825-6000-f2d4-59c7-29a4-df97.ip6.access.telenet.be) (Remote host closed the connection)
2026-01-02 20:58:13 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 21:02:04 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 21:02:46 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 21:02:58 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 21:05:37 × mmohammadi9812 quits (~mohammad@104.28.214.168) (Remote host closed the connection)
2026-01-02 21:07:44 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 244 seconds)
2026-01-02 21:11:48 <monochrom> For that example, you could have simply [y | Just y <- [Just 1, Nothing, Just 2]]
2026-01-02 21:11:58 <EvanR> it's annoying that if you care about sharing, whose semantics is beyond the scope of the syntax, you need to rely on spelling it one of several "equivalent" ways and hoping the compiler understands that
2026-01-02 21:12:14 <EvanR> it seems unhaskelly
2026-01-02 21:14:17 <monochrom> Every PL ideology has been broken by even its most ideological language. For example, Prolog added cuts to ruin the nice and symmetric logic programming ideal.
2026-01-02 21:14:19 merijn joins (~merijn@host-cl.cgnat-g.v4.dfn.nl)
2026-01-02 21:15:24 <monochrom> In the case of Haskell, a ton of tweaks ruined the denotational ideal. But I am not surprised; someone has to talk about time costs and space costs.
2026-01-02 21:15:57 × target_i quits (~target_i@user/target-i/x-6023099) (Quit: leaving)
2026-01-02 21:17:22 <monochrom> You can't talk about costs when hiding behind the denotational façade.
2026-01-02 21:17:38 wennefer0 joins (~wennefer0@user/wennefer0)
2026-01-02 21:18:24 <EvanR> yes but you could have cost meaningful syntactic forms
2026-01-02 21:18:35 <EvanR> dedicated to that purpose
2026-01-02 21:18:52 × wennefer0 quits (~wennefer0@user/wennefer0) (Client Quit)
2026-01-02 21:18:55 × merijn quits (~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 240 seconds)
2026-01-02 21:19:04 <EvanR> and if you can't ... the other way doesn't sound plausible
2026-01-02 21:19:27 <EvanR> e.g. if predicting costs is too hard

All times are in UTC.