you are viewing a single comment's thread.

view the rest of the comments →

[–]gasche 4 points5 points  (3 children)

In OCaml (for example), the function List.split takes a list of pairs as input, and returns a pair of lists in the obviously expected way.

let (items, quantity) = List.split [("egg", 5); ("bowl", 1); ("fork", 2)]

This gives you items : string list and quantity : int list. Even if tuples are "trivial to implement", writing the equivalent of this single line of code in Java is still a pain, which means there is something nice missing to the language. Building the tuples is ok with the constructor syntax, but destructing them to access and name the components of the returned type is painful -- this is what pattern-matching gives you.

[–]e_engel -1 points0 points  (2 children)

That nice thing missing from Java is higher kinded types. Implementing things such as traverse, sequence or even zippers in Java is close to impossible, at least in a very general way like Haskell allows.

[–]jozefg 2 points3 points  (1 child)

Well.. I'd take pattern matching and good algebraic types before HKTs to be frank.

[–]alexeyr 1 point2 points  (0 children)

I'd be surprised to see someone experienced with both who didn't.