summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Remote/KRPC.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Remote/KRPC.hs b/src/Remote/KRPC.hs
index e1ad0853..1b4ae4b6 100644
--- a/src/Remote/KRPC.hs
+++ b/src/Remote/KRPC.hs
@@ -175,7 +175,9 @@ extractArgs :: BEncodable arg
175 => [ParamName] -> Map ParamName BEncode -> Result arg 175 => [ParamName] -> Map ParamName BEncode -> Result arg
176extractArgs as d = fromBEncode =<< 176extractArgs as d = fromBEncode =<<
177 case as of 177 case as of
178 [] -> Right (BList []) 178 [] -> if M.null d
179 then Right (BList [])
180 else Right (BDict d)
179 [x] -> f x 181 [x] -> f x
180 xs -> BList <$> mapM f xs 182 xs -> BList <$> mapM f xs
181 where 183 where
@@ -184,12 +186,22 @@ extractArgs as d = fromBEncode =<<
184{-# INLINE extractArgs #-} 186{-# INLINE extractArgs #-}
185 187
186injectVals :: BEncodable arg => [ParamName] -> arg -> [(ParamName, BEncode)] 188injectVals :: BEncodable arg => [ParamName] -> arg -> [(ParamName, BEncode)]
187injectVals [] (toBEncode -> BList []) = [] 189injectVals [] (toBEncode -> be)
190 = case be of
191 BList [] -> []
192 BDict d -> M.toList d
193 _ -> invalidParamList [] be
194
188injectVals [p] (toBEncode -> arg) = [(p, arg)] 195injectVals [p] (toBEncode -> arg) = [(p, arg)]
189injectVals ps (toBEncode -> BList as) = L.zip ps as 196injectVals ps (toBEncode -> BList as) = L.zip ps as
190injectVals _ _ = error "KRPC.injectVals: impossible" 197injectVals pl a = invalidParamList pl (toBEncode a)
191{-# INLINE injectVals #-} 198{-# INLINE injectVals #-}
192 199
200invalidParamList :: [ParamName] -> BEncode -> a
201invalidParamList pl be
202 = error $ "KRPC invalid parameter list: " ++ show pl ++ "\n" ++
203 "while procedure args are: " ++ show be
204
193-- | Alias to Socket, through might change in future. 205-- | Alias to Socket, through might change in future.
194type Remote = Socket 206type Remote = Socket
195 207