2019-11-20 21:21:30 +03:00
|
|
|
-- | A tiny mtl-style wrapper around 'U.newUnique'.
|
|
|
|
module Control.Monad.Unique
|
2021-09-24 01:56:37 +03:00
|
|
|
( U.Unique,
|
|
|
|
MonadUnique (..),
|
|
|
|
)
|
|
|
|
where
|
2019-11-20 21:21:30 +03:00
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
import Data.Unique qualified as U
|
|
|
|
import Hasura.Prelude
|
2019-11-20 21:21:30 +03:00
|
|
|
|
|
|
|
class (Monad m) => MonadUnique m where
|
|
|
|
newUnique :: m U.Unique
|
|
|
|
|
|
|
|
instance MonadUnique IO where
|
|
|
|
newUnique = U.newUnique
|
|
|
|
|
|
|
|
instance (MonadUnique m) => MonadUnique (ExceptT e m) where
|
|
|
|
newUnique = lift newUnique
|
2021-09-24 01:56:37 +03:00
|
|
|
|
2019-11-20 21:21:30 +03:00
|
|
|
instance (MonadUnique m) => MonadUnique (ReaderT r m) where
|
|
|
|
newUnique = lift newUnique
|
2021-09-24 01:56:37 +03:00
|
|
|
|
2019-11-20 21:21:30 +03:00
|
|
|
instance (MonadUnique m) => MonadUnique (StateT s m) where
|
|
|
|
newUnique = lift newUnique
|
2021-09-24 01:56:37 +03:00
|
|
|
|
2019-11-20 21:21:30 +03:00
|
|
|
instance (Monoid w, MonadUnique m) => MonadUnique (WriterT w m) where
|
|
|
|
newUnique = lift newUnique
|