Logs: freenode/#haskell
| 2020-11-19 05:05:15 | × | tumdedum quits (~tumdedum@unaffiliated/espiral) (Ping timeout: 265 seconds) |
| 2020-11-19 05:07:12 | × | texasmynsted quits (~texasmyns@212.102.45.121) (Ping timeout: 260 seconds) |
| 2020-11-19 05:07:42 | → | thunderrd joins (~thunderrd@183.182.110.8) |
| 2020-11-19 05:08:54 | × | conal quits (~conal@64.71.133.70) (Quit: Computer has gone to sleep.) |
| 2020-11-19 05:09:49 | × | spatchkaa quits (~spatchkaa@S010600fc8da47b63.gv.shawcable.net) (Ping timeout: 264 seconds) |
| 2020-11-19 05:10:56 | × | mbomba quits (~mbomba@bras-base-toroon2719w-grc-49-142-114-9-241.dsl.bell.ca) (Quit: WeeChat 3.0) |
| 2020-11-19 05:12:53 | → | christo joins (~chris@81.96.113.213) |
| 2020-11-19 05:13:03 | → | tumdedum joins (~tumdedum@unaffiliated/espiral) |
| 2020-11-19 05:13:16 | × | cosimone quits (~cosimone@5.171.24.92) (Ping timeout: 240 seconds) |
| 2020-11-19 05:14:21 | → | aioe joins (aoei@2a01:7e01::f03c:92ff:fe4f:e85a) |
| 2020-11-19 05:14:23 | × | monochrom quits (trebla@216.138.220.146) (Quit: NO CARRIER) |
| 2020-11-19 05:15:20 | × | FreeBirdLjj quits (~freebirdl@101.228.42.108) (Remote host closed the connection) |
| 2020-11-19 05:15:25 | × | xerox_ quits (~xerox@unaffiliated/xerox) (Ping timeout: 240 seconds) |
| 2020-11-19 05:17:16 | → | cosimone joins (~cosimone@5.170.241.44) |
| 2020-11-19 05:17:23 | × | christo quits (~chris@81.96.113.213) (Ping timeout: 260 seconds) |
| 2020-11-19 05:17:29 | × | aoei quits (~aoei@240.223.246.35.bc.googleusercontent.com) (Remote host closed the connection) |
| 2020-11-19 05:18:44 | aioe | is now known as aoei |
| 2020-11-19 05:19:07 | × | ericsagn1 quits (~ericsagne@2405:6580:0:5100:8c9:42ac:c0f6:8508) (Ping timeout: 272 seconds) |
| 2020-11-19 05:21:32 | × | jb55 quits (~jb55@gateway/tor-sasl/jb55) (Remote host closed the connection) |
| 2020-11-19 05:21:38 | × | ft quits (~ft@shell.chaostreff-dortmund.de) (Ping timeout: 264 seconds) |
| 2020-11-19 05:21:52 | → | jb55 joins (~jb55@gateway/tor-sasl/jb55) |
| 2020-11-19 05:22:23 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Quit: leaving) |
| 2020-11-19 05:22:38 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2020-11-19 05:24:43 | → | day_ joins (~Unknown@unaffiliated/day) |
| 2020-11-19 05:27:05 | → | SanchayanMaity joins (~Sanchayan@106.201.35.233) |
| 2020-11-19 05:27:45 | × | day quits (~Unknown@unaffiliated/day) (Ping timeout: 240 seconds) |
| 2020-11-19 05:27:45 | day_ | is now known as day |
| 2020-11-19 05:27:58 | → | monochrom joins (trebla@216.138.220.146) |
| 2020-11-19 05:28:31 | → | xerox_ joins (~xerox@unaffiliated/xerox) |
| 2020-11-19 05:31:06 | → | ericsagn1 joins (~ericsagne@2405:6580:0:5100:b274:8c51:102c:8ca9) |
| 2020-11-19 05:32:10 | → | n00b joins (d055ed89@208.85.237.137) |
| 2020-11-19 05:32:55 | n00b | is now known as n0042 |
| 2020-11-19 05:33:34 | <n0042> | Hello folks. May I ask what is probably a pretty common newbie question? I have done a lot of research on it and am starting to feel a little stumped at having not found the proper answer |
| 2020-11-19 05:33:48 | × | xerox_ quits (~xerox@unaffiliated/xerox) (Ping timeout: 272 seconds) |
| 2020-11-19 05:34:52 | → | zyklotomic joins (~ethan@unaffiliated/chocopuff) |
| 2020-11-19 05:35:29 | <n0042> | I have a situation where I need to take an unknown # of lines from stdin (no more, no less, finite but unknown until runtime). I have tried a hundred different ways of trying to use getLine programmatically so that it collects exactly n-amount of lines, after n is known. Is there a good article I can read on this? |
| 2020-11-19 05:36:11 | <zyklotomic> | what have you tried so far |
| 2020-11-19 05:37:33 | <n0042> | So far my most promising approach has been to get the initial number of lines with getLine (because that input is known) parse it and extract the number, and then try to run getLine that amount of times. |
| 2020-11-19 05:37:59 | <glguy> | that sounds right |
| 2020-11-19 05:37:59 | <zyklotomic> | i'm just a beginner, but maybe replicateM might help |
| 2020-11-19 05:38:04 | <dsal> | It'd be easier to show code and describe the confusion than to describe the problem. |
| 2020-11-19 05:38:06 | × | hidedagger quits (~nate@unaffiliated/hidedagger) (Quit: WeeChat 2.9) |
| 2020-11-19 05:38:18 | <glguy> | ?paste |
| 2020-11-19 05:38:18 | <lambdabot> | A pastebin: https://paste.debian.net/ |
| 2020-11-19 05:38:20 | <zyklotomic> | replicateM n getLine |
| 2020-11-19 05:38:39 | <n0042> | I have not tried replicateM. I'll try that. |
| 2020-11-19 05:38:41 | <glguy> | zyklotomic, maybe, but n0042 ought to be able to do this without any library functions first |
| 2020-11-19 05:39:13 | <glguy> | n0042, Do you have any attempts yet? What have you tried? |
| 2020-11-19 05:39:32 | <n0042> | I did try: "take n (repeat getLine)" and wound up with a list of getLine functions that I then wasn't sure how to turn into values |
| 2020-11-19 05:39:54 | <n0042> | I also tried recursive-do as described in the ghc docs, but that didn't want to compile the way I was trying to do it. |
| 2020-11-19 05:40:29 | <glguy> | recursive-do is something you don't need |
| 2020-11-19 05:40:29 | <dsal> | Showing code (and errors/confusion) is more informative than describing code. |
| 2020-11-19 05:40:42 | × | cosimone quits (~cosimone@5.170.241.44) (Quit: cosimone) |
| 2020-11-19 05:40:45 | <glguy> | You can paste your code on a pastebin so that people can see what you've got |
| 2020-11-19 05:40:56 | <n0042> | I'll use pastebin real quick to show you what I've got so far. uno momento |
| 2020-11-19 05:41:04 | <glguy> | showing code will help us see what you do know how to do |
| 2020-11-19 05:41:52 | → | agrajag` joins (~agrajag`@84.39.117.57) |
| 2020-11-19 05:43:24 | <dsal> | Some confusion seems to be between functions and actions. replicating `getLine` will make a bunch of `getLine` actions, but it won't get lines. There's a path from there, but it's probably not what you want. |
| 2020-11-19 05:43:57 | → | nbloomf joins (~nbloomf@2600:1700:ad14:3020:6c29:bc9c:b97a:2b45) |
| 2020-11-19 05:44:49 | <zyklotomic> | on a seperate thread, i have a question about folds vs monads |
| 2020-11-19 05:44:59 | <zyklotomic> | hope you guys don't mind juggling the convo a bit |
| 2020-11-19 05:45:11 | <glguy> | go for it |
| 2020-11-19 05:45:29 | <zyklotomic> | is there any deeper relationship b/w them? I was reading https://mail.haskell.org/pipermail/beginners/2014-August/013993.html |
| 2020-11-19 05:45:43 | <zyklotomic> | as a result of a google search, after noticing that foldl was kinda like State |
| 2020-11-19 05:46:20 | <zyklotomic> | then I was writing another function that folded with a monoid (list appending) |
| 2020-11-19 05:46:30 | <glguy> | There's not much relating folds to monads |
| 2020-11-19 05:46:31 | <zyklotomic> | and it basically was Writer (i think) |
| 2020-11-19 05:46:38 | <zyklotomic> | are these just coincidences? |
| 2020-11-19 05:46:56 | <zyklotomic> | I should generally prefer using folds right |
| 2020-11-19 05:47:11 | <zyklotomic> | I can show an example |
| 2020-11-19 05:47:29 | × | aoei quits (aoei@2a01:7e01::f03c:92ff:fe4f:e85a) (Quit: ZNC 1.7.5 - https://znc.in) |
| 2020-11-19 05:47:37 | <n0042> | https://pastebin.com/zwuqHsSY |
| 2020-11-19 05:47:37 | × | chkno quits (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net) (Read error: Connection reset by peer) |
| 2020-11-19 05:48:00 | → | chkno joins (~chkno@75-7-2-127.lightspeed.sntcca.sbcglobal.net) |
| 2020-11-19 05:48:02 | <glguy> | zyklotomic, foldl is similar to traverse used with State |
| 2020-11-19 05:48:04 | <n0042> | Here's sort of what I got so far. It's for an assignment but there's no need to get into the assignment itself. I already have that part figured out. It's just the I/O that's confusing me |
| 2020-11-19 05:48:08 | <glguy> | but that's not much about being a monad |
| 2020-11-19 05:48:17 | <zyklotomic> | https://paste.debian.net/1173146/ |
| 2020-11-19 05:48:32 | <zyklotomic> | wait yeah, you're right, I probably shouldn't have jumped to monad |
| 2020-11-19 05:48:35 | <glguy> | that's more about foldl being related to State specifically in the context of foldable types |
| 2020-11-19 05:49:44 | → | hidedagger joins (~nate@unaffiliated/hidedagger) |
| 2020-11-19 05:49:56 | <glguy> | :t \f t -> runState(traverse (state . f) t) |
| 2020-11-19 05:49:57 | <lambdabot> | Traversable t => (a -> s -> (b, s)) -> t a -> s -> (t b, s) |
| 2020-11-19 05:50:08 | → | aoei joins (~aoei@li2174-104.members.linode.com) |
| 2020-11-19 05:50:12 | <glguy> | :t foldl |
| 2020-11-19 05:50:13 | <lambdabot> | Foldable t => (b -> a -> b) -> b -> t a -> b |
| 2020-11-19 05:50:36 | <glguy> | :t scanl |
| 2020-11-19 05:50:38 | <lambdabot> | (b -> a -> b) -> b -> [a] -> [b] |
| 2020-11-19 05:50:46 | <glguy> | :t mapAccumL |
| 2020-11-19 05:50:47 | <lambdabot> | Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c) |
| 2020-11-19 05:51:01 | <zyklotomic> | or actually, I mean, what about Writer and State |
| 2020-11-19 05:51:17 | <zyklotomic> | would you like classify them as some kind, or am I looking into this too much |
| 2020-11-19 05:51:27 | <zyklotomic> | and it is just a nice coincidenec |
| 2020-11-19 05:51:51 | <zyklotomic> | where the behavior is "traversing" |
| 2020-11-19 05:51:52 | <glguy> | there's no deep connection that I can think of |
| 2020-11-19 05:52:21 | <zyklotomic> | ah fair enough, thanks for entertaining my q |
| 2020-11-19 05:52:43 | <dsal> | n0042: what do you want `results` to be? |
| 2020-11-19 05:53:14 | <dsal> | From the application, it looks like you want it to be a single string. |
| 2020-11-19 05:54:18 | <n0042> | So, results is going to print a line for each "packet" showing the time it was processed or if it was processed. That's all going to be handled by the program logic which i've got covered, and it'll just print off a list of strings. But to get there I need to collect the strings which contain the arrival time and time-to-process for each packet, |
| 2020-11-19 05:54:18 | <n0042> | which is the programmatic input part. |
All times are in UTC.