4 ms·
Scala for Haskell programmers
- pcof 17y agoIt reads somewhat like "The Occult for The Arcane", doesn't it?
- jrockway 17y agoPerhaps if you don't know Haskell, Scala, or any computer science beyond "trees"...
- jrockway 17y agoScala is definitely one of the better functional languages for Java. (It's OO implementation is not that great, however.) I am left with a few questsions: Monoid was used as an example, but does Scala's type system support instances like: instance (Monoid a, Monoid b) => Monoid (a,b) where mempty = (mempty, mempty) ... In this case, a mempty tuple is created by creating a mempty "a" and then a mempty "b". If you think about it, this is obvious, but the question is whether Scala's type system knows what "a" and "b" are at the right time, so it can delegate to the right "other" mempty. (I ask, because I wrote a Haskell-style data structure module for Perl, but it is missing Monoid for this reason. We would know the types after mempty ran, but we can't run it without knowing the types. If only you could fold time back on itself...) Also, they use the word "forAll" to describe type signatures; are higher-rank types allowable?
- runaro 17y agoNo higher-rank types in Scala, I'm afraid. As for the monoid instance: def pairMonoid[A,B](a:Monoid[A],b:Monoid[B]) = new Monoid[(A, B)] { def empty = (a.empty, b.empty) ... }
- deleted 17y ago[deleted]