Define and implement a generic monad behavior.