Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,514 events total
2021-08-27 00:10:27 <roboguy_> maralorn: what would that do?
2021-08-27 00:10:40 <roboguy_> oh, in a do-block
2021-08-27 00:10:41 <maralorn> So e.g. `do {print ('getInt + 'getInt)}` would get desugared to `do {a0 <- getInt; b0 <- getInt; print (a0 + b0)}`
2021-08-27 00:10:45 <roboguy_> like Idris's !?
2021-08-27 00:11:08 <maralorn> Idris has that?
2021-08-27 00:11:13 <Axman6> sounds a wee bit like the proposal for the foo (<- g) x (<- h) syntax... can't remember it's name
2021-08-27 00:11:23 <roboguy_> I think Idris has it with !
2021-08-27 00:11:46 <maralorn> Axman6: Ah, yeah. I thought about using `<-` for that.
2021-08-27 00:12:22 × chisui quits (~chisui@200116b868eba000c7eca115e002477a.dip.versatel-1u1.de) (Quit: Client closed)
2021-08-27 00:12:27 roboguy__ joins (~roboguy_@2605:a601:afe7:9f00:a00e:962b:3f01:b758)
2021-08-27 00:12:53 <monochrom> In bash, "cmd (< cmd2) (> cmd3)" is called process substitution. Perhaps we can call that monadic substitution :)
2021-08-27 00:13:57 <maralorn> Axman6: Do you think it was a ghc-proposal?
2021-08-27 00:14:02 chisui joins (~chisui@200116b868eba000c7eca115e002477a.dip.versatel-1u1.de)
2021-08-27 00:14:09 <roboguy__> there have been a few times where I was thinking it'd be nice to have that
2021-08-27 00:14:21 <yushyin> even more syntax sugar? oO
2021-08-27 00:14:32 <monochrom> https://ro-che.info/ccc/1
2021-08-27 00:14:35 <geekosaur> haskell is mostly syntax sugar]
2021-08-27 00:14:39 <roboguy__> hah
2021-08-27 00:14:47 <roboguy__> that is pretty accurate!
2021-08-27 00:14:54 <Axman6> I think so. I believe it was rejected because ordering becomes a bit painful - if you f (<- g) (<- h) and you need h to execute before g then the syntax doesn't really work
2021-08-27 00:15:00 <roboguy__> especially when you look at Core
2021-08-27 00:15:10 <maralorn> yushyin: Yeah I know. People will hate it.
2021-08-27 00:15:22 <Axman6> Everything is caasseee, everything is case when you look at the core...
2021-08-27 00:15:49 <roboguy__> occasionally it is let
2021-08-27 00:16:03 <Axman6> Let's just fancy case
2021-08-27 00:16:06 <Axman6> (I know it's not)
2021-08-27 00:16:07 <roboguy__> haha
2021-08-27 00:16:23 × roboguy_ quits (~roboguy_@2605:a601:afe7:9f00:1cd3:839e:78c5:a38b) (Ping timeout: 250 seconds)
2021-08-27 00:16:27 <c_wraith> never a case without a let
2021-08-27 00:16:33 <maralorn> Axman6: flip?
2021-08-27 00:16:44 <roboguy__> let there be a case
2021-08-27 00:16:44 <Axman6> that becomes gross very quickly
2021-08-27 00:16:53 <Axman6> IMO flip is almost always a code smell
2021-08-27 00:16:54 <monochrom> What if the syntax is "f (30 <- g) (20 <- h)" using ordinals 20 and 30 to indicate order?
2021-08-27 00:17:09 <c_wraith> monochrom: are you reinventing BASIC intentionally?
2021-08-27 00:17:16 <Axman6> -XBASICMonadicExecution
2021-08-27 00:17:30 <monochrom> Haha I don't know. I am not free of BASIC influence.
2021-08-27 00:17:47 <roboguy__> ah, you sorta run into the issues that you have with sequence points in C?
2021-08-27 00:18:09 <maralorn> You can always do { let x = (<- h); f (<- g) x } if you really need the other order.
2021-08-27 00:18:14 <monochrom> flip is also not very general.
2021-08-27 00:18:58 <monochrom> Ugh that breaks how "let" is supposed to preserve equational reasoning.
2021-08-27 00:19:04 <maralorn> idk, unisonlang has this feature (with their effect system) and I think writing code with it is really pleasant.
2021-08-27 00:19:29 <maralorn> monochrom: That is a fair point.
2021-08-27 00:19:57 <maralorn> do { x <- h; f (<- g) x} ?
2021-08-27 00:20:56 <maralorn> otoh that kinda lessens the appeal since I have always been a little annoyed by <- and = being so different things …
2021-08-27 00:21:49 <monochrom> 'getInt + 'getInt is a misleading example.
2021-08-27 00:22:01 <roboguy__> it's more weird to me that = is often used in effectful ways
2021-08-27 00:22:02 <maralorn> monochrom: Why?
2021-08-27 00:23:01 <monochrom> 'getInt - 'getInt is a slightly better example that alerts you to the issue "what if my intetion is y<-getInt; x<-getInt; return (y-x), not (x-y)"
2021-08-27 00:23:24 Lycurgus joins (~juan@cpe-45-46-140-49.buffalo.res.rr.com)
2021-08-27 00:24:04 <maralorn> monochrom: Yeah, there needs to be some simple rule for that.
2021-08-27 00:24:11 <monochrom> In general an honest example involves a non-commutative f (or even, if 3 parameters are involved, also non-associative) so that the order issue we were discussing is immediately self-evident.
2021-08-27 00:24:28 <maralorn> Fair
2021-08-27 00:24:54 <monochrom> Such an honest example also destroy the fantasy of believing that such a feature is nice.
2021-08-27 00:25:13 <monochrom> This is why honest examples are never given.
2021-08-27 00:25:18 <maralorn> but, but
2021-08-27 00:25:25 <maralorn> I programmed with it. It was nice.
2021-08-27 00:25:36 <maralorn> It was in a strict language though …
2021-08-27 00:25:50 <monochrom> Haskell's IO is also a strict language.
2021-08-27 00:26:56 <monochrom> Err I botched my example. I wanted "return (x-y)" and I wanted the user to enter y first.
2021-08-27 00:28:05 × raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 250 seconds)
2021-08-27 00:28:18 <roboguy__> :t print =<< (-) @Int <$> readLn <*> readLn
2021-08-27 00:28:19 <lambdabot> error:
2021-08-27 00:28:19 <lambdabot> Pattern syntax in expression context: (-)@Int
2021-08-27 00:28:19 <lambdabot> Did you mean to enable TypeApplications?
2021-08-27 00:28:43 <roboguy__> :t print =<< (-) <$> (readLn :: IO Int) <*> readLn
2021-08-27 00:28:44 <lambdabot> IO ()
2021-08-27 00:31:34 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:c1b3:f9cf:5870:faa7) (Remote host closed the connection)
2021-08-27 00:31:53 <roboguy__> I feel like between (=<<), (>>=), (<$>) and (<*>) you can get decently far (especially if you throw in an operator that is defined as \f x -> join (f <*> x))
2021-08-27 00:32:00 × epolanski quits (uid312403@id-312403.helmsley.irccloud.com) (Quit: Connection closed for inactivity)
2021-08-27 00:32:42 <monochrom> @type \f x -> join (f <*> x)
2021-08-27 00:32:43 <lambdabot> Monad m => m (a1 -> m a2) -> m a1 -> m a2
2021-08-27 00:33:11 <roboguy__> I used that a lot when I worked with the z3 package, due to how it's EDSL types are
2021-08-27 00:33:27 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-08-27 00:33:40 × azeem quits (~azeem@176.200.209.130) (Ping timeout: 240 seconds)
2021-08-27 00:33:47 <maralorn> roboguy__: Yeah, you can. But it feels far less intuitive.
2021-08-27 00:34:18 azeem joins (~azeem@176.200.209.130)
2021-08-27 00:34:40 <maralorn> There was at the minimum a year in my Haskell learning experience where <$> and <*> scared the shit out of me.
2021-08-27 00:35:19 × werneta quits (~werneta@70-142-214-115.lightspeed.irvnca.sbcglobal.net) (Remote host closed the connection)
2021-08-27 00:36:17 <Axman6> Extremely general things like that can be very difficult to grok
2021-08-27 00:36:38 × Lord_of_Life quits (~Lord@user/lord-of-life/x-2819915) (Ping timeout: 250 seconds)
2021-08-27 00:37:12 <Axman6> I think for most people the understanding comes from seeing how they behave for specific choices of applicatives, and then fetting a feel for the general pattern. Eventually it just becomes "Oh this this is an applicative, I can do these things too, and have a good expectation of how they should behave)
2021-08-27 00:37:16 <Axman6> s/)/"
2021-08-27 00:37:47 × PinealGlandOptic quits (~PinealGla@37.115.210.35) (Quit: leaving)
2021-08-27 00:38:05 × alx741 quits (~alx741@181.196.68.187) (Quit: alx741)
2021-08-27 00:38:07 <roboguy__> that's exactly my recommendation for stuff like that, too. I think it's a pretty effective way to learn
2021-08-27 00:38:09 Lord_of_Life joins (~Lord@user/lord-of-life/x-2819915)
2021-08-27 00:38:34 × NieDzejkob quits (~quassel@195.149.98.3) (Ping timeout: 252 seconds)
2021-08-27 00:38:36 <haskl> maerwald, I just read the bit about not being able to test code that isn't exported, basically. I'm having trouble with defining the type of something in an example as some type that doesn't get exported. It seems like there's no way around that fact besides changing my code so it *does* export that code. That's a major limitation of cabal-docspec if I'm not mistaken.
2021-08-27 00:38:48 <roboguy__> some things can certainly still be tricky though (many category theory things immediately come to mind, for me personally)
2021-08-27 00:39:04 eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:c1b3:f9cf:5870:faa7)
2021-08-27 00:40:41 werneta joins (~werneta@70-142-214-115.lightspeed.irvnca.sbcglobal.net)
2021-08-27 00:41:44 NieDzejkob joins (~quassel@195.149.98.3)
2021-08-27 00:42:39 <Axman6> Like understanding Applicative with Maybe is pretty easy, generalise a function over arguments which might not exist, and the result only exists if they all did. Then generalising a function where each argument can be chosen from lists is the next step. Generalising a function over arguments that can come from IO. And eventually you get that feel for "generalise a funnction over..."
2021-08-27 00:42:46 × chisui quits (~chisui@200116b868eba000c7eca115e002477a.dip.versatel-1u1.de) (Ping timeout: 246 seconds)
2021-08-27 00:43:44 <maralorn> Today for me most monad/applicative/category operators seem easy. Never the less I observe my self always bailing out to writing stuff in do notation because it is more intuitive and scales much better to more complicated expressions.
2021-08-27 00:44:39 <maralorn> And then when I have working code I refactor it to use more operators because that feels prettier.
2021-08-27 00:45:13 <maralorn> But I guess that’s bad because when it was hard for me to write quickly it’s probably hard for others to read quickly.
2021-08-27 00:46:57 <maralorn> I feel that some await like syntax would help with that.
2021-08-27 00:48:13 <maralorn> (and for people annoyed by Haskell syntax getting bigger and bigger. I can give you a list of syntax features that I would like to see dropped for balance. :-p)

All times are in UTC.