3 ms·
Not sure what weakness you're referring to in that SO post; the OP is actually saying otherwise: > I have always considered the Scala variation to be on the ad
by virtualwhys 12y ago
Not sure what weakness you're referring to in that SO post; the OP is actually saying otherwise:
> I have always considered the Scala variation to be on the advantageous side [relative to Haskell].
Daniel Spiewak does provide an answer that points out a weakness with scala collections when used with ADTs, but (G)ADTs of and in themselves are pretty damn elegant in Scala, arguably rivaling Haskell equivalent (provided we set aside Scala's slightly more verbose implementation).
- tel 12y agoDaniel's answer is not specific to Scala's collections library but instead any generic type unless it's set to be invariant. That ultimately leads to a tradeoff between soundness and convenience (as mentioned in comment toward Scalaz's Monad impl). Ultimately, both of his points come from the idea that you genuinely want a mechanism for deferring information to runtime and case classes almost give that to you if it weren't for their default to greater typing granularity and covering it up with subtyping relations. The point I made in the comments is that this throws away syntax directness almost everywhere and that tosses out a lot of inference. Ultimately, Haskell's GADTs give you the same power as Scala's case classes, but they require you to actually ask for that level of type specificity and then provide an explicit and delimited family so that inference doesn't get as mucked up. So, I think Scala is certainly workable... but in general disallows precision of desired expression, ironically, by defaulting to greater precision of actual "type". (There's finally a totally pedantic argument to be had that "Inl and Inr aren't types" in some foundational sense. Of course you can consider them types and model a perfectly reasonable type system off of that consideration. That said, they're something a little different from your standard MLTT/BiCCC/TypeTheory/Logic types, fwtw)
- virtualwhys 12y agoThanks, Scala collections in particular are unfortunately capable of wreaking havoc (Paul Phillips' infamous List(1,2,3).contains("your mom")) in surprising ways. I'm not saying that Scala's approach to G(ADT)s is flawless (by any means), but it is powerful, and to cast a strength as a weakness is a bit disengenious, particularly when the SO user is in fact saying, what's the deal, Scala is superior to Haskell in this area. Then again, Scala's terribly unpopular in the Haskell community and here on HN, so casting the language in a bad light is of no surprise. FWIW, I really enjoyed that Twitter Bird pic tweeting out Haskell's logo in this language usage breakdown[1]. Heh, the language that everybody is talking about...and nobody is using O_o Saying that, Haskell by all indications seems poised to take off, so I may be eating my words in future. We shall see, next 3 to 5 years on and off the JVM are going to be interesting times indeed ;-) https://github.com/Dobiasd/programming-language-subreddits-and-their-choice-of-words/blob/master/README.md https://github.com/Dobiasd/programming-language-subreddits-a...
- tel 12y agoI truly disagree that Scala is superior. I think it's different and made an interesting encoding of ADTs. I also don't think Daniel was suggesting anything otherwise, though the op was.