I just read a tutorial on Session Types. Session Types are a means for statically verifying a protocol between two (or with the new release, more) parties. It is what Erlang’s type system would be if Erlang had a type system.
The tutorial is very good, so I won’t belabor the point by reintroducing them here, but here’s a little teaser. Let’s say you have two processes, implemented like so:
process1 = do x <- recv y <- recv send (x + y)
process2 = do send 42 x <- recv send (x + 1)
The session types library can verify at compile time that these two processes cannot talk to each other, since
process1 is expecting to receive two integers but
process2 only sends one before expecting to receive something.
Therefore, I conclude that Haskell is better than Erlang. Please ignore the fact that Haskell is missing the important things about Erlang (fault tolerance, hot swapping, total serialization). :-)
A quick glance at the automatically generated documentation for the session types library will cause you to go blind1. It is this kind of brilliant hackery which makes me really want a good dependently-typed language, since this kind of thing shouldn’t have to be brilliant hackery. It should be standard, everyday stuff.
1Oh, did you already click on it? I’m sorry, but I can deduce that you have since regained it.