A monad for type casting