Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-04 23:43:39 conal_ joins (~conal@64.71.133.70)
2021-03-04 23:44:07 curiousgay joins (~gay@178.217.208.8)
2021-03-04 23:45:22 <heck-to-the-gnom> What's the difference between `<>` & `++`? Practically, anyway.
2021-03-04 23:45:33 <monochrom> <> is more general.
2021-03-04 23:45:34 <koz_> heck-to-the-gnom: <> is more general.
2021-03-04 23:45:37 <koz_> Ninja'd.
2021-03-04 23:45:40 <koz_> :t (<>)
2021-03-04 23:45:41 <lambdabot> Semigroup a => a -> a -> a
2021-03-04 23:45:45 <monochrom> There are pros and cons to being more general.
2021-03-04 23:45:45 <koz_> :t (++)
2021-03-04 23:45:47 <lambdabot> [a] -> [a] -> [a]
2021-03-04 23:45:56 <koz_> heck-to-the-gnom: ^ is your difference
2021-03-04 23:46:02 <shachaf> dolio: To be fair, they probably weren't that great before either.
2021-03-04 23:46:02 <monochrom> But <> came later. Much later.
2021-03-04 23:46:05 f-a joins (~f-a@151.68.209.64)
2021-03-04 23:46:10 heatsink joins (~heatsink@2600:1700:bef1:5e10:b42a:6451:2211:3708)
2021-03-04 23:46:16 <shachaf> But they're certainly worse off after.
2021-03-04 23:46:54 <f-a> I am getting `Could not deduce (Foldable t0) arising from a use of ‘elem’` errors while building Cabal (git). I suspect this is due to a GHC mismatch. Mine is 8.8.3, which one should I use?
2021-03-04 23:47:24 <heck-to-the-gnom> I mean, I can see the type differences, but doesn't that just add the case for scenarios where you're not dealing with array-based types, but ones that can be conjoined? Perhaps like a queue type of some sort?
2021-03-04 23:47:40 <koz_> heck-to-the-gnom: That doesn't even gel here.
2021-03-04 23:47:44 <heck-to-the-gnom> So, support for non-list/array derived conjoables?
2021-03-04 23:47:54 <heck-to-the-gnom> conjoinables**
2021-03-04 23:47:54 <koz_> Semigroup is a mathematical concept.
2021-03-04 23:48:05 <koz_> List concatenation is one example of a semigroup operation.
2021-03-04 23:48:10 × Jesin quits (~Jesin@pool-72-66-101-18.washdc.fios.verizon.net) (Quit: Leaving)
2021-03-04 23:48:13 <koz_> There are _many, many, many_ others.
2021-03-04 23:48:18 <koz_> (<>) works (theoretically) for all of them.
2021-03-04 23:48:22 <koz_> (++) is specific to lists.
2021-03-04 23:48:26 <koz_> WHich are not arrays.
2021-03-04 23:48:40 koz_ sighs at argumentum ad serpentum rearing its head.
2021-03-04 23:48:43 <ByteEater> on the dependent typing and "magical" optimization capabilities in a shorter time frame though, one more thing I imagine possible is for APIs based on gdp to become more popular and then if there's a proof (produced mostly by the functions down the data dependency graph, not tediously by the programmer) of stronger properties, paths with more
2021-03-04 23:48:44 <ByteEater> optimizations become available for selection by functions like drop but gdp-aware, at compile time or runtime
2021-03-04 23:49:16 <heck-to-the-gnom> depends on which language, I suppose, in python arrays/lists are synonyms, but I'll take your word for it in regards to haskell
2021-03-04 23:49:32 <monochrom> Python is wrong. Python is poison in this regard.
2021-03-04 23:49:49 <monochrom> But you're welcome to use <> pervasively if you like it more.
2021-03-04 23:49:58 kiweun joins (~kiweun@2607:fea8:2a62:9600:a84d:3e6e:7692:7abe)
2021-03-04 23:50:04 <monochrom> <> did not exist 20 years ago. ++ did.
2021-03-04 23:50:13 <heck-to-the-gnom> It's quick & dirty, all that it's meant to be, simple scripts, nothing else, unless, you're werd AF
2021-03-04 23:50:14 <koz_> heck-to-the-gnom: The problem is that array and list are not synonymous in literally any other context.
2021-03-04 23:50:20 <heck-to-the-gnom> weird*
2021-03-04 23:50:22 <koz_> And it basically confusing about a thousand issues.
2021-03-04 23:50:28 <koz_> And leads to writing of really awful code.
2021-03-04 23:50:48 <heck-to-the-gnom> OK, to me I've never seen another language where the distinction is made, I'll keep that in mind, however
2021-03-04 23:51:06 <koz_> It's literally 'every other language'.
2021-03-04 23:51:10 <koz_> As well as algorithm analysis.
2021-03-04 23:51:20 <koz_> Python is alone is this bizarre conflation.
2021-03-04 23:51:26 <koz_> s/is/in/
2021-03-04 23:51:28 <monochrom> I don't doubt Python's value in other regards. But it is wrong, dishonest, and poisonous on the topic of lists and arrays.
2021-03-04 23:51:48 <koz_> monochrom: It's wrong, dishonest and poisonous on a lot of other topics too, don't worry.
2021-03-04 23:51:49 <ByteEater> many languages have it the Python way, e.g. JavaScript
2021-03-04 23:51:56 <koz_> ByteEater: No they don't.
2021-03-04 23:51:59 <heck-to-the-gnom> It's always been an array as a basic type, and I've never seen a list as a type, but the words have been synonymous to me until now
2021-03-04 23:52:07 <koz_> In JavaScript, arrays have array-like behaviour and perf.
2021-03-04 23:52:08 <heck-to-the-gnom> (in my experience)
2021-03-04 23:52:19 <monochrom> It is the #1 cause of why many CS graduates can't tell the difference, cost-wise.
2021-03-04 23:52:28 <koz_> heck-to-the-gnom: If you take nothing away from here, take this: lists are never, ever, ever, arrays.
2021-03-04 23:52:34 <koz_> And anyone who tells you otherwise is a liar.
2021-03-04 23:52:48 <heck-to-the-gnom> unless, in the context of python, got it
2021-03-04 23:52:52 <koz_> s/nothing/nothing else/
2021-03-04 23:52:57 <ByteEater> well, the API is similar, you can push and pop, shift and unshift, splice, and even delete
2021-03-04 23:52:57 <koz_> Python can be wrong in its own bubble.
2021-03-04 23:53:00 <heck-to-the-gnom> nice
2021-03-04 23:53:06 <koz_> It coasts on its own popularity and hero-worship.
2021-03-04 23:53:14 <ByteEater> there are optimizations, but if an array becomes sparse, most bets are off
2021-03-04 23:53:18 <qih> koz_: Not a Python fan then? 8-) o/
2021-03-04 23:53:26 <koz_> qih: I don't violently loathe it.
2021-03-04 23:53:31 <koz_> Merely strongly disdain.
2021-03-04 23:53:38 <qih> Hahaha
2021-03-04 23:53:41 <heck-to-the-gnom> but, do tell me, what's the difference between an array & a list, you've gotten me curious
2021-03-04 23:53:55 × kiweun quits (~kiweun@2607:fea8:2a62:9600:a84d:3e6e:7692:7abe) (Ping timeout: 240 seconds)
2021-03-04 23:54:03 <qih> Good point re List v Array
2021-03-04 23:54:06 <ByteEater> there's no fundamental reason the same couldn't be done in a Python implementation, it's just that there's just one that counts more than all the others
2021-03-04 23:54:07 <koz_> heck-to-the-gnom: Arrays have O(1) random access, lists have O(n).
2021-03-04 23:54:39 <monochrom> "array" = consecutive boxes. "list" = linked list, the pointer-to-next-node one.
2021-03-04 23:54:40 <koz_> (I should have said Theta(1) and Theta(n) there)
2021-03-04 23:55:13 <dolio> If you're going to get all passionate, shouldn't you say that arrays aren't really constant time, either?
2021-03-04 23:55:27 <monochrom> They basically have opposite cost trade-offs.
2021-03-04 23:55:29 <koz_> dolio: True. But the fact is, they don't have identical random access.
2021-03-04 23:55:44 <koz_> But yeah, you are right, constant-time indexing is basically a lie in practice.
2021-03-04 23:55:51 <ByteEater> heck-to-the-gnom, sticking with <> gives you also the ability to switch, if you wish some day, from String to something more tweaked like Data.Text without changing the operator in existing code
2021-03-04 23:55:59 <heck-to-the-gnom> So, lists are more similar to queues, seeing as to get to the next one, you need to visit the previous?
2021-03-04 23:56:08 <heck-to-the-gnom> Back to the original topic: Is there any noticeable performance gain or deficit to using `<>` rather than `++`?
2021-03-04 23:56:09 <monochrom> Yes.
2021-03-04 23:56:15 <koz_> There can be.
2021-03-04 23:56:15 × heatsink quits (~heatsink@2600:1700:bef1:5e10:b42a:6451:2211:3708) (Remote host closed the connection)
2021-03-04 23:56:16 <heck-to-the-gnom> Good point ByteEater.
2021-03-04 23:56:56 <koz_> heck-to-the-gnom: Have you ever done any course(s) on data structures and algorithms?
2021-03-04 23:56:57 <heck-to-the-gnom> In a very trivial use case, mind you
2021-03-04 23:56:59 <koz_> If not, I advise it.
2021-03-04 23:57:02 <koz_> It's quite enlightening.
2021-03-04 23:57:12 <heck-to-the-gnom> I'll look into it
2021-03-04 23:57:13 × Guest42328 quits (~textual@mskresolve-a.mskcc.org) (Quit: Textual IRC Client: www.textualapp.com)
2021-03-04 23:57:46 <koz_> FWIW I always use <>.
2021-03-04 23:57:58 heatsink joins (~heatsink@2600:1700:bef1:5e10:b42a:6451:2211:3708)
2021-03-04 23:58:08 <koz_> But that's mostly because I don't use lists all that often in situations where concatenation comes up a lot.
2021-03-04 23:58:44 <heck-to-the-gnom> Man, if python uses a list under the hood instead of an array they just call a list, then I'm going to be mad at them.
2021-03-04 23:58:54 <koz_> heck-to-the-gnom: They use a dynamic array.
2021-03-04 23:59:07 <heck-to-the-gnom> ok, good
2021-03-04 23:59:13 <koz_> Which is basically an array that self-resize.
2021-03-04 23:59:19 <monochrom> On this April 1st, someone will impersonate Stroustrup and say "in retrospect, I should have named my language C<>".

All times are in UTC.