Writing distributed map-reduce queries in Erlang