Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→
Page 1 .. 417 418 419 420 421 422 423 424 425 426 427 .. 5022
502,152 events total
2020-10-05 02:13:35 <Squarism> yep
2020-10-05 02:13:43 <Squarism> Bar a
2020-10-05 02:13:51 <ski> if `Bar a' only has `gimmeString :: a -> String', then `exists a. Bar a *> a' is basically the same as just `String'. so the existential is fairly useless, then
2020-10-05 02:14:18 <ski> but perhaps you had some more methods, which perhaps mentioned `a' more than ones ? or perhaps mentioned `a' in return type ?
2020-10-05 02:14:29 <ski> s/ones/once/
2020-10-05 02:15:34 falafel joins (~falafel@2605:e000:1527:d491:706d:90a5:67aa:1cd9)
2020-10-05 02:15:57 × justanotheruser quits (~justanoth@unaffiliated/justanotheruser) (Ping timeout: 272 seconds)
2020-10-05 02:17:25 <Squarism> I tend to confuse myself that classes are like java interface. I forget you have to parameterize all usage of them. a must be bound in scope I guess you say.
2020-10-05 02:19:44 <ski> yea, in an implementation of methods of an interface in Java, you can use `this'
2020-10-05 02:19:52 <ski> there is an object, associated with the interface
2020-10-05 02:19:57 <dsal> I think java's worse at mentally contaminating people than basic.
2020-10-05 02:20:01 <ski> not so, with type classes in Haskell
2020-10-05 02:20:05 × elliott__ quits (~elliott@pool-108-51-141-12.washdc.fios.verizon.net) (Ping timeout: 240 seconds)
2020-10-05 02:20:10 × urodna quits (~urodna@unaffiliated/urodna) (Quit: urodna)
2020-10-05 02:21:25 elliott__ joins (~elliott@pool-108-51-141-12.washdc.fios.verizon.net)
2020-10-05 02:21:53 <quintasan> \o/
2020-10-05 02:21:54 <quintasan> I got it
2020-10-05 02:22:39 <quintasan> But at what price, it's 4:21
2020-10-05 02:22:42 <ski> `Comparable' in Java in Haskell terms would be `exists a. Comparable a *> a', where `Comparable' on the Haskell side would be a type class with a `compareTo :: a -> Object -> Int' method
2020-10-05 02:23:16 <ski> or, with the later `Comparable<T>' in Java, in Haskell terms would be `exists a. Comparable a T *> a', where `Comparable a b' on the Haskell side would be a type class with a `compareTo :: a -> b -> Int' method
2020-10-05 02:24:13 × machinedgod quits (~machinedg@d67-193-126-196.home3.cgocable.net) (Ping timeout: 264 seconds)
2020-10-05 02:24:31 <Squarism> ski, what is that "exists .." thing called?
2020-10-05 02:24:51 <ski> quintasan : hm, i think you might need to find where in the code you're converting from `Transaction' to `Session', and pass `Serializable' and `Write' to the `transaction' call, there ?
2020-10-05 02:24:58 <ski> Squarism : existential quantification
2020-10-05 02:25:06 <justsomeguy> Describing type classes by comparison with features of other languages is starting to become a pet peeve of mine. ...But whatever helps you learn, I guess.
2020-10-05 02:25:27 <ski> (not to be confused with the `ExistentialQuantification' language extension, which, imho, is a misnomer)
2020-10-05 02:25:28 SirClueless joins (42413686@cpe-66-65-54-134.nyc.res.rr.com)
2020-10-05 02:25:43 × cp- quits (~cp-@b157153.ppp.asahi-net.or.jp) (Quit: Disappeared in a puff of smoke)
2020-10-05 02:26:00 agrim is now known as agrif
2020-10-05 02:26:22 agrif is now known as agrim
2020-10-05 02:26:28 toorevitimirp joins (~tooreviti@117.182.181.38)
2020-10-05 02:27:15 justsomeguy got confused by the java analogy since he didn't know java, and then to decipher how type classes (are like|differ from) interfaces he had to learn what the heck and interface is on top of what a type class is. The most readable description was actually from the haskell language report.
2020-10-05 02:27:28 × jle` quits (~mstksg@unaffiliated/mstksg) (Ping timeout: 272 seconds)
2020-10-05 02:27:32 <ski> justsomeguy : iirc, at least last time i looked, traits in Rust were also limited in this way. that is, with neither them, nor interfaces in Java, can you express something like `exists w. Widget w *> Map String w'. iow, they only support encoding `exists x. C x *> x', with the plain existentially quantified variable, after the `*>'
2020-10-05 02:28:04 <SirClueless> I have a beginner question I think. On the wiki page for fibonacci numbers they have the following program for generating an infinite sequence of them: `fibs = 0 : 1 : zipWith (+) fibs (tail fibs)`. What I'm trying to understand is whether or not that function recurses an exponential amount of times or a linear amount of times. Or does Haskell not
2020-10-05 02:28:04 <SirClueless> make any guarantees either way?
2020-10-05 02:28:24 cp- joins (~cp-@b157153.ppp.asahi-net.or.jp)
2020-10-05 02:28:45 <ski> justsomeguy : yea .. it's not intended that people should go learn Java interfaces, to better understand Haskell type classes. it's just that, often, people already have some idea of Java interfaces, and in that case, it might help a bit, to compare with that, when learning type classes. there are similarities, but there's also differences
2020-10-05 02:29:18 <justsomeguy> It seems good for getting an intuition of it, I suppose.
2020-10-05 02:29:42 <dsal> I don't think java is good for getting an intuition. If you have a java intuition, it would help to translate, but it's like any other language translation concept.
2020-10-05 02:29:53 <dsal> i.e., idioms don't translate super well
2020-10-05 02:30:01 ski . o O ( "Interface-passing style" by Fare (François-René Rideau) in 2010-02-17 at <https://fare.livejournal.com/155094.html> )
2020-10-05 02:30:13 <justsomeguy> ¯\_(ツ)_/¯
2020-10-05 02:30:16 <ski> dsal, yep
2020-10-05 02:30:43 <ski> justsomeguy : perhaps not good, but possibly useful, to get into the right ballpark, at least
2020-10-05 02:31:21 <ski> Squarism : it's not a function. and, with by-need / lazy evaluation/reduction, it'll run in linear, not exponential, time
2020-10-05 02:31:54 <justsomeguy> Sure, as a first step, it seems useful. Then again, the idea of a type class isn't that hard. The description is only two paragraphs in the Haskell language report, and actually readable (not too much jargon).
2020-10-05 02:32:11 <ski> (the reason is that the data structure (the list), will act as a cache for the elements of the Fibonacci sequence, not recomputing them)
2020-10-05 02:32:29 <justsomeguy> So sometimes I wonder why people bother with the intermediary step of explaining type classes by comparison.
2020-10-05 02:32:46 <dsal> The hard thing about a haskell typeclass if you're used to a java interface or go interface or C++ abstract class or something is that you can't have a "Show" value.
2020-10-05 02:33:01 <dsal> You'll really want to have a [Show], but you can't do that.
2020-10-05 02:33:02 <Squarism> Sorry to stir up such debate. I used to know this, I just went away for a year and lost details.
2020-10-05 02:33:08 Samos joins (~Kira@201.192.165.173)
2020-10-05 02:33:32 <ski> justsomeguy : being able to define your own derived overloaded operations, with (almost) no special care at all to ensure that happening, when calling other overloaded operations, is not something people tend to be used to, from other languages, though
2020-10-05 02:33:40 <justsomeguy> Squarism: Hey, no problem. I think of this as a friendly conversation rather than a debate. :)
2020-10-05 02:34:17 <Samos> greetings
2020-10-05 02:34:18 <justsomeguy> Fair point, ski -- I suppose the main concept takes some getting used to.
2020-10-05 02:34:26 <ski> dsal : you can have `[exists a. Show a *> a]' .. but (for `Show'), that's not terribly useful. it's more or less just a more hairy version of `[String]'
2020-10-05 02:34:35 <ski> @src elem
2020-10-05 02:34:36 <lambdabot> elem x = any (== x)
2020-10-05 02:34:49 <ski> well, take this implementation
2020-10-05 02:34:52 <SirClueless> @ski so this is a guaranteed part of the Haskell language then, that re-evaluating some early piece of the list will be efficient and not recompute the whole list? I'm just beginning to understand "thunks" so it's hard for me to understand why it's guaranteed by the language, even if it happens in practice
2020-10-05 02:34:52 <lambdabot> Maybe you meant: wiki src ask
2020-10-05 02:35:11 <ski> _ `elem` [ ] = False
2020-10-05 02:35:21 <ski> x0 `elem` (x:xs)
2020-10-05 02:35:55 × Amras quits (~Amras@unaffiliated/amras0000) (Ping timeout: 240 seconds)
2020-10-05 02:36:01 <ski> = x0 == x
2020-10-05 02:36:12 <ski> || x0 `elem` xs
2020-10-05 02:36:31 <SirClueless> Like, I don't really understand yet how the language can guarantee that, in practice, the millionth fibonacci number is available cheaply when requested and won't be recomputed
2020-10-05 02:36:44 <ski> because `(==)' is overloaded (being a method of `Eq'), this `elem' will automagically also be overloaded (requiring `Eq')
2020-10-05 02:38:14 × Quarl quits (~Quarl@94.191.136.1.mobile.tre.se) (Ping timeout: 272 seconds)
2020-10-05 02:38:20 <ski> Squarism : "so this is a guaranteed part of the Haskell language then, .." -- no. but it tends to be what implementations do, unless they have any particular reason to deviate from this (such as speculatively evaluating some sub-expressions that're not demanded (yet, at least), since you have some parallel cores available for use, and you think you might need the value soon)
2020-10-05 02:38:55 <ski> "thunks" is an implementation method, for implementing lazy / by-need reduction/evaluation
2020-10-05 02:39:10 <Squarism> ski, : was that for me?
2020-10-05 02:39:26 <SirClueless> That's so scary to me. It's like saying the performance of the evaluation isn't part of the correctness of the evaluation.
2020-10-05 02:39:44 <ski> Squarism : yes (not the one about uoverloading, but the two messages after that)
2020-10-05 02:39:48 × oisdk quits (~oisdk@2001:bb6:3329:d100:89a1:5b05:b385:265f) (Quit: oisdk)
2020-10-05 02:40:06 <SirClueless> (I think ski is responding to me sometimes while using your name, Squarism)
2020-10-05 02:40:58 <ski> SirClueless : it's something i think all implementations have done by default, unless there's been any clear reason (like optimization) to do otherwise
2020-10-05 02:41:31 <ski> oh. hm, yea, i think i managed to refer to the wrong person, in one message above -- sorry about that
2020-10-05 02:41:38 <justsomeguy> SirClueless: If you enjoy watching videos, I recommend this explanation of thunks ... https://www.youtube.com/watch?v=j19amq73-qA&list=PLe7Ei6viL6jGp1Rfu0dil1JH1SHk9bgDV&index=26 ; I'm not sure it will satisfy your curiosity, but it should at least give you a taste, and maybe you'll find it fun.
2020-10-05 02:42:43 × falafel quits (~falafel@2605:e000:1527:d491:706d:90a5:67aa:1cd9) (Remote host closed the connection)
2020-10-05 02:42:54 justsomeguy chides himself for reccomending stuff even though he's a total noob.
2020-10-05 02:42:55 <ski> SirClueless : note that the language doesn't specify an operational/procedural semantics, how to get to the answer. it only talks about denotational semantics, what the answer is
2020-10-05 02:43:04 <SirClueless> It just seems super scary to say "It's exponential runtime, but in practice on every major Haskell implementation it's linear"
2020-10-05 02:43:25 <SirClueless> Like, in my world that's the same as saying "It's broken, but in practice on every major Haskell implementation it's not broken"
2020-10-05 02:43:37 <dolio> Maybe you should care about the actual implementation, then..
2020-10-05 02:43:38 <dsal> Wait until you learn about optimizing compilers in other languages...
2020-10-05 02:43:38 <ski> SirClueless : by-need / lazy reduction/evaluation is an operational semantics concept. and since the language report doesn't talk about operational semantics, it doesn't specify by-need / laziness
2020-10-05 02:44:02 <SirClueless> It would be like writing non-portable C code that works everywhere in practice: yeah it's OK for now, but still a bit scary
2020-10-05 02:44:18 brandly joins (~brandly@c-73-68-15-46.hsd1.ma.comcast.net)
2020-10-05 02:44:30 <dsal> I've written portable C code that runs everywhere. Except ARM where it segfaults.
2020-10-05 02:45:05 <SirClueless> Exponential vs. Linear Time isn't just operational semantics though: getting the result of Fibonacci in exponential time is just as bad as getting the wrong result from Fibonacci, in pretty much every computation environment I've ever been in
2020-10-05 02:45:32 <ski> (and ditto for talking about time or space complexity. those are operational semantics concepts, and the report doesn't talk about that)
2020-10-05 02:45:52 drbean joins (~drbean@TC210-63-209-23.static.apol.com.tw)
2020-10-05 02:45:58 <SirClueless> Like if it was in a batch process in a data center it would take arbitrary resources, or if it was computed in response to a request to a server, it would timeout
2020-10-05 02:46:11 <SirClueless> And not being able to make any guarantees about that stuff is scary
2020-10-05 02:46:42 <ski> (perhaps one could argue that it ought to talk some about it. e.g. to specify "proper tail recursion" (another misnomer, since it doesn't have to do with recursion, per se), which is a space complexity thing (unbounded number of active tail calls in bounded space))
2020-10-05 02:46:52 <dsal> I think, in practice, you wouldn't use that implementation of fibs as a list of all fibs in a real program. In practice, you write the code that does what you want, and if it can't do it to your efficiency requirements, you change the parts that need to be optimized. Refactoring is super easy in haskell.
2020-10-05 02:47:27 falafel joins (~falafel@2605:e000:1527:d491:706d:90a5:67aa:1cd9)

All times are in UTC.