Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-07 18:02:01 <monochrom> The reason can be seen from hand-running it:
2021-03-07 18:02:25 <rond_> > foldl (&&) True (repeat False)
2021-03-07 18:02:27 <monochrom> foldr (&&) True (False : whatever) = False && foldr ... = False. Done.
2021-03-07 18:02:31 <lambdabot> mueval-core: Time limit exceeded
2021-03-07 18:03:22 kunsttyv joins (~kunsttyv@ti0005q162-5102.bb.online.no)
2021-03-07 18:03:34 <rond_> interesting
2021-03-07 18:04:09 <minoru_shiraeesh> rond_: that sentence is really confusing for a beginner
2021-03-07 18:04:23 pineapples[m] joins (pineapples@gateway/shell/matrix.org/x-yodeebrpycxvvfhd)
2021-03-07 18:04:23 mly[m] joins (mlydisenco@gateway/shell/matrix.org/x-vsddcgdrozvrcpfd)
2021-03-07 18:04:24 ManofLetters[m] joins (manoflette@gateway/shell/matrix.org/x-xhemtjphkmydmucx)
2021-03-07 18:04:25 VarikValefor[m] joins (varikvalef@gateway/shell/matrix.org/x-eijklabkebhzgrcd)
2021-03-07 18:04:25 invent[m] joins (inventmatr@gateway/shell/matrix.org/x-acsaxyfzehsuqpnv)
2021-03-07 18:04:26 maralorn joins (maralornma@gateway/shell/matrix.org/x-uxbseyfakmhjsikg)
2021-03-07 18:04:27 <rond_> It is. How to read it?
2021-03-07 18:04:27 <monochrom> foldl uses "tail recursion", that's why it has problems. This is what's wrong with obsessing over "tail recursion".
2021-03-07 18:04:27 freeman42x[m]1 joins (freeman42x@gateway/shell/matrix.org/x-kvuqdpxllvlgxrfm)
2021-03-07 18:04:31 dftxbs3e joins (~dftxbs3e@unaffiliated/dftxbs3e)
2021-03-07 18:04:34 sm[m] joins (simonmicma@gateway/shell/matrix.org/x-kfjwhkilnrmtiqzr)
2021-03-07 18:04:42 immae joins (immaematri@gateway/shell/matrix.org/x-kanozzlnyfzodeoe)
2021-03-07 18:04:59 <minoru_shiraeesh> l and r in foldl and foldr don't mean "from left" and "from right". they mean "left associative" and "right associative"
2021-03-07 18:05:01 alecs[m] joins (malumorema@gateway/shell/matrix.org/x-dipfcuykpbkbqeke)
2021-03-07 18:05:30 jtojnar joins (jtojnarmat@gateway/shell/matrix.org/x-nemjmawtxnucncbk)
2021-03-07 18:05:34 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 276 seconds)
2021-03-07 18:05:36 <rond_> That wasn't obvious at all
2021-03-07 18:05:38 <[exa]> rond_: you may also try `foldl (&&) True (True:False:True:error "a trap!")` which is "finite". `foldr` survives there too.
2021-03-07 18:06:03 <rond_> > foldl (&&) True (True:False:True:error "a trap!")
2021-03-07 18:06:06 <lambdabot> *Exception: a trap!
2021-03-07 18:06:09 <rond_> > foldr (&&) True (True:False:True:error "a trap!")
2021-03-07 18:06:09 alar[m] joins (alarmxalat@gateway/shell/matrix.org/x-btirhtujftoyatyv)
2021-03-07 18:06:10 meff[m]1 joins (meffsunado@gateway/shell/matrix.org/x-bhggmttmkrzvyggc)
2021-03-07 18:06:12 <lambdabot> False
2021-03-07 18:06:13 the_1_[m] joins (the1matrix@gateway/shell/matrix.org/x-azpuapzwzrdxqaxc)
2021-03-07 18:06:16 themsay[m] joins (themsaymat@gateway/shell/matrix.org/x-revdyihapfdobrsk)
2021-03-07 18:06:35 <rond_> And the reason is exactly what  minoru_shiraeesh said:  "left associative" and "right associative"
2021-03-07 18:06:40 <rond_> super interesting
2021-03-07 18:06:52 <[exa]> rond_: in the second, case, the evaluated expression reads as `(True&&(False&&(....))`, so the (&&) can short-circuit there
2021-03-07 18:07:14 <infinisil> Maybe a better explanation for the l and r are that the dependency chain of values flows to the left/right
2021-03-07 18:07:30 <minoru_shiraeesh> there is an article about folds in haskell: https://wiki.haskell.org/Foldr_Foldl_Foldl%27
2021-03-07 18:07:40 <[exa]> rond_: with foldl, the evaluated expression reads `((... && False ) && error "a trap!")`, so the topmost && cannot be ever evaluated to give the final result
2021-03-07 18:08:23 bobiusbillius joins (~bobiusbil@2a02:c7d:51c4:7000:1167:87c5:c3c8:7dfb)
2021-03-07 18:08:28 <[exa]> rond_: notably, l/r means "direction of adding parentheses", but not at all "order of evaluation"
2021-03-07 18:08:47 NieDzejkob joins (~quassel@195.149.98.3)
2021-03-07 18:08:58 <rond_> "l/r means "direction of adding parentheses", but not at all "order of evaluation"" - that's confusing. I'd say they're the same in my current state of mind
2021-03-07 18:09:12 <[exa]> rond_: well, not with lazy evaluation
2021-03-07 18:09:34 <rond_> Do you think that : https://wiki.haskell.org/Foldr_Foldl_Foldl%27 might enlighten me?
2021-03-07 18:09:38 × dyeplexer quits (~lol@unaffiliated/terpin) (Remote host closed the connection)
2021-03-07 18:10:50 <monochrom> foldl and foldr were invented in non-lazy languages such as Lisp and ML. There, they really were left-to-right and right-to-left, respectively.
2021-03-07 18:11:03 × dftxbs3e quits (~dftxbs3e@unaffiliated/dftxbs3e) (Remote host closed the connection)
2021-03-07 18:11:05 Jd007 joins (~Jd007@162.156.11.151)
2021-03-07 18:11:21 × NieDzejkob quits (~quassel@195.149.98.3) (Excess Flood)
2021-03-07 18:11:32 NieDzejkob joins (~quassel@195.149.98.3)
2021-03-07 18:11:42 <monochrom> What happens is if you copy-paste their code to Haskell, lazy evaluation runs them differently.
2021-03-07 18:12:52 <c_wraith> foldr is a lot more useful in Haskell, thanks to that.
2021-03-07 18:14:33 <rond_> I was so content that everything I read is straight-forward and easy... up until this point :D
2021-03-07 18:14:36 jakalx parts (~jakalx@base.jakalx.net) ("Error from remote client")
2021-03-07 18:15:09 justsomeguy joins (~justsomeg@unaffiliated/--/x-3805311)
2021-03-07 18:15:09 <monochrom> It can still be straigtforward. Do the algebra. Don't read words.
2021-03-07 18:15:16 <maerwald> yeah, you always process the list left to right :)
2021-03-07 18:15:25 <monochrom> <monochrom> foldr (&&) True (False : whatever) = False && foldr ... = False. Done.
2021-03-07 18:15:31 <monochrom> That nails it.
2021-03-07 18:15:43 × NieDzejkob quits (~quassel@195.149.98.3) (Read error: Connection reset by peer)
2021-03-07 18:15:56 <monochrom> A formula is worth a thousand pictures.
2021-03-07 18:15:59 joe[m]3 joins (joemonoida@gateway/shell/matrix.org/x-heehkpixvzbakbkb)
2021-03-07 18:16:15 <maerwald> just because you don't like pictures
2021-03-07 18:16:17 <monochrom> (Combine it with "a picture is worth a thousand words")
2021-03-07 18:16:58 × tromp quits (~tromp@dhcp-077-249-230-040.chello.nl) (Remote host closed the connection)
2021-03-07 18:17:02 <monochrom> And now, what [exa] got wrong.
2021-03-07 18:17:26 <monochrom> foo && error "bah" is not always a problem. False && error "bah" is just fine.
2021-03-07 18:17:29 <rond_> monochrom: Could you expand the example you provided with `foldl` instead of `foldr`?
2021-03-07 18:17:33 NieDzejkob joins (~quassel@vps-dd3183b7.vps.ovh.net)
2021-03-07 18:19:10 gitgood joins (~gitgood@82-132-217-191.dab.02.net)
2021-03-07 18:19:13 <monochrom> What goes wrong with that foldl example is: foldl (&&) z (x : error "bah") = foldl (&&) (z && x) (error "bah") = error "bah". There is no foo && error "bah" anywhere.
2021-03-07 18:19:52 nineonine joins (~nineonine@2604:3d08:7785:9600:ad8c:89aa:bf10:9556)
2021-03-07 18:20:17 <monochrom> foldl (&&) True (False : False : ... etc) = foldl (&&) (True && False) (False : ...etc) = you keep doing more, there is no end.
2021-03-07 18:20:59 × Rudd0 quits (~Rudd0@185.189.115.103) (Ping timeout: 260 seconds)
2021-03-07 18:21:10 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 276 seconds)
2021-03-07 18:21:16 <rond_> Okay, I need to take a break
2021-03-07 18:21:28 <monochrom> And maerwald, as you can see, it is words that I don't like.
2021-03-07 18:21:40 × nineonine quits (~nineonine@2604:3d08:7785:9600:ad8c:89aa:bf10:9556) (Remote host closed the connection)
2021-03-07 18:21:55 kam1 joins (~kam1@113.203.63.161)
2021-03-07 18:22:03 <maerwald> They are rather problematic, indeed.
2021-03-07 18:22:05 <rond_> I'll write down the examples, probably sleep with them and likely come back again to ask about it again (after reading the article from wiki.haskell as well)
2021-03-07 18:22:13 o1lo01ol_ joins (~o1lo01ol1@bl7-88-181.dsl.telepac.pt)
2021-03-07 18:22:16 nineonine joins (~nineonine@2604:3d08:7785:9600:ad8c:89aa:bf10:9556)
2021-03-07 18:22:39 × o1lo01ol1o quits (~o1lo01ol1@bl7-89-228.dsl.telepac.pt) (Read error: Connection reset by peer)
2021-03-07 18:22:44 <rond_> Thank you all for your help!
2021-03-07 18:24:09 mirrorbird joins (~dwsjeid91@m83-187-177-242.cust.tele2.se)
2021-03-07 18:25:47 Ericson2314 joins (ericson231@gateway/shell/matrix.org/x-mqrfmtvzohzxsodp)
2021-03-07 18:26:37 <maerwald> oh, new streamly version
2021-03-07 18:26:47 <maerwald> the hackage live ticker here isn't working again it seems
2021-03-07 18:26:57 <justsomeguy> That library looks 'streamly cool :^).
2021-03-07 18:27:02 × nineonine quits (~nineonine@2604:3d08:7785:9600:ad8c:89aa:bf10:9556) (Ping timeout: 264 seconds)
2021-03-07 18:27:12 × Narinas quits (~Narinas@187-178-93-112.dynamic.axtel.net) (Read error: Connection reset by peer)
2021-03-07 18:27:31 Narinas joins (~Narinas@187-178-93-112.dynamic.axtel.net)
2021-03-07 18:29:09 × frozenErebus quits (~frozenEre@94.128.82.20) (Ping timeout: 256 seconds)
2021-03-07 18:29:13 jesser[m] joins (jessermatr@gateway/shell/matrix.org/x-yepyguibsbmyahah)
2021-03-07 18:29:18 darkcodi[m] joins (darkcodima@gateway/shell/matrix.org/x-xjmhgcxlpysirlzx)
2021-03-07 18:29:57 justanotheruser joins (~justanoth@unaffiliated/justanotheruser)
2021-03-07 18:35:15 frozenErebus joins (~frozenEre@94.128.82.20)
2021-03-07 18:35:16 machinedgod joins (~machinedg@24.105.81.50)

All times are in UTC.