The monad and API definitions.