{-# LANGUAGE CPP #-}
module Data.ObjectName (
ObjectName(..), GeneratableObjectName(..)
) where
import Control.Monad ( replicateM )
import Control.Monad.IO.Class ( MonadIO(..) )
#if __GLASGOW_HASKELL__ < 708
#endif
class ObjectName a where
#if __GLASGOW_HASKELL__ >= 708
{-# MINIMAL isObjectName, ( deleteObjectName | deleteObjectNames ) #-}
#endif
isObjectName :: MonadIO m => a -> m Bool
deleteObjectName :: MonadIO m => a -> m ()
deleteObjectName = [a] -> m ()
forall a (m :: * -> *). (ObjectName a, MonadIO m) => [a] -> m ()
deleteObjectNames ([a] -> m ()) -> (a -> [a]) -> a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> [a] -> [a]
forall a. a -> [a] -> [a]
:[])
deleteObjectNames:: MonadIO m => [a] -> m ()
deleteObjectNames = (a -> m ()) -> [a] -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ a -> m ()
forall a (m :: * -> *). (ObjectName a, MonadIO m) => a -> m ()
deleteObjectName
#if __GLASGOW_HASKELL__ < 708
#endif
class ObjectName a => GeneratableObjectName a where
#if __GLASGOW_HASKELL__ >= 708
{-# MINIMAL genObjectName | genObjectNames #-}
#endif
genObjectName :: MonadIO m => m a
genObjectName = IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> (Int -> IO a) -> Int -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a] -> a) -> IO [a] -> IO a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> a
forall a. [a] -> a
head (IO [a] -> IO a) -> (Int -> IO [a]) -> Int -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO [a]
forall a (m :: * -> *).
(GeneratableObjectName a, MonadIO m) =>
Int -> m [a]
genObjectNames (Int -> m a) -> Int -> m a
forall a b. (a -> b) -> a -> b
$ Int
1
genObjectNames :: MonadIO m => Int -> m [a]
genObjectNames = (Int -> m a -> m [a]) -> m a -> Int -> m [a]
forall a b c. (a -> b -> c) -> b -> a -> c
flip Int -> m a -> m [a]
forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM m a
forall a (m :: * -> *). (GeneratableObjectName a, MonadIO m) => m a
genObjectName