summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-10-17 09:59:20 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-10-17 09:59:20 +0400
commit5ad4603614704bcca92a89ecf655d6a551f4f8ac (patch)
tree3e5cd12790e0925ee3f9d643aa0531ad2c78c571 /src/Network
parentb064c9ebc2aecb2846ca0083a3a516d4cd618b29 (diff)
Remove containers dependency
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/KRPC.hs6
-rw-r--r--src/Network/KRPC/Scheme.hs14
2 files changed, 7 insertions, 13 deletions
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
125import Data.BEncode.Types as BE 125import Data.BEncode.Types as BE
126import Data.ByteString.Char8 as BC 126import Data.ByteString.Char8 as BC
127import Data.List as L 127import Data.List as L
128import Data.Map as M
129import Data.Monoid 128import Data.Monoid
130import Data.Typeable 129import Data.Typeable
131import Network 130import Network
@@ -359,9 +358,6 @@ server :: (MonadBaseControl IO remote, MonadIO remote)
359 -> remote () 358 -> remote ()
360server servAddr handlers = do 359server 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
23import Control.Applicative 23import Control.Applicative
24import Data.BEncode.BDict as BS 24import Data.BEncode.BDict as BS
25import Data.BEncode.Types as BS 25import Data.BEncode.Types as BS
26import Data.Set as S
27 26
28import Network.KRPC.Protocol 27import Network.KRPC.Protocol
29import Network.KRPC 28import Network.KRPC
@@ -51,7 +50,7 @@ instance KMessage KError ErrorCode where
51 50
52data KQueryScheme = KQueryScheme { 51data 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
57bdictKeys :: BDict -> [BKey] 56bdictKeys :: BDict -> [BKey]
@@ -61,24 +60,23 @@ bdictKeys Nil = []
61instance KMessage KQuery KQueryScheme where 60instance 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
68methodQueryScheme :: Method a b -> KQueryScheme 67methodQueryScheme :: Method a b -> KQueryScheme
69methodQueryScheme = KQueryScheme <$> methodName 68methodQueryScheme = KQueryScheme <$> methodName <*> methodParams
70 <*> S.fromList . methodParams
71{-# INLINE methodQueryScheme #-} 69{-# INLINE methodQueryScheme #-}
72 70
73newtype KResponseScheme = KResponseScheme 71newtype KResponseScheme = KResponseScheme
74 { rscVals :: Set ValName 72 { rscVals :: [ValName]
75 } deriving (Show, Read, Eq, Ord) 73 } deriving (Show, Read, Eq, Ord)
76 74
77instance KMessage KResponse KResponseScheme where 75instance 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
82methodRespScheme :: Method a b -> KResponseScheme 80methodRespScheme :: Method a b -> KResponseScheme
83methodRespScheme = KResponseScheme . S.fromList . methodVals 81methodRespScheme = KResponseScheme . methodVals
84{-# INLINE methodRespScheme #-} 82{-# INLINE methodRespScheme #-}