Skip to content

Commit

Permalink
Use newtype instead of type
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Jun 7, 2024
1 parent 91ac8e1 commit 8ab94c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions library/Faktory/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import UnliftIO (MonadUnliftIO, withRunInIO)
-- |
--
-- @since 1.1.3.0
type FaktoryPool = Pool Producer
newtype FaktoryPool = FaktoryPool (Pool Producer)

-- |
--
Expand All @@ -60,6 +60,7 @@ newFaktoryPool
-> m FaktoryPool
newFaktoryPool settings PoolSettings {..} = do
liftIO
. fmap FaktoryPool
. Pool.newPool
$ Pool.defaultPoolConfig
(newProducer settings)
Expand Down Expand Up @@ -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

Expand All @@ -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)

0 comments on commit 8ab94c6

Please sign in to comment.