Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,532 events total
2021-08-27 11:13:32 <dminuoso> This all looks a bit weird, let me look at it again
2021-08-27 11:13:47 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:c1b3:f9cf:5870:faa7)
2021-08-27 11:14:46 <trcc> hehe I am not surprised by that
2021-08-27 11:15:44 lavaman joins (~lavaman@98.38.249.169)
2021-08-27 11:16:01 <trcc> dminuoso: the actual source is here: https://github.com/HFMU/ex_water-tank/blob/master/src/FMU.hs and related HaskellFMU is here: https://github.com/HFMU/HaskellFmu if it helps...
2021-08-27 11:17:03 <dminuoso> What's the point of `output` here?
2021-08-27 11:17:24 <dminuoso> Also, you seem to have a monad confusion going on here.
2021-08-27 11:17:36 <trcc> dminuoso: The oerall idea is that I want to "EASILY" append to a list of log messages. So the idea of output is just to append log messages to the list of logentries
2021-08-27 11:17:45 <trcc> Based on this originally https://kseo.github.io/posts/2017-01-21-writer-monad.html
2021-08-27 11:17:59 <dminuoso> First off, generally `Writer` monad is a code smell already.
2021-08-27 11:18:17 <dminuoso> For logging output, something like LoggingT (or other solutions) is a better fit.
2021-08-27 11:18:24 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:c1b3:f9cf:5870:faa7) (Ping timeout: 250 seconds)
2021-08-27 11:18:34 <trcc> the messages are later to be outputtet via a function pointer
2021-08-27 11:18:35 <dminuoso> So before I address this further, do you do this to explore Writer, or is your need just to have logging?
2021-08-27 11:19:15 <trcc> The doStep function is called from within a library. Once it finishes, the library outputs each log message via a function pointer
2021-08-27 11:19:29 <trcc> The doStep function is called from within a library. Once it finishes, the library outputs each log message *in [T.LogEntry]* via a function pointer
2021-08-27 11:19:32 <dminuoso> I dont know what you mean by function pointer.
2021-08-27 11:19:45 <trcc> ia ctually mean a C function pointer
2021-08-27 11:20:09 <dminuoso> So one quirky thing is that you're not using `WriterT`
2021-08-27 11:20:16 <dminuoso> And there's several other quirks here.
2021-08-27 11:20:25 × lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 252 seconds)
2021-08-27 11:20:26 <dminuoso> But really, I'd just drop `WriterT` and use `LoggingT`
2021-08-27 11:20:40 <dminuoso> You can feed your log into a C foreign library via LoggingT too
2021-08-27 11:21:40 <trcc> Okay, I will try and see if I can figure this part out
2021-08-27 11:21:48 <trcc> thank you
2021-08-27 11:21:57 <Guest55> I'm applying a function over and over inside state. Doing it manually (line 8 - 11) gives a different result from doing it using `iterate` (line 7). What is happening? https://paste.tomsmeding.com/RxaaJ0nB I'd guess it has something to do with updation of the HashTable, but I'm not sure
2021-08-27 11:32:24 <int-e> Guest55: the iterate thing does return (3,6) >>= next mybook, then return (3,6) >>= next mybook >>= next mybook, ... so 15 `>>= next mybook` in total...
2021-08-27 11:33:30 <trcc> hehe dminuoso I found a way: although 16 -> 20 is not pretty: https://paste.tomsmeding.com/fgHaFy76
2021-08-27 11:33:49 <Guest55> int-e why 15
2021-08-27 11:33:57 <int-e> Guest55: 1+2+3+4+5 = 15
2021-08-27 11:34:16 <dminuoso> trcc: At the very least use WriterT.
2021-08-27 11:34:20 <int-e> gioh the 5 is too much, so it's 10, my bad
2021-08-27 11:34:26 <dminuoso> Instead of manually using Writer and IO.
2021-08-27 11:34:37 <dminuoso> trcc: But really, at the end, use LoggingT.
2021-08-27 11:34:54 pfurla joins (~pfurla@ool-182ed2e2.dyn.optonline.net)
2021-08-27 11:34:55 <Guest55> oh.... I thought iterate reused the previous output
2021-08-27 11:34:56 <dminuoso> Writer has a way of stabbing you in the back in terms of space leaks.
2021-08-27 11:35:02 <trcc> dminuoso: ya, I will try and switch it alter on. But it is a big thing, and I would like to see it working first.. I will try with writerT some time
2021-08-27 11:35:06 × enoq quits (~enoq@2a05:1141:1f5:5600:b9c9:721a:599:bfe7) (Quit: enoq)
2021-08-27 11:35:52 <Drew[m]> dminuoso: umm isn't Control.Monad.Trans.Writer.CPS a fix for that?
2021-08-27 11:36:28 <Drew[m]> trcc: are you using Control.Monad.Trans.Writer.CPS as your source of `Writer`?
2021-08-27 11:36:42 <int-e> Guest55: yes, but it's only building monadic actions here, not running them
2021-08-27 11:37:01 <trcc> Drew[m]: no, I never heard of that before
2021-08-27 11:37:10 <dminuoso> Drew[m]: Maybe yeah, but you still accumulate a log.
2021-08-27 11:37:15 <dminuoso> Unnecessarily
2021-08-27 11:37:29 <Guest55> int-e but it's running it only 4 times in total?
2021-08-27 11:37:40 × pfurla_ quits (~pfurla@53.15.195.173.client.static.strong-in52.as13926.net) (Ping timeout: 240 seconds)
2021-08-27 11:37:57 <dminuoso> With LoggingT you never keep anything around, as it's essentially just some pretty wrapper around (in simplified terms) `ReaderT (String -> IO ()) ...`. There's nothing to "append" to a log.
2021-08-27 11:38:17 <dminuoso> With Writer you have the additional problem of unlifting and working with bracket.
2021-08-27 11:38:27 <dminuoso> You just get headaches
2021-08-27 11:38:38 juhp joins (~juhp@bb116-14-48-29.singnet.com.sg)
2021-08-27 11:38:45 <int-e> Guest55: the argument to `sequence` is [return (3,6), return (3,6) >>= next mybook, return (3,6) >>= next mybook >>= next mybook, ...]
2021-08-27 11:38:46 × juhp quits (~juhp@bb116-14-48-29.singnet.com.sg) (Read error: Connection reset by peer)
2021-08-27 11:38:54 <trcc> Thanks dminuoso and Drew[m]
2021-08-27 11:38:58 <trcc> got some input for later :)
2021-08-27 11:39:32 <int-e> Guest55: and sequence runs each of these actions, with 0, 1, 2, 3, and finally 4 calls to `next mybook`.
2021-08-27 11:39:42 <Guest55> ohhh.... I get it. So when it evaluates, it does not use the previous values, it recomputes from start
2021-08-27 11:40:04 <Guest55> So how can I change this behavior?
2021-08-27 11:40:18 juhp_ joins (~juhp@bb116-14-48-29.singnet.com.sg)
2021-08-27 11:41:00 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:42:24 machinedgod joins (~machinedg@135-23-192-217.cpe.pppoe.ca)
2021-08-27 11:43:00 <int-e> Guest55: you can't use iterate+sequence to accomplish this; I'd write a manual recursion. (but there's bound to be a library that has a monadic version of unfoldr that abstracts from this)
2021-08-27 11:43:06 jippiedoe joins (~david@2a02-a44c-e14e-1-ff47-c45c-287d-42e8.fixed6.kpn.net)
2021-08-27 11:43:38 <Guest55> great! Thanks int-e
2021-08-27 11:43:39 <int-e> Guest55: I'm assuming you want to capture the intermediate results
2021-08-27 11:44:00 × trcc quits (~trcc@users-1190.st.net.au.dk) ()
2021-08-27 11:44:04 <Guest55> I want to find the first result that satisfies a condition
2021-08-27 11:44:21 burnside_ joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:44:25 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:44:37 × neo1 quits (~neo3@cpe-292712.ip.primehome.com) (Ping timeout: 252 seconds)
2021-08-27 11:44:37 <Guest55> I'll write a recursion myself, thanks again!
2021-08-27 11:46:39 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:46:39 × burnside_ quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:46:42 egoist joins (~egoist@186.235.82.117)
2021-08-27 11:46:54 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:47:09 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:47:13 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:47:31 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:47:46 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:47:59 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:48:37 burnside_ joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:48:37 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:49:45 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:49:45 × burnside_ quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:52:39 lua joins (~ed@101.100.135.46)
2021-08-27 11:54:15 burnside_ joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 11:54:15 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Read error: Connection reset by peer)
2021-08-27 11:57:08 oxide joins (~lambda@user/oxide)
2021-08-27 11:58:40 × markpythonicbtc quits (~textual@c-24-6-12-87.hsd1.ca.comcast.net) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-08-27 12:02:57 Codaraxis_ joins (~Codaraxis@user/codaraxis)
2021-08-27 12:03:09 × xff0x quits (~xff0x@2001:1a81:53dc:be00:da3f:ef74:f6f8:c86d) (Ping timeout: 250 seconds)
2021-08-27 12:04:13 xff0x joins (~xff0x@2001:1a81:53dc:be00:a2ac:ecf7:da22:1207)
2021-08-27 12:06:40 × Codaraxis__ quits (~Codaraxis@user/codaraxis) (Ping timeout: 240 seconds)
2021-08-27 12:09:14 <Drew[m]> dminuoso: There's no reason to accumulate a log, from what I can tell. You can consume it piecewise so it is garbage collected as you go
2021-08-27 12:11:01 <Drew[m]> I wrote a little demo to convince myself the log was still produced lazily
2021-08-27 12:11:11 acidjnk_new joins (~acidjnk@p200300d0c72b95925da55fe159cc0756.dip0.t-ipconnect.de)
2021-08-27 12:11:27 <Drew[m]> https://paste.tomsmeding.com/gOFJYdLg
2021-08-27 12:12:03 <dminuoso> Drew[m]: And you need MonadBaseControl for unlifting. What about log entries produced in `catch`?
2021-08-27 12:12:36 <dminuoso> Drew[m]: And that doesnt prove something.
2021-08-27 12:13:00 dschrempf joins (~dominik@070-207.dynamic.dsl.fonira.net)

All times are in UTC.