From c8cb893aabfefa2274e789abbe05b312140b5523 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Thu, 2 Jan 2014 17:57:55 +0400 Subject: Add non operator version of (<@>) --- src/Network/BitTorrent/DHT/Session.hs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/Network') diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs index a76880d7..a6c56d70 100644 --- a/src/Network/BitTorrent/DHT/Session.hs +++ b/src/Network/BitTorrent/DHT/Session.hs @@ -33,7 +33,11 @@ module Network.BitTorrent.DHT.Session , getPeerList -- * Messaging + -- ** Initiate + , queryNode , (<@>) + + -- ** Accept , NodeHandler , nodeHandler ) where @@ -90,7 +94,7 @@ data Options = Options , optK :: {-# UNPACK #-} !K -- | RPC timeout. - , optTimeout :: {-# UNPACK #-} !NominalDiffTime + , optTimeout :: !NominalDiffTime -- , optReannounceInterval :: NominalDiffTime -- , optDataExpiredTimeout :: NominalDiffTime @@ -312,9 +316,9 @@ getPeerList ih = do -----------------------------------------------------------------------} -- | Throws exception if node is not responding. -(<@>) :: forall a b ip. Address ip => KRPC (Query a) (Response b) - => a -> NodeAddr ip -> DHT ip b -q <@> addr = do +queryNode :: forall a b ip. Address ip => KRPC (Query a) (Response b) + => NodeAddr ip -> a -> DHT ip b +queryNode addr q = do nid <- getNodeId let Method name = method :: Method (Query a) (Response b) @@ -334,6 +338,12 @@ q <@> addr = do insertNode (NodeInfo remoteId addr) return r +-- | Infix version of 'queryNode' function. +(<@>) :: Address ip => KRPC (Query a) (Response b) + => a -> NodeAddr ip -> DHT ip b +(<@>) = flip queryNode +{-# INLINE (<@>) #-} + type NodeHandler ip = Handler (DHT ip) nodeHandler :: Address ip => KRPC (Query a) (Response b) -- cgit v1.2.3