implement promise.fold
add tests and documentation