Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,457 events total
2021-08-25 02:43:46 <famubu> dsal: Yeah when we look it as something like 'equations' it make sense.
2021-08-25 02:45:05 × wroathe quits (~wroathe@user/wroathe) (Ping timeout: 250 seconds)
2021-08-25 02:45:06 <dsal> thornAvery: I don't exactly understand what you're specifying there. If you have a list of those functions, then I'd imagine something like `traverse` will get you close, but I'd need to see more context.
2021-08-25 02:55:27 × azeem quits (~azeem@176.201.15.223) (Ping timeout: 240 seconds)
2021-08-25 02:57:27 × famubu quits (~famubu@user/famubu) (Ping timeout: 240 seconds)
2021-08-25 02:58:59 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-08-25 02:58:59 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Changing host)
2021-08-25 02:58:59 wroathe joins (~wroathe@user/wroathe)
2021-08-25 02:59:01 hjulle[m] joins (~hjullemat@2001:470:69fc:105::1dd)
2021-08-25 02:59:22 slack1256 joins (~slack1256@191.126.161.169)
2021-08-25 03:01:00 × Skyfire quits (~pyon@user/pyon) (Ping timeout: 250 seconds)
2021-08-25 03:04:05 azeem joins (~azeem@176.201.15.223)
2021-08-25 03:10:54 × alx741 quits (~alx741@186.178.109.43) (Quit: alx741)
2021-08-25 03:12:47 × azeem quits (~azeem@176.201.15.223) (Ping timeout: 240 seconds)
2021-08-25 03:12:55 merijn joins (~merijn@83-160-49-249.ip.xs4all.nl)
2021-08-25 03:13:02 azeem joins (~azeem@176.201.15.223)
2021-08-25 03:14:06 × [itchyjunk] quits (~itchyjunk@user/itchyjunk/x-7353470) (Remote host closed the connection)
2021-08-25 03:16:56 otto_s_ joins (~user@p4ff272f9.dip0.t-ipconnect.de)
2021-08-25 03:17:45 <aegon> if you forkIO do you have to rebuild your monad stack or is there a way to fork but keep things like ST around with liftIO
2021-08-25 03:17:54 × spruit11 quits (~quassel@2a02:a467:ccd6:1:1d51:90f2:b4a7:ece8) (Ping timeout: 250 seconds)
2021-08-25 03:18:41 <c_wraith> believe it or not, the type of liftIO answers that question
2021-08-25 03:19:11 <c_wraith> also, ST isn't even available as a transformer...
2021-08-25 03:19:26 <aegon> its a ReaderT
2021-08-25 03:19:33 <c_wraith> err, the type of forkIO
2021-08-25 03:20:01 × otto_s quits (~user@p5de2f618.dip0.t-ipconnect.de) (Ping timeout: 248 seconds)
2021-08-25 03:20:49 <c_wraith> anyway. forkIO takes something with a type that unifies with IO a
2021-08-25 03:21:15 <c_wraith> that clearly means it must be IO. Not something wrapping IO
2021-08-25 03:21:29 × waleee quits (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd) (Ping timeout: 250 seconds)
2021-08-25 03:21:55 × raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 250 seconds)
2021-08-25 03:21:59 <c_wraith> now, as far as ReaderT, you can easily reconstruct it inside the forked thread
2021-08-25 03:22:22 <c_wraith> thought if it has any mutable cells in the environment, you will have to respect that you're nondeterministic now
2021-08-25 03:23:22 <aegon> the environment is used to pass along a pool of postgres connections
2021-08-25 03:23:50 <aegon> to reconstruct it I need to pull the env out of the wrapped monad before using liftIO right? maybe i ought to play around and see if i can make the type system happy
2021-08-25 03:25:05 <c_wraith> you can always do something like env <- ask ; forkIO (runReaderT action env)
2021-08-25 03:25:56 <c_wraith> where action is the thing you want to run in the other thread
2021-08-25 03:26:41 <c_wraith> Reader is trvial in a way that makes it easy to reconstruct inside forkIO
2021-08-25 03:26:46 <c_wraith> Err, ReaderT
2021-08-25 03:29:02 <Axman6> fendor: you can think of it as a recursive function (which, really is basically what it is). Definitions can quite happily refer to themselves recursively, and if yuu have a name for a value, then definitions using that value will all point to the same object in memory
2021-08-25 03:29:06 <aegon> well i made things a bit more tricky for me, I wrapped all this in an AppT transformer but given what you said I should be able to peel the onion back and then drop it in. I'm assumping resource-pool is thread safe though also, I need to dig into that, as well as wrap my head around catching exceptions in a forked thread / what to do with them. Hoping to delay thinking about exception handling till my
2021-08-25 03:29:12 <aegon> brain is fresh in the mornin
2021-08-25 03:29:24 <Axman6> uh, ok, I guess they left. sorry fendor
2021-08-25 03:30:02 spruit11 joins (~quassel@2a02:a467:ccd6:1:8c29:d071:7a1c:6a79)
2021-08-25 03:31:13 × slack1256 quits (~slack1256@191.126.161.169) (Remote host closed the connection)
2021-08-25 03:32:47 <c_wraith> yeah, I'd expect the pool to be threadsafe. Not much use having one that isn't.
2021-08-25 03:33:01 <aegon> oy, this means i need to despecialize the rest of my funcs away from IO and go into MonadIO land :?
2021-08-25 03:34:05 <c_wraith> If you want to be polymorphic, yes. Alternatively, you can specialize them to your type
2021-08-25 03:34:41 <dsal> aegon: There's also UnliftIO if you want to into that direction.
2021-08-25 03:36:10 <aegon> dsal: i was looking at unliftIO it seems like the trade-off is somewhere around exception handling, which seems relevant since i have to deal with some around http calls
2021-08-25 03:37:10 <dsal> It's more about solving your stated problem -- you can't carry the stack with you, but you'll want to recreate it on the other side.
2021-08-25 03:40:05 <thornAvery> hello again, i tried to play around with it but im still missing something sorry. my problem is i have a record that i want to pass throguh a number of functions, each of which will either pass it to the next, or exit with either success or failure, possibly after printing some messages to STDIO/STDERR. i think i need to use an Either transformer? at the moment im having to nest cases like this https:/
2021-08-25 03:40:05 <thornAvery> /pastebin.com/raw/TuFjv2Sc which seems bad
2021-08-25 03:42:58 <thornAvery> although, i can probably actually just have an Either monad that returns an IO action now that i look at it, ill give that a try ahh sorry for spamming the channel
2021-08-25 03:47:25 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 252 seconds)
2021-08-25 03:47:29 × azeem quits (~azeem@176.201.15.223) (Ping timeout: 250 seconds)
2021-08-25 03:47:31 × Guest1826 quits (~chris@81.96.113.213) (Remote host closed the connection)
2021-08-25 03:48:06 famubu joins (~famubu@14.139.174.50)
2021-08-25 03:48:08 chris joins (~chris@81.96.113.213)
2021-08-25 03:48:12 chris is now known as Guest7659
2021-08-25 03:52:15 × Guest7659 quits (~chris@81.96.113.213) (Ping timeout: 250 seconds)
2021-08-25 03:52:33 chris joins (~chris@81.96.113.213)
2021-08-25 03:52:36 chris is now known as Guest3591
2021-08-25 03:53:37 × abhixec quits (~abhixec@c-67-169-139-16.hsd1.ca.comcast.net) (Quit: leaving)
2021-08-25 03:53:39 azeem joins (~azeem@176.201.15.223)
2021-08-25 03:56:03 <aegon> dsal hey, UnliftIO is pretty cool i'll try to figure out how to swap it
2021-08-25 03:56:30 <dsal> thornAvery: You might consider not mixing in effects.
2021-08-25 03:57:29 <dsal> There's ExceptT and ContT that might help you create a better structure.
2021-08-25 03:59:13 <dsal> But in general, that's doing too many different things to understand what it's supposed to be.
2021-08-25 04:03:06 × talismanick quits (~user@2601:644:8500:8350::cc04) (Remote host closed the connection)
2021-08-25 04:03:19 talismanick joins (~user@2601:644:8500:8350::cc04)
2021-08-25 04:04:10 falafel joins (~falafel@2601:280:4e00:9970:889a:3513:448f:30e9)
2021-08-25 04:04:14 × ChaiTRex quits (~ChaiTRex@user/chaitrex) (Remote host closed the connection)
2021-08-25 04:04:49 ChaiTRex joins (~ChaiTRex@user/chaitrex)
2021-08-25 04:08:52 × geekosaur quits (~geekosaur@xmonad/geekosaur) (Ping timeout: 252 seconds)
2021-08-25 04:09:59 geekosaur joins (~geekosaur@xmonad/geekosaur)
2021-08-25 04:10:04 × res0nat0r8 quits (~Fletch@dia.whatbox.ca) (Quit: Ping timeout (120 seconds))
2021-08-25 04:10:38 res0nat0r8 joins (~Fletch@dia.whatbox.ca)
2021-08-25 04:10:53 × azeem quits (~azeem@176.201.15.223) (Ping timeout: 250 seconds)
2021-08-25 04:11:18 azeem joins (~azeem@176.201.15.223)
2021-08-25 04:15:33 × fawful quits (~guy@c-76-104-217-93.hsd1.wa.comcast.net) (Quit: WeeChat 3.2)
2021-08-25 04:18:32 × markpythonicbtc quits (~textual@2601:647:5a00:35:999f:46ac:3d0f:19d0) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2021-08-25 04:19:27 markpythonicbtc joins (~textual@2601:647:5a00:35:999f:46ac:3d0f:19d0)
2021-08-25 04:19:35 × famubu quits (~famubu@14.139.174.50) (Changing host)
2021-08-25 04:19:35 famubu joins (~famubu@user/famubu)
2021-08-25 04:23:17 <aegon> hmm ok i have UnliftIO for my top level monad but i need to use a function defined by a librario called withContex :: \/a . (Context -> IOa) -> IO a
2021-08-25 04:23:25 <aegon> but within that inner func i need access to my stack
2021-08-25 04:23:35 <aegon> this seems like what unliftIO is for
2021-08-25 04:23:46 <aegon> or do i need to recreate my stack inside the lambda
2021-08-25 04:23:50 × zebrag quits (~chris@user/zebrag) (Quit: Konversation terminated!)
2021-08-25 04:28:39 × azeem quits (~azeem@176.201.15.223) (Ping timeout: 250 seconds)
2021-08-25 04:29:52 <dsal> unliftio should do most of the work for you.
2021-08-25 04:32:29 <aegon> yeah i'm playing with it now, trying to use withRunInIO but then i get complaints when i try to access side effects in my stack from within that lambda
2021-08-25 04:33:01 <aegon> so i'm trying to get a better grip on it reading fp complete stuff on unliftio
2021-08-25 04:35:40 azeem joins (~azeem@176.201.15.223)
2021-08-25 04:36:28 <aegon> oh i see i need to prefix run on my actions that use my monad within that lambda
2021-08-25 04:37:53 × hgolden quits (~hgolden2@cpe-172-114-84-61.socal.res.rr.com) (Quit: Konversation terminated!)
2021-08-25 04:41:13 × wroathe quits (~wroathe@user/wroathe) (Ping timeout: 250 seconds)
2021-08-25 04:48:38 mei joins (~mei@user/mei)
2021-08-25 04:49:07 <aegon> that works but thats a lot of withRunInIO, and resulting run calls, should I be worried about perf? seems like in a situation where you have to run quite a lot of code in a world that was built for a handler in IO () actions against your own effect stack you end up unwrapping a lot with the withRunInIO helper
2021-08-25 04:50:14 <dsal> It shouldn't be a *lot*. But maybe there's a design problem at a different level.
2021-08-25 04:51:08 <dsal> You said you're using forkIO, right? Are you using the unlifted version?

All times are in UTC.