diff options
author | Paul Oliver <contact@pauloliver.dev> | 2025-01-16 19:22:18 -0800 |
---|---|---|
committer | Paul Oliver <contact@pauloliver.dev> | 2025-01-17 19:16:43 -0800 |
commit | e3ea039428545e185b38c5633fe3576ab32f1f8e (patch) | |
tree | 56ab8d1248b4387ceab6094305e7a75699c4e393 /hsm-core/Hsm/Core/Zmq.hs | |
parent | e1fa79eb713c249055fb23fcc6684a94f77d8368 (diff) |
Cleans excessive type annotations
Diffstat (limited to 'hsm-core/Hsm/Core/Zmq.hs')
-rw-r--r-- | hsm-core/Hsm/Core/Zmq.hs | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/hsm-core/Hsm/Core/Zmq.hs b/hsm-core/Hsm/Core/Zmq.hs index 8c12133..2f70d48 100644 --- a/hsm-core/Hsm/Core/Zmq.hs +++ b/hsm-core/Hsm/Core/Zmq.hs @@ -4,7 +4,6 @@ module Hsm.Core.Zmq ( withSocket ) where -import Data.Text (Text) import Effectful (Eff, IOE, (:>)) import Effectful.Log (Log, LogLevel(LogTrace)) import Effectful.Resource (Resource, allocate) @@ -12,23 +11,19 @@ import Hsm.Core.Log (withLogIO) import System.ZMQ4 qualified as Z withSocket :: - forall t es. (Z.SocketType t, IOE :> es, Log :> es, Resource :> es) + (Z.SocketType t, IOE :> es, Log :> es, Resource :> es) => t -> Eff es (Z.Socket t) withSocket stype = withLogIO >>= bracket where - bracket :: (LogLevel -> Text -> IO ()) -> Eff es (Z.Socket t) bracket logIO = snd . snd <$> allocate acquire release where - acquire :: IO (Z.Context, Z.Socket t) - acquire = do - logIO LogTrace "Acquiring ZMQ context" - cont <- Z.context - sock <- Z.socket cont stype - return (cont, sock) - -- - release :: (Z.Context, Z.Socket t) -> IO () - release (cont, sock) = do - logIO LogTrace "Releasing ZMQ context" - Z.close sock - Z.shutdown cont + acquire = + logIO LogTrace "Acquiring ZMQ context" >> do + cont <- Z.context + sock <- Z.socket cont stype + return (cont, sock) + release (cont, sock) = + logIO LogTrace "Releasing ZMQ context" >> do + Z.close sock + Z.shutdown cont |