Having IOSim be an instance of PrimMonad (and thus MonadPrim) opens up access to (almost) all of the functionality from the primitive package: including arrays, prim arrays, byte arrays, poiters etc.
The only thing from the primitive package that definately will not work is Data.Primitive.MVar, i.e. real MVars.
And then also use this to make MonadST a lot simpler. By using the PrimState type family we can express the type of stToIO properly:
Having IOSim be an instance of PrimMonad (and thus MonadPrim) opens up access to (almost) all of the functionality from the primitive package: including arrays, prim arrays, byte arrays, poiters etc.
The only thing from the primitive package that definately will not work is Data.Primitive.MVar, i.e. real MVars.
And then also use this to make MonadST a lot simpler. By using the PrimState type family we can express the type of stToIO properly:
whereas using withLiftST was very tricky.