Trying to implement Monads in Java