

Scala for Haskell programmers - dons
http://docs.google.com/present/view?id=dhmnf9cf_26cgst4zg8

======
jrockway
Scala 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
No 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) ... }

------
pcof
It reads somewhat like "The Occult for The Arcane", doesn't it?

~~~
jrockway
Perhaps if you don't know Haskell, Scala, or any computer science beyond
"trees"...

