Define onPtr for machine monads