Functional programming abstractions for weakly consistent systems