diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-10-17 09:59:20 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-10-17 09:59:20 +0400 |
commit | 5ad4603614704bcca92a89ecf655d6a551f4f8ac (patch) | |
tree | 3e5cd12790e0925ee3f9d643aa0531ad2c78c571 | |
parent | b064c9ebc2aecb2846ca0083a3a516d4cd618b29 (diff) |
Remove containers dependency
-rw-r--r-- | krpc.cabal | 3 | ||||
-rw-r--r-- | src/Network/KRPC.hs | 6 | ||||
-rw-r--r-- | src/Network/KRPC/Scheme.hs | 14 |
3 files changed, 8 insertions, 15 deletions
@@ -40,13 +40,12 @@ library | |||
40 | , Network.KRPC.Protocol | 40 | , Network.KRPC.Protocol |
41 | , Network.KRPC.Scheme | 41 | , Network.KRPC.Scheme |
42 | build-depends: base == 4.* | 42 | build-depends: base == 4.* |
43 | , bytestring >= 0.10 | ||
43 | 44 | ||
44 | , lifted-base >= 0.1.1 | 45 | , lifted-base >= 0.1.1 |
45 | , transformers >= 0.2 | 46 | , transformers >= 0.2 |
46 | , monad-control >= 0.3 | 47 | , monad-control >= 0.3 |
47 | 48 | ||
48 | , bytestring >= 0.10 | ||
49 | , containers >= 0.4 | ||
50 | , bencoding == 0.4.* | 49 | , bencoding == 0.4.* |
51 | 50 | ||
52 | , network >= 2.3 | 51 | , network >= 2.3 |
diff --git a/src/Network/KRPC.hs b/src/Network/KRPC.hs index 27363515..b6e14bb0 100644 --- a/src/Network/KRPC.hs +++ b/src/Network/KRPC.hs | |||
@@ -125,7 +125,6 @@ import Data.BEncode.BDict as BE | |||
125 | import Data.BEncode.Types as BE | 125 | import Data.BEncode.Types as BE |
126 | import Data.ByteString.Char8 as BC | 126 | import Data.ByteString.Char8 as BC |
127 | import Data.List as L | 127 | import Data.List as L |
128 | import Data.Map as M | ||
129 | import Data.Monoid | 128 | import Data.Monoid |
130 | import Data.Typeable | 129 | import Data.Typeable |
131 | import Network | 130 | import Network |
@@ -359,9 +358,6 @@ server :: (MonadBaseControl IO remote, MonadIO remote) | |||
359 | -> remote () | 358 | -> remote () |
360 | server servAddr handlers = do | 359 | server servAddr handlers = do |
361 | remoteServer servAddr $ \addr q -> do | 360 | remoteServer servAddr $ \addr q -> do |
362 | case dispatch (queryMethod q) of | 361 | case L.lookup (queryMethod q) handlers of |
363 | Nothing -> return $ Left $ MethodUnknown (queryMethod q) | 362 | Nothing -> return $ Left $ MethodUnknown (queryMethod q) |
364 | Just m -> m addr q | 363 | Just m -> m addr q |
365 | where | ||
366 | handlerMap = M.fromList handlers | ||
367 | dispatch s = M.lookup s handlerMap | ||
diff --git a/src/Network/KRPC/Scheme.hs b/src/Network/KRPC/Scheme.hs index 9d8a1876..244f035d 100644 --- a/src/Network/KRPC/Scheme.hs +++ b/src/Network/KRPC/Scheme.hs | |||
@@ -23,7 +23,6 @@ module Network.KRPC.Scheme | |||
23 | import Control.Applicative | 23 | import Control.Applicative |
24 | import Data.BEncode.BDict as BS | 24 | import Data.BEncode.BDict as BS |
25 | import Data.BEncode.Types as BS | 25 | import Data.BEncode.Types as BS |
26 | import Data.Set as S | ||
27 | 26 | ||
28 | import Network.KRPC.Protocol | 27 | import Network.KRPC.Protocol |
29 | import Network.KRPC | 28 | import Network.KRPC |
@@ -51,7 +50,7 @@ instance KMessage KError ErrorCode where | |||
51 | 50 | ||
52 | data KQueryScheme = KQueryScheme { | 51 | data KQueryScheme = KQueryScheme { |
53 | qscMethod :: MethodName | 52 | qscMethod :: MethodName |
54 | , qscParams :: Set ParamName | 53 | , qscParams :: [ParamName] |
55 | } deriving (Show, Read, Eq, Ord) | 54 | } deriving (Show, Read, Eq, Ord) |
56 | 55 | ||
57 | bdictKeys :: BDict -> [BKey] | 56 | bdictKeys :: BDict -> [BKey] |
@@ -61,24 +60,23 @@ bdictKeys Nil = [] | |||
61 | instance KMessage KQuery KQueryScheme where | 60 | instance KMessage KQuery KQueryScheme where |
62 | scheme q = KQueryScheme | 61 | scheme q = KQueryScheme |
63 | { qscMethod = queryMethod q | 62 | { qscMethod = queryMethod q |
64 | , qscParams = S.fromAscList $ bdictKeys $ queryArgs q | 63 | , qscParams = bdictKeys $ queryArgs q |
65 | } | 64 | } |
66 | {-# INLINE scheme #-} | 65 | {-# INLINE scheme #-} |
67 | 66 | ||
68 | methodQueryScheme :: Method a b -> KQueryScheme | 67 | methodQueryScheme :: Method a b -> KQueryScheme |
69 | methodQueryScheme = KQueryScheme <$> methodName | 68 | methodQueryScheme = KQueryScheme <$> methodName <*> methodParams |
70 | <*> S.fromList . methodParams | ||
71 | {-# INLINE methodQueryScheme #-} | 69 | {-# INLINE methodQueryScheme #-} |
72 | 70 | ||
73 | newtype KResponseScheme = KResponseScheme | 71 | newtype KResponseScheme = KResponseScheme |
74 | { rscVals :: Set ValName | 72 | { rscVals :: [ValName] |
75 | } deriving (Show, Read, Eq, Ord) | 73 | } deriving (Show, Read, Eq, Ord) |
76 | 74 | ||
77 | instance KMessage KResponse KResponseScheme where | 75 | instance KMessage KResponse KResponseScheme where |
78 | {-# SPECIALIZE instance KMessage KResponse KResponseScheme #-} | 76 | {-# SPECIALIZE instance KMessage KResponse KResponseScheme #-} |
79 | scheme = KResponseScheme . S.fromAscList . bdictKeys . respVals | 77 | scheme = KResponseScheme . bdictKeys . respVals |
80 | {-# INLINE scheme #-} | 78 | {-# INLINE scheme #-} |
81 | 79 | ||
82 | methodRespScheme :: Method a b -> KResponseScheme | 80 | methodRespScheme :: Method a b -> KResponseScheme |
83 | methodRespScheme = KResponseScheme . S.fromList . methodVals | 81 | methodRespScheme = KResponseScheme . methodVals |
84 | {-# INLINE methodRespScheme #-} | 82 | {-# INLINE methodRespScheme #-} |