10.4.5 Scala

Scala is a multiparadigm language like Common Lisp; though it’s statically typed, it seems to have been influenced by Lisp in some ways — it’s expression-oriented, for instance, and comes with a REPL. It might be my language of choice if I weren’t so fond of Common Lisp. Though it’s not pure like Haskell, it does have good support for the functional style.

Being a language, not just a library, Scala could have added quasi-mutating operators, but doesn’t have them.

Immutable maps have a withDefault method, although it takes a function to compute the default rather than just the default value. This is more powerful in some ways, yet it limits what the implementation can do with the default; for example, FSet’s map-difference will tell you if the first argument map has a default different from the second’s. Scala wouldn’t be able to do this.

But Scala’s map combining operations are impoverished compared to both Haskell’s and FSet’s; it has neither intersection nor difference operations, and its map union operation can only do shadowing of values in the left operand by those in the right one; there’s no provision for a value-combining function.

These are fairly minor points, though. Overall, it looks like Scala’s functional collections seem nearly as well built out as Haskell’s.

Like Clojure and Java, Scala uses abstract equality.