{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} module Control.Monad.Resumable.Scoped where import Unsafe.Coerce -- safe since we're only changing phantom types data Static data Dynamic statically :: Scoped Static m => (ScopedAs Static m a -> ScopedAs Static m b) -> m a -> m b dynamically :: Scoped Dynamic m => (ScopedAs Dynamic m a -> ScopedAs Dynamic m b) -> m a -> m b class Scoped scope m where type ScopedAs scope m :: * -> * scoped :: scope -> (ScopedAs scope m a -> ScopedAs scope m b) -> m a -> m b scoped _ f = unsafeCoerce . f . unsafeCoerce