Yes, congratulations, you have just invented Bluefin! (well, modulo :&, which is needed for having resources with different lifetimes).
@Leary’s caveats are essential, and @Leary first pointed out to me here the necessity of keeping the type index on the monad too:
type role IOS nominal representational: the need for this is unfortunate. Type roles default to the least safe possibility!MonadUnliftIO: even weaker functions can break the scoping too: MonadUnliftIO instance allows escape · Issue #29 · tomjaguarpaw/bluefin · GitHub. I don’t have anything optimistic to say about this except that if you use them you to have to be careful.