From 8ab94c6422bb39ce212d73d41056239549bd71e1 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 7 Jun 2024 12:52:08 -0400 Subject: [PATCH] Use newtype instead of type --- library/Faktory/Pool.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/Faktory/Pool.hs b/library/Faktory/Pool.hs index 803e2b3..a88f82e 100644 --- a/library/Faktory/Pool.hs +++ b/library/Faktory/Pool.hs @@ -37,7 +37,7 @@ import UnliftIO (MonadUnliftIO, withRunInIO) -- | -- -- @since 1.1.3.0 -type FaktoryPool = Pool Producer +newtype FaktoryPool = FaktoryPool (Pool Producer) -- | -- @@ -60,6 +60,7 @@ newFaktoryPool -> m FaktoryPool newFaktoryPool settings PoolSettings {..} = do liftIO + . fmap FaktoryPool . Pool.newPool $ Pool.defaultPoolConfig (newProducer settings) @@ -104,7 +105,7 @@ withProducer => (Producer -> m a) -> m a withProducer f = do - p <- asks (^. faktoryPoolL) + FaktoryPool p <- asks (^. faktoryPoolL) withRunInIO $ \runInIO -> do Pool.withResource p $ runInIO . f @@ -121,6 +122,6 @@ withProducer f = do takeProducer :: (MonadIO m, MonadReader env m, HasFaktoryPool env) => m (Producer, m ()) takeProducer = do - p <- asks (^. faktoryPoolL) + FaktoryPool p <- asks (^. faktoryPoolL) (producer, lp) <- liftIO $ Pool.takeResource p pure (producer, liftIO $ Pool.putResource lp producer)