You want something like
newtype CWIO a = CWIO { unCWIO :: CWorld -> (a, CWorld) }
which will allow you to define the appropriate instances and to use CWIO
and unCWIO
to move back and forth between wrapped CWIO
computations and the unwrapped underlying functions. newtype
is a variant of data
tailored and optimised for wrappers with a single constructor.
Note that by adopting such a definition for CWIO
you will end up with something equivalent to the State
monad specialised for a CWorld
state.