Skip to content

Instantly share code, notes, and snippets.

@kindaro
Created May 11, 2024 07:47
Show Gist options
  • Save kindaro/0955e1e5c101cb1341e4e45d6f43838d to your computer and use it in GitHub Desktop.
Save kindaro/0955e1e5c101cb1341e4e45d6f43838d to your computer and use it in GitHub Desktop.
diff --git a/krpc.cabal b/krpc.cabal
index c565bd2..85d03e5 100644
--- a/krpc.cabal
+++ b/krpc.cabal
@@ -53,7 +53,7 @@ library
, monad-control >= 0.3
, monad-logger >= 0.3
, bencoding >= 0.4.3
- , network >= 2.3
+ , network >= 2.3 && <= 3.0
, containers
if impl(ghc < 7.6)
build-depends: ghc-prim
@@ -89,4 +89,4 @@ benchmark bench
, monad-logger
, criterion
, krpc
- ghc-options: -O2 -fforce-recomp
\ No newline at end of file
+ ghc-options: -O2 -fforce-recomp
diff --git a/src/Network/KRPC/Manager.hs b/src/Network/KRPC/Manager.hs
index 4436a9b..35f068a 100644
--- a/src/Network/KRPC/Manager.hs
+++ b/src/Network/KRPC/Manager.hs
@@ -16,6 +16,8 @@
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TemplateHaskell #-}
+{-# LANGUAGE KindSignatures #-}
+
module Network.KRPC.Manager
( -- * Manager
MonadKRPC (..)
@@ -151,7 +153,7 @@ class (MonadBaseControl IO m, MonadLogger m, MonadIO m)
-- | Can be used to add logging for instance.
liftHandler :: h a -> m a
- default liftHandler :: m a -> m a
+ default liftHandler :: forall a. (MonadKRPC h m, h ~ m) => h a -> m a
liftHandler = id
instance (MonadBaseControl IO h, MonadLogger h, MonadIO h)
@@ -170,7 +172,7 @@ newManager :: Options -- ^ various protocol options;
-> SockAddr -- ^ address to listen on;
-> [Handler h] -- ^ handlers to run on incoming queries.
-> IO (Manager h) -- ^ new rpc manager.
-newManager opts @ Options {..} servAddr handlers = do
+newManager opts@Options {..} servAddr handlers = do
validateOptions opts
sock <- bindServ
tref <- newEmptyMVar
@@ -396,7 +398,7 @@ runHandler h addr KQuery {..} = Lifted.catches wrapper failbacks
]
dispatchHandler :: MonadKRPC h m => KQuery -> SockAddr -> m KResult
-dispatchHandler q @ KQuery {..} addr = do
+dispatchHandler q@KQuery {..} addr = do
Manager {..} <- getManager
case L.lookup queryMethod handlers of
Nothing -> return $ Left $ KError MethodUnknown queryMethod queryId
diff --git a/src/Network/KRPC/Method.hs b/src/Network/KRPC/Method.hs
index ea9da95..85496f0 100644
--- a/src/Network/KRPC/Method.hs
+++ b/src/Network/KRPC/Method.hs
@@ -47,7 +47,7 @@ newtype Method param result = Method { methodName :: MethodName }
instance (Typeable a, Typeable b) => Show (Method a b) where
showsPrec _ = showsMethod
-showsMethod :: forall a. forall b. Typeable a => Typeable b
+showsMethod :: forall a b. (Typeable a, Typeable b)
=> Method a b -> ShowS
showsMethod (Method name) =
showString (BC.unpack name) <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment