Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→
Page 1 .. 283 284 285 286 287 288 289 290 291 292 293 .. 17987
1,798,644 events total
2021-06-04 19:47:58 <arjun> monochrom: are you refering to the pdf doc as 'slides'?
2021-06-04 19:47:59 <monochrom> (BTW who actually wrote a two-hour-bloody-long symphony? Answer: Mahler. :) )
2021-06-04 19:48:04 <monochrom> Yeah.
2021-06-04 19:48:22 <arjun> aw'ight
2021-06-04 19:48:36 mpt joins (~tom@p57a566da.dip0.t-ipconnect.de)
2021-06-04 19:48:45 <monochrom> So yeah, you have your weekend 4-hour opera-listening afternoon planned now :)
2021-06-04 19:49:05 <arjun> i am confused. am i being talked to ? : P
2021-06-04 19:49:10 <monochrom> yeah :)
2021-06-04 19:49:18 <arjun> right. yea
2021-06-04 19:49:41 <arjun> i am at that awkward stage anyway. not really a beginner, not really a pro
2021-06-04 19:50:36 <monochrom> In that case, it's similar to me, there are some parts you are ready to pay attention to, and some other parts you just keep in mind "this exists, I'll come back later".
2021-06-04 19:51:01 <arjun> sure
2021-06-04 19:51:13 <arjun> be lazy, like the language
2021-06-04 19:51:43 <monochrom> which is really like most people's experience with classical music "I listen again two years later and find something new"
2021-06-04 19:51:58 <arjun> i listen metal
2021-06-04 19:52:12 × Guest10 quits (~Guest10@187.83.249.216.dyn.smithville.net) (Quit: Client closed)
2021-06-04 19:52:15 <monochrom> I hate analogies. But ironically I make the most perfect analogies.
2021-06-04 19:52:43 <arjun> *insert hulk meme*
2021-06-04 19:52:51 <arjun> i see that as an absolute win
2021-06-04 19:53:11 <dminuoso> monochrom: Mmm, I dont like that the generated asm code differs slightly from the sheets, and there's some strange discrepancies with the diagrams.
2021-06-04 19:53:23 <dminuoso> This is a mind bender already
2021-06-04 19:54:07 <monochrom> Perhaps it needs updating. Every example was true not long ago.
2021-06-04 19:54:32 Izem joins (~Izem@bras-base-london1483w-grc-38-65-95-41-91.dsl.bell.ca)
2021-06-04 19:54:54 <Izem> what is the motivation for do notation?
2021-06-04 19:55:03 <dminuoso> Well, for starters the slides suggest given `Just 1` the payload of the first closure points at the info table of the second closure
2021-06-04 19:55:06 <dminuoso> But then you see something like this:
2021-06-04 19:55:14 <dminuoso> .quadExample.value2_closure+1
2021-06-04 19:55:27 <dminuoso> Where is this +1 coming from?
2021-06-04 19:55:27 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-06-04 19:55:46 <lucky> Izem: easily expressing certain imperative-like constructs and reasoning about them in an imperative-like manner
2021-06-04 19:55:59 <lucky> when you're chaining actions it's syntactic sugar for that, I guess
2021-06-04 19:56:17 Scotty_Trees joins (~Scotty_Tr@162-234-179-169.lightspeed.brhmal.sbcglobal.net)
2021-06-04 19:56:37 <lucky> historically it originates specifically with the IO monad and sort of got dragged along with the realization that monads are much more general than just IO
2021-06-04 19:56:38 <dminuoso> lucky: Think of do-notation as a programmable semicolon/equals-sign from traditional languages. :)
2021-06-04 19:56:47 <Izem> that makes sense, I was just wondering if there was another way, since Haskell is primarily about expressions
2021-06-04 19:56:49 <lucky> dminuoso: pretty much
2021-06-04 19:56:55 <dminuoso> Err, I meant Izem!
2021-06-04 19:57:01 <lucky> Izem: absolutely, it's just syntactic sugar for a sequence of bind operations
2021-06-04 19:57:12 × eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:a54f:2e66:1417:26d8) (Remote host closed the connection)
2021-06-04 19:57:14 <Izem> oh, interesting, what is bind?
2021-06-04 19:57:22 <lucky> https://en.wikibooks.org/wiki/Haskell/do_notation#Just_sugar
2021-06-04 19:57:31 <dminuoso> Izem:: So while in <arbitraryimperative language> you can can write `f = g(); z = h(f);` we get to assign meaning to `=`, `;`, and generalize for non-routines too.
2021-06-04 19:57:37 <Izem> I've been thinking about expressions vs statements for some time know, still confused
2021-06-04 19:57:40 <monochrom> No no, the payload of the 1st closure points at a heap object, this heap object begins with pointer to info table (of I#).
2021-06-04 19:58:00 <lucky> a <- getContents; putStrLn a is the same as getContents -> \a >>= putStrLn a --> \_
2021-06-04 19:58:05 <lucky> \_
2021-06-04 19:58:24 <Izem> s/know/now/
2021-06-04 19:58:50 <dminuoso> monochrom: https://gist.github.com/dminuoso/5c6484cb42e5aa4a6d91e1a24e8ffc67
2021-06-04 19:59:42 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-06-04 20:00:11 <monochrom> Ah! Pointer tagging! Use lsb to indicate "this pointer btw points to a whnf already, and the data construct is the 1st data constructor of its type"
2021-06-04 20:00:12 <dminuoso> Izem: the terms "statement" is usually a syntactic categorization for some languages, in Haskell we don't have statements.
2021-06-04 20:00:14 <lucky> Izem: it's a hamfisted explanation, but think of it as constructing an expression that "queues up" a sequence of statements that will only actually be executed at top-level evaluation when main is invoked
2021-06-04 20:00:36 <dminuoso> Once you accept that we dont have statements, your life will be easier!
2021-06-04 20:00:40 <lucky> Haskell's do notation tries to make that way of thinking about it more statement-like, but yes, it's all a pure expression technically
2021-06-04 20:00:58 <arjun> hamfisted
2021-06-04 20:00:59 <monochrom> So perhaps fast-forward to the "pointer tagging" slide...
2021-06-04 20:01:07 <arjun> my new favourite word.
2021-06-04 20:01:09 <Izem> so this bind is the sequencing operation?
2021-06-04 20:01:20 <dminuoso> monochrom: Oh.
2021-06-04 20:01:30 <monochrom> :) :) :)
2021-06-04 20:02:18 <lucky> Izem: Ahhh this is why everyone gets lost haha. In a context where that makes sense (like the IO monad) yes. But bind is a more general property of monads, and monads themselves are more general than a sequence (whether of data or operations)
2021-06-04 20:02:35 <lucky> Izem: e.g. a list is just a item bound to a list with an item bound to a list... etc.
2021-06-04 20:02:50 <dminuoso> Im guessing explains the .align 8, to allow pointer tagging
2021-06-04 20:03:01 <Izem> I'm going to design a programming language that's why I've been taking time to look at how other languages handle this
2021-06-04 20:03:07 <Izem> lucky interesting
2021-06-04 20:03:08 shriekingnoise joins (~shrieking@186.137.144.80)
2021-06-04 20:03:14 <tput> bind is this (>>=) :: Monad m => m a -> (a -> m b) -> m b, this happens to enforce a dependency. we can use it to express sequencing, but it is more general than that
2021-06-04 20:03:19 <lucky> ^ yes
2021-06-04 20:03:37 <Izem> so monads are one of the key concepts in haskell, nice.
2021-06-04 20:03:46 <dminuoso> Oh good. It's been a long time since we flooded unsuspecting newcomers with confusing bind explanations
2021-06-04 20:03:46 <lucky> it's a mathematical property that when obeyed allows you to generalize about it, it turns out you can reason about sequences of imperative actions, and lists, using the same algorithms and structures
2021-06-04 20:04:03 <dminuoso> Izem: Are you familiar with JavaScript?
2021-06-04 20:04:06 <lucky> heh
2021-06-04 20:04:10 <Izem> yeah in passing
2021-06-04 20:04:26 <lucky> confusing people about monads is all haskell is good for, besides its beautiful expressivity anyway
2021-06-04 20:04:38 <arjun> monads are overrated anyway
2021-06-04 20:04:51 <arjun> team applicative anyone?
2021-06-04 20:04:54 <lucky> heheh
2021-06-04 20:05:05 <lucky> that's probably a better place to start, both in theory and in explanation
2021-06-04 20:05:17 <Izem> do you guys program in clean as well?
2021-06-04 20:05:23 <arjun> once upon a time, there lived a functor
2021-06-04 20:05:29 × juhp quits (~juhp@128.106.188.199) (Ping timeout: 265 seconds)
2021-06-04 20:05:53 <dminuoso> Izem: With a bit of squinting we can think of async/await as monadic, so this is one of the things of what Monad matches except traditional "sequence commands and assign results"
2021-06-04 20:06:07 <dminuoso> (If we look close enough, it's not exactly true, but perhaps to an outsider it might look more motivating)
2021-06-04 20:06:45 <Izem> oh, sorry I've not really looked in depth at async/await. I did in python though so I guess it's the same?
2021-06-04 20:07:18 × ubert quits (~Thunderbi@p200300ecdf259df0e6b318fffe838f33.dip0.t-ipconnect.de) (Remote host closed the connection)
2021-06-04 20:07:49 <tput> Haskell is lazy, so in general it's hard to know when something will actually get eval'd, but in (>>=) :: m a -> (a -> m b) -> m b, to get the result we need to use the function of type (a -> m b), but to use that we need an a from the m a. a monad instance for a type describes how to do that (generally without giving access to the 'a' outside of a bind). This let's us force m a to be eval'd before m b.
2021-06-04 20:07:56 juhp joins (~juhp@128.106.188.199)
2021-06-04 20:08:45 <arjun> are you okay with your undestanding of typeclasses ?
2021-06-04 20:08:56 <dminuoso> Well, so in JavaScript you have these promises, and you'd usually work with them as `httpRequest().then((response) => use(response))`. With async/await you can just write this as `const response = await httpRequest(); use(response)`
2021-06-04 20:08:59 <dminuoso> handwavingly
2021-06-04 20:09:40 <dminuoso> In Haskell this would correspond to `httpRequest >>= (\response -> use response)`, or written in do-notation `do { response <- httpRequest; use response }`
2021-06-04 20:09:56 <dminuoso> This is only very suggestive, though
2021-06-04 20:10:49 <Izem> arjun who is this question for?
2021-06-04 20:10:56 <Izem> dminuoso thanks
2021-06-04 20:11:21 <dminuoso> Izem: Similarly, you might have a function concatMap (which maps each element to a list, and then flattens the resulting nested list by one level). So you could either write: `concatMap [1,2,3] (\i -> [10 * i, 20 * i])` or `do { i <- [1,2,3]; [10 * i, 20 * i ]}`
2021-06-04 20:12:05 × kw quits (~user@2605:a601:a615:f600:601:15f2:ebf9:271) (Read error: Connection reset by peer)
2021-06-04 20:12:22 <arjun> who here is trying to understand monads ?
2021-06-04 20:12:45 kw joins (~user@2605:a601:a615:f600:601:15f2:ebf9:271)
2021-06-04 20:12:52 <arjun> when i was new. i tried understanding `What` a monad was. i failed. miserably

All times are in UTC.