Logs: freenode/#haskell
| 2021-04-18 21:10:41 | × | Sorna quits (~Sornaensi@077213200034.dynamic.telenor.dk) (Ping timeout: 240 seconds) |
| 2021-04-18 21:11:05 | <seven_three> | what is an example of a foldr doing early exit? |
| 2021-04-18 21:11:10 | <davean> | safinaskar: Your code gets cleaner if you just collapse repeatitive code into a single level! |
| 2021-04-18 21:11:24 | <monochrom> | foldr (&&) undefined (repeat False) |
| 2021-04-18 21:11:38 | <monochrom> | test that it takes finite time |
| 2021-04-18 21:11:47 | → | Alleria joins (~textual@2603-7000-3040-0000-8d12-8548-27bc-6b87.res6.spectrum.com) |
| 2021-04-18 21:11:56 | <seven_three> | ok I see what you mean |
| 2021-04-18 21:12:10 | Alleria | is now known as Guest78338 |
| 2021-04-18 21:12:25 | <davean> | The early termination is epxlicite in the (&&) definition |
| 2021-04-18 21:12:59 | <seven_three> | right and otherwise folding an infinite list would never terminate |
| 2021-04-18 21:13:23 | × | Sorny quits (~Sornaensi@79.142.232.102.static.router4.bolignet.dk) (Ping timeout: 265 seconds) |
| 2021-04-18 21:13:24 | <monochrom> | I disagree. The "same" code in SML behaves differently. This really takes learning. Nothing self-evident here. In fact most people find the opposite meaning self-evident. |
| 2021-04-18 21:14:05 | <safinaskar> | davean: "Why do you want to code the early return explicitely instead of just have it work BTW?" - see here: http://paste.debian.net/1194216/ |
| 2021-04-18 21:14:13 | <monochrom> | I know because I use that example to totally surprise my students. And that's even after I've taught them lazy evaluation. |
| 2021-04-18 21:14:56 | <davean> | safinaskar: that doesn't answer the question |
| 2021-04-18 21:15:02 | <davean> | safinaskar: tahts why you want curly brase style |
| 2021-04-18 21:15:05 | × | smatting quits (~stefan@p200300cd7708e000958acc65436f5a2e.dip0.t-ipconnect.de) (Ping timeout: 250 seconds) |
| 2021-04-18 21:15:33 | <davean> | monochrom: its explicite by being explicitely lazy in the second argument - as I said, its explicite in the *definition of (&&)* |
| 2021-04-18 21:16:11 | <monochrom> | I taught them lazy evaluation steps. Then I threw them the exercise of "now your turn, show me the steps for foldr (+) 0 [1,2], and for for foldr (&&) True [False, False]". The students do the (+) one correctly. Then proceed to do the (&&) one the very same way as the (+) one. |
| 2021-04-18 21:16:16 | × | Guest78338 quits (~textual@2603-7000-3040-0000-8d12-8548-27bc-6b87.res6.spectrum.com) (Ping timeout: 258 seconds) |
| 2021-04-18 21:16:48 | → | Alleria_ joins (~textual@2603-7000-3040-0000-8d12-8548-27bc-6b87.res6.spectrum.com) |
| 2021-04-18 21:18:07 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 252 seconds) |
| 2021-04-18 21:18:45 | <safinaskar> | davean: "but you have things like "do do"" - you mean using "do" inside of "do"? this is intentional. to hide bindings. i. e. i write "do { do { a<-...; ... }; foo; }" to make sure "foo" doesn't see "a". i am inventive:) . i don't simply copy-paste examples, i develop my style :) |
| 2021-04-18 21:19:14 | × | robotmay quits (~beepboop@2001:8b0:7af0:2580:505f:607:efbd:23b4) (Remote host closed the connection) |
| 2021-04-18 21:20:00 | <davean> | safinaskar: also, in your example, you make a nested case instead of a sequence like in the C++ code, to no point i can see - they do the same things in the True branch, so you can collapse them, etc |
| 2021-04-18 21:20:22 | <safinaskar> | well, i don't know how indent-based layout work. i simply always try to use curly braces to avoid understanding indent-based rules |
| 2021-04-18 21:20:30 | → | robotmay joins (~beepboop@2001:8b0:7af0:2580:e563:8f42:67c7:6d13) |
| 2021-04-18 21:21:02 | <davean> | safinaskar: same indent, same block, different indent, different block. Same rule as braces basicly (theres some more details, but you only need them if you choose to sue them and theres not MUCH more) |
| 2021-04-18 21:21:26 | <davean> | safinaskar: your code, you can just delete the braces I think |
| 2021-04-18 21:21:38 | <davean> | safinaskar: indent style is *the thing you're already doing* |
| 2021-04-18 21:22:41 | <davean> | safinaskar: have you seen 'guard'? |
| 2021-04-18 21:23:15 | <davean> | http://hackage.haskell.org/package/base-4.15.0.0/docs/Control-Monad.html |
| 2021-04-18 21:23:26 | <davean> | Also 'when' |
| 2021-04-18 21:24:03 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2021-04-18 21:24:15 | × | ph88 quits (~ph88@2a02:8109:9e00:7e5c:d5ef:86b3:afc4:9258) (Ping timeout: 260 seconds) |
| 2021-04-18 21:24:42 | <safinaskar> | monochrom: ""and" is already a right-fold and does early exit, btw" - when i say i want early exit, i mean this: http://paste.debian.net/1194216/ . i. e. i want to be able to place "return true" and "return false" at any point in my function |
| 2021-04-18 21:25:11 | × | Sornaensis quits (~Sornaensi@077213200034.dynamic.telenor.dk) (Ping timeout: 240 seconds) |
| 2021-04-18 21:25:53 | × | elliott__ quits (~elliott@pool-108-18-30-46.washdc.fios.verizon.net) (Ping timeout: 240 seconds) |
| 2021-04-18 21:26:20 | <davean> | safinaskar: I want to be clear, I've been telling you you can do that if you want |
| 2021-04-18 21:26:27 | <davean> | you're explicitely avoiding it |
| 2021-04-18 21:26:41 | × | falafel quits (~falafel@pool-96-255-70-50.washdc.fios.verizon.net) (Ping timeout: 260 seconds) |
| 2021-04-18 21:26:50 | <davean> | I'm getting a touch tired of repeating myself though so I'm going to go do something productive :) |
| 2021-04-18 21:28:45 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 268 seconds) |
| 2021-04-18 21:29:02 | <safinaskar> | davean: "The early termination is epxlicite in the (&&) definition" - when i say "early" i don't mean chronologically early. i mean "placed early in source file" |
| 2021-04-18 21:31:33 | <safinaskar> | i understand how laziness in Haskell work. i understand that lazy would work differently in strict language. i understand what is fork. and i can make my code shorter using folds and other techniques (but i would not call fold-based code cleaner). but i still don't understand WHY i should solve all this haskell-releated problems instead of just |
| 2021-04-18 21:31:34 | <safinaskar> | writing imperative code |
| 2021-04-18 21:32:00 | <seven_three> | I think you want guards. https://dpaste.org/qjn1 |
| 2021-04-18 21:32:36 | <davean> | seven_three: he SPECIFICLY wants to only use braces |
| 2021-04-18 21:32:53 | <davean> | He's already rejected all the Haskell options for getting exatly what he wants in the base language |
| 2021-04-18 21:33:03 | <seven_three> | oh nevermind then |
| 2021-04-18 21:33:22 | <davean> | So he'd need like 'when' and 'guard' on a Alternative |
| 2021-04-18 21:33:35 | <davean> | Which would get him to the C code, but he seems to ignore when I say that |
| 2021-04-18 21:34:42 | <davean> | I could search-replace his C++ code into Haskell |
| 2021-04-18 21:34:47 | <safinaskar> | davean: "they do the same things in the True branch, so you can collapse them" - how i can collapse them? |
| 2021-04-18 21:34:48 | <dmj`> | safinaskar: equational reasoning, safety, purity, abstraction are Haskell's main selling points. Laziness is convenient too. If you have a large codebase you want to maintain and refactor, anything but Haskell is a nightmare. |
| 2021-04-18 21:35:10 | <davean> | the 'if's become 'when' and the for becomes a fold, and we're done |
| 2021-04-18 21:35:57 | <davean> | foldM that is |
| 2021-04-18 21:37:02 | <safinaskar> | davean: "have you seen 'guard'?" - yes. let's imagine i am inside Maybe monad. i can easily early return Nothing simply by writing Nothing on separate line. but i cannot early return "Just 0" as opposed to imperative languages |
| 2021-04-18 21:38:16 | <safinaskar> | s/i understand what is fork/i understand what is fold/ |
| 2021-04-18 21:38:28 | <lechner> | Hi, is there a way to parse more complex YAML structures using this code? Also, how do I get the values, please? Thanks! https://dpaste.org/YCnR#L16,17,18,19,20 |
| 2021-04-18 21:39:10 | ← | seven_three parts (~user@pool-96-233-64-53.bstnma.fios.verizon.net) ("ERC (IRC client for Emacs 27.2)") |
| 2021-04-18 21:39:22 | → | Guest78317 joins (~laudiacay@67.176.215.84) |
| 2021-04-18 21:39:31 | × | hyiltiz quits (~quassel@unaffiliated/hyiltiz) (Ping timeout: 260 seconds) |
| 2021-04-18 21:42:06 | <davean> | seven_three: I think the more relivent example would be "case" with guards specificly |
| 2021-04-18 21:42:46 | <safinaskar> | i still don't like haskell |
| 2021-04-18 21:43:13 | × | Major_Biscuit quits (~Major_Bis@82-169-100-198.biz.kpn.net) (Quit: WeeChat 3.0.1) |
| 2021-04-18 21:43:22 | <davean> | Feel free not to, but understand its because you're refusing to actually use it |
| 2021-04-18 21:43:34 | × | Guest78317 quits (~laudiacay@67.176.215.84) (Ping timeout: 252 seconds) |
| 2021-04-18 21:43:38 | <davean> | and want it to look exactly like another thing but refuse to use the parts of it that make it do that |
| 2021-04-18 21:43:59 | → | nut joins (~user@roc37-h01-176-170-197-243.dsl.sta.abo.bbox.fr) |
| 2021-04-18 21:44:02 | × | gitgood quits (~gitgood@80-44-9-246.dynamic.dsl.as9105.com) (Quit: Probably away to do something really awesome) |
| 2021-04-18 21:44:44 | → | hyiltiz joins (~quassel@unaffiliated/hyiltiz) |
| 2021-04-18 21:45:46 | <davean> | safinaskar: We're here to help you, not make you like things, if your goal is to not like something, your success should be pretty easy. |
| 2021-04-18 21:48:09 | <monochrom> | "Is that 'avoid success at all costs?'?" meme :) |
| 2021-04-18 21:48:55 | → | renzhi joins (~renzhi@2607:fa49:6500:bc00::e7b) |
| 2021-04-18 21:48:58 | <davean> | "f x | some_condition = True; f x | other_condition = False; f x = any (\i -> foo) [0 .. n - 1];" is clearly more focused on the thing your example is actually doing for example. Theres less "extra" in there, rejecting it for wanting braces is something you're entirely free to do though. And is has your ordering properly for example. |
| 2021-04-18 21:48:58 | → | EmanuelLoos[m] joins (emanuel-lo@gateway/shell/matrix.org/x-xedchorwdbepbzbx) |
| 2021-04-18 21:49:42 | <davean> | but its really not interesting to talk to you when you are looking to push your stylistic interests and disinterested in even accepting you can have what you want (I actually have a C monad in some of my code I use for pasting C code in) |
| 2021-04-18 21:50:23 | → | usr25 joins (~usr25@unaffiliated/usr25) |
| 2021-04-18 21:50:34 | <davean> | (Direclty pasting C code in took a ton of fuckery of course, but it mostly works) |
| 2021-04-18 21:50:59 | ← | usr25 parts (~usr25@unaffiliated/usr25) () |
| 2021-04-18 21:51:20 | × | LKoen_ quits (~LKoen@77.168.9.109.rev.sfr.net) (Quit: “It’s only logical. First you learn to talk, then you learn to think. Too bad it’s not the other way round.”) |
| 2021-04-18 21:51:29 | × | __monty__ quits (~toonn@unaffiliated/toonn) (Quit: leaving) |
| 2021-04-18 21:52:00 | <davean> | safinaskar: but to save you some time, you not liking Haskell isn't going to bother anyone here |
| 2021-04-18 21:52:13 | × | elfets quits (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) (Ping timeout: 252 seconds) |
| 2021-04-18 21:52:56 | × | tmciver quits (~tmciver@cpe-172-101-40-226.maine.res.rr.com) (Ping timeout: 260 seconds) |
| 2021-04-18 21:54:46 | → | tmciver joins (~tmciver@cpe-172-101-40-226.maine.res.rr.com) |
| 2021-04-18 21:56:57 | <safinaskar> | ""f x | some_condition = True; f x | other_condition = False; f x = any (\i -> foo) [0 .. n - 1];" is clearly more focused on the thing your example is actually doing for example. Theres less "extra" in there, rejecting it for wanting braces is something you're entirely free to do though" - your code is hard to write. to write such code i need to |
| 2021-04-18 21:56:58 | <safinaskar> | write code i usually write first, and then refactor it to your version. this is reason i don't write code like yours, not because of curly braces |
| 2021-04-18 21:57:41 | → | jamm_ joins (~jamm@unaffiliated/jamm) |
| 2021-04-18 21:57:44 | → | carldd joins (~carldd@90-224-49-113-no56.tbcn.telia.com) |
| 2021-04-18 21:58:34 | <davean> | safinaskar: thats entierly a you issue because they're the same code semanticly |
| 2021-04-18 21:59:21 | <davean> | Its a very slight stylistic difference in how you type it out, not even in how you think about it |
| 2021-04-18 21:59:42 | <davean> | perhaps you're thinking of it as something other than a very basic sytax sugar difference but thats all it is |
| 2021-04-18 22:00:00 | <davean> | your editor could let you type yours and generate mind even |
| 2021-04-18 22:00:04 | <davean> | thats *all* it is |
| 2021-04-18 22:00:11 | × | fendor quits (~fendor@178.165.130.27.wireless.dyn.drei.com) (Remote host closed the connection) |
| 2021-04-18 22:00:48 | → | falafel joins (~falafel@pool-96-255-70-50.washdc.fios.verizon.net) |
| 2021-04-18 22:02:16 | × | jamm_ quits (~jamm@unaffiliated/jamm) (Ping timeout: 258 seconds) |
| 2021-04-18 22:03:20 | → | gitgood joins (~gitgood@80-44-9-246.dynamic.dsl.as9105.com) |
All times are in UTC.