Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,677 events total
2021-07-27 17:58:48 <Cale> case theMaybeIO of
2021-07-27 17:58:55 <Cale> Nothing -> ... do something else ...
2021-07-27 17:59:05 <Cale> Just x -> x
2021-07-27 17:59:22 <Cale> If you want to do nothing in the Nothing case, then you could write return ()
2021-07-27 17:59:33 <kmein> :t maybe (return ()) id
2021-07-27 17:59:34 <lambdabot> Monad m => Maybe (m ()) -> m ()
2021-07-27 17:59:35 <Cale> (which is an action that does nothing)
2021-07-27 17:59:44 <kmein> (for a one-liner)
2021-07-27 17:59:53 sedeki joins (~textual@user/sedeki)
2021-07-27 18:00:49 <Cale> Yeah, or in fact, that sequence function I mentioned earlier would also work because Maybe is Traversable
2021-07-27 18:00:59 <lechner> that's exactly what i tried to avoid with the Maybe monad. i kind of came from there: https://dpaste.org/SL7E
2021-07-27 18:01:01 <Cale> sequence :: Maybe (IO a) -> IO (Maybe a)
2021-07-27 18:01:22 × dunkeln quits (~dunkeln@94.129.69.87) (Ping timeout: 240 seconds)
2021-07-27 18:01:34 <Cale> There's also a version called sequence_ which drops the result
2021-07-27 18:01:36 <Cale> :t sequence_
2021-07-27 18:01:37 <lambdabot> (Foldable t, Monad m) => t (m a) -> m ()
2021-07-27 18:02:06 <lechner> it's probably hard to see in the diff, but i replaced the "case of"s with <-
2021-07-27 18:02:14 <Cale> So, t = Maybe and m = IO will get you a thing that does nothing if the Maybe is Nothing, and executes the action if it's Just of some action
2021-07-27 18:02:40 <lechner> that's what i need
2021-07-27 18:03:56 × hughjfchen quits (~hughjfche@vmi556545.contaboserver.net) (Ping timeout: 265 seconds)
2021-07-27 18:04:17 <Cale> I honestly don't mind your original case expressions though (but I would usually avoid defining the scrutinee with let immediately prior)
2021-07-27 18:04:34 hughjfchen joins (~hughjfche@vmi556545.contaboserver.net)
2021-07-27 18:04:43 <Cale> However, it depends on how we expect the program to change over time
2021-07-27 18:05:14 <lechner> it will change because i am learning
2021-07-27 18:05:18 <Cale> If you end up wanting to handle the failure cases more nicely, you'll probably end up replacing the return () in the failure case with something else, and then there won't necessarily be a shorthand.
2021-07-27 18:05:41 <Cale> (at least, not one which is more readable than a case expression would be)
2021-07-27 18:06:19 <lechner> i don't actually need to handle them, I don't think, but I will hold onto the case expressions for now
2021-07-27 18:06:32 mastarija joins (~mastarija@31.217.8.174)
2021-07-27 18:06:39 <lechner> what did you mean with scrutinee plesae?
2021-07-27 18:06:49 burnsidesLlama joins (~burnsides@dhcp168-022.wadham.ox.ac.uk)
2021-07-27 18:07:09 <lechner> the "let"s that is
2021-07-27 18:07:18 × chris_ quits (~chris@81.96.113.213) (Remote host closed the connection)
2021-07-27 18:07:28 <monochrom> In "case foo x of ...", the scrutinee is "foo x".
2021-07-27 18:07:54 <monochrom> The victim of pattern matching.
2021-07-27 18:08:46 <monochrom> DigitalKiwi: Haha congrats
2021-07-27 18:08:50 <lechner> yes, that was kind of pointless. i see it now
2021-07-27 18:10:13 <lechner> monochrom Cale: so elegant. thank you!
2021-07-27 18:10:21 <DigitalKiwi> <butterfly meme> is this a thunk?
2021-07-27 18:10:37 dunkeln joins (~dunkeln@94.129.69.87)
2021-07-27 18:10:53 × dunkeln quits (~dunkeln@94.129.69.87) (Client Quit)
2021-07-27 18:11:00 <DigitalKiwi> the previously unevalutaed lazy joke has been evaluated
2021-07-27 18:11:29 <monochrom> :)
2021-07-27 18:11:48 <DigitalKiwi> https://ircbrowse.tomsmeding.com/day/lchaskell/2021/07/26?id=112114#trid112114 for anyone lost about wtf we're talking about lol
2021-07-27 18:12:11 chris_ joins (~chris@81.96.113.213)
2021-07-27 18:16:26 × chris_ quits (~chris@81.96.113.213) (Ping timeout: 250 seconds)
2021-07-27 18:17:12 × zmt01 quits (~zmt00@user/zmt00) (Quit: Gone.)
2021-07-27 18:18:52 × lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 245 seconds)
2021-07-27 18:20:17 zmt00 joins (~zmt00@user/zmt00)
2021-07-27 18:22:10 × stefan-_ quits (~cri@42dots.de) (Ping timeout: 240 seconds)
2021-07-27 18:23:30 × xff0x quits (~xff0x@2001:1a81:527c:b500:a365:4553:d50c:f6f5) (Ping timeout: 268 seconds)
2021-07-27 18:23:47 xff0x joins (~xff0x@2001:1a81:527c:b500:2b8c:4e21:9ff9:e65e)
2021-07-27 18:24:46 × jao quits (~jao@cpc103048-sgyl39-2-0-cust502.18-2.cable.virginm.net) (Remote host closed the connection)
2021-07-27 18:25:42 × gehmehgeh quits (~user@user/gehmehgeh) (Quit: Leaving)
2021-07-27 18:26:10 stefan-_ joins (~cri@42dots.de)
2021-07-27 18:26:52 × sedeki quits (~textual@user/sedeki) (Quit: Textual IRC Client: www.textualapp.com)
2021-07-27 18:27:03 jao joins (~jao@cpc103048-sgyl39-2-0-cust502.18-2.cable.virginm.net)
2021-07-27 18:27:47 × mr-red quits (~drd@2001:b07:a70:9f1f:1562:34de:f50f:77d4) (Quit: ZNC 1.8.2 - https://znc.in)
2021-07-27 18:28:16 Obo joins (~roberto@70.pool90-171-81.dynamic.orange.es)
2021-07-27 18:29:48 eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net)
2021-07-27 18:29:55 drd joins (~drd@2001:b07:a70:9f1f:1562:34de:f50f:77d4)
2021-07-27 18:31:50 × mastarija quits (~mastarija@31.217.8.174) (Quit: Leaving)
2021-07-27 18:33:37 × burnsidesLlama quits (~burnsides@dhcp168-022.wadham.ox.ac.uk) (Remote host closed the connection)
2021-07-27 18:36:55 burnsidesLlama joins (~burnsides@dhcp168-022.wadham.ox.ac.uk)
2021-07-27 18:39:27 <lechner> Hi, what's is the z0 in my function's "ZMQ z0 ()" return type, please? This is inside the ZMQ monad. https://hackage.haskell.org/package/zeromq4-haskell
2021-07-27 18:40:30 <Rembane> lechner: Probably the rest of the monad transformer stack.
2021-07-27 18:40:38 <Rembane> lechner: Do you have some example code?
2021-07-27 18:41:07 <geekosaur> that said, when ghc appends a number to a type it usually means you forgot to connect something up, so it's inventing a new type
2021-07-27 18:41:23 <Rembane> Yes, and also typed holes are great.
2021-07-27 18:41:32 <Cale> The maintainer should really build and upload the documentation for that package separately
2021-07-27 18:41:52 <lechner> why did it FTB?
2021-07-27 18:42:07 <Cale> Probably the external library dependencies
2021-07-27 18:42:28 <lechner> Rembane: https://dpaste.org/STjO#L87
2021-07-27 18:42:46 <lechner> geekosaur: I think i invented it!
2021-07-27 18:42:51 <Cale> Apparently, ZMQ is like ST, and so the "z" parameter is actually meaningless, it's just there to prevent you from using ZMQ sockets created by one session with another.
2021-07-27 18:43:17 <lechner> is see
2021-07-27 18:43:24 <Cale> runZMQ :: MonadIO m => (forall z. ZMQ z a) -> m a -- in order to use this, any occurrence of the "z" parameter can't occur in "a"
2021-07-27 18:44:30 <Cale> And so data structures which have a "z" in them can't be smuggled out in the result, (and even if you did somehow, e.g. by using an existential type, you still couldn't use them with another runZMQ, since there's effectively a new "z" each time.
2021-07-27 18:46:53 <lechner> i tried _ instead of z0 but GHC did not like it, and referred me to PartialTypeSignatures which i did not adopt
2021-07-27 18:47:17 <Cale> Yeah, if you want to use _'s in types, you have to turn on PartialTypeSignatures
2021-07-27 18:47:22 <DigitalKiwi> lechner is ghc
2021-07-27 18:47:46 <Cale> Any variable letter will do there, but I'd stick with the z that the library uses.
2021-07-27 18:47:57 <DigitalKiwi> that's why ghc is so slow sometimes; it has to ask lechner to type infer!
2021-07-27 18:48:04 <lechner> in the well-defined world of Haskell, how can i legally refer to a z0 that was never defined?
2021-07-27 18:48:13 <Cale> Well, what are you trying to do?
2021-07-27 18:48:37 <lechner> Just compile (TM)
2021-07-27 18:48:54 <Cale> Usually you will want to leave the z polymorphic, so writing just z there will do
2021-07-27 18:49:20 <lechner> okay
2021-07-27 18:49:29 <Cale> (in fact, if it became not-polymorphic, that would mean that you could never use the action)
2021-07-27 18:50:24 <lechner> i don't know what that means, but it sounds like something that could make me sleep poorly
2021-07-27 18:50:34 <Cale> When you have a ZMQ action which returns something like a socket, you'll have to ensure the z's match, like ZMQ z (Socket z)
2021-07-27 18:51:00 <lechner> i see
2021-07-27 18:51:23 <Cale> It's as though each time you use runZMQ, it gets to invent its own z type
2021-07-27 18:51:26 <lechner> what does the zero do then, please?
2021-07-27 18:51:44 <lechner> it means nothing?
2021-07-27 18:51:46 <Cale> and that prevents sockets and such from being created in one runZMQ and being used in another
2021-07-27 18:51:52 <lechner> yeah
2021-07-27 18:51:54 <c_wraith> z0 is just a name
2021-07-27 18:51:58 <lechner> that makes sense
2021-07-27 18:52:02 <c_wraith> It has no inherent meaning
2021-07-27 18:52:13 <monochrom> Every name has no meaning, actually.

All times are in UTC.