Skip to content

Commit

Permalink
Remove trivial build warnings
Browse files Browse the repository at this point in the history
Redundant imports, unused variables etc.
  • Loading branch information
kfish authored and jepst committed Sep 25, 2011
1 parent 9ae60f8 commit 290adea
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 111 deletions.
2 changes: 1 addition & 1 deletion Remote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Remote ( -- * The process layer
expect, receive, receiveWait, receiveTimeout,
match, matchIf, matchUnknown, matchUnknownThrow, matchProcessDown,

logS, say, LogSphere(..), LogTarget(..), LogFilter(..), LogConfig(..), LogLevel(..),
logS, say, LogSphere, LogTarget(..), LogFilter(..), LogConfig(..), LogLevel(..),
setLogConfig, setNodeLogConfig, getLogConfig, defaultLogConfig, getCfgArgs,

UnknownMessageException(..), ServiceException(..),
Expand Down
13 changes: 9 additions & 4 deletions Remote/Call.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Control.Monad.Trans (liftIO)
import Control.Monad (liftM)
import Remote.Closure (Closure(..))
import Remote.Process (ProcessM)
import Remote.Reg (Lookup,putReg,RemoteCallMetaData)
import Remote.Reg (putReg,RemoteCallMetaData)
import Remote.Task (remoteCallRectify,TaskM)

-- TODO this module is the result of months of tiny thoughtless changes and desperately needs a clean-up
Expand Down Expand Up @@ -124,7 +124,7 @@ remotable names =
let outnames = concat $ map snd declGen
regs <- sequence $ makeReg loc outnames
return $ decs ++ regs
where makeReg loc names =
where makeReg loc names' =
let
mkentry = [e| putReg |]
regtype = [t| RemoteCallMetaData |]
Expand All @@ -135,7 +135,7 @@ remotable names =
applies [] = varE param
applies [h] = appE (app2E mkentry (varE h) (litE $ stringL (reasonableNameModule h++nameBase h))) (varE param)
applies (h:t) = appE (app2E mkentry (varE h) (litE $ stringL (reasonableNameModule h++nameBase h))) (applies t)
bodyq = normalB (applies names)
bodyq = normalB (applies names')
sig = sigD registryName regtype
dec = funD registryName [clause [varP param] bodyq []]
in [sig,dec]
Expand Down Expand Up @@ -170,6 +170,7 @@ remotable names =
isarrow _ = False
applyargs f [] = f
applyargs f (l:r) = applyargs (appE f l) r
funtype :: Integer
funtype = case last arglist of
(AppT (process) _) | process == ttprocessm -> 0
| process == ttio -> 1
Expand Down Expand Up @@ -207,7 +208,7 @@ remotable names =
[]]
implPls = if isarrowful then [implPldec,implPldef] else []
implPldec = case last arglist of
(AppT ( process) v) | process == tttaskm ->
(AppT ( process) _v) | process == tttaskm ->
sigD implPlName (return $ putParams $ [payload,(AppT process payload)])
_ -> sigD implPlName (return $ putParams implarglist)
implPldef = case last arglist of
Expand All @@ -222,16 +223,20 @@ remotable names =
in ([closuredec,closuredef,impldec,impldef]++if not isarrowful then [implPldec,implPldef] else [],
[aname,implName]++if not isarrowful then [implPlName] else [])

getType :: Name -> Q [(Name, Type)]
getType name =
do info <- reify name
case info of
VarI iname itype _ _ -> return [(iname,itype)]
_ -> return []

putParams :: [Type] -> Type
putParams (afst:lst:[]) = AppT (AppT ArrowT afst) lst
putParams (afst:[]) = afst
putParams (afst:lst) = AppT (AppT ArrowT afst) (putParams lst)
putParams [] = error "Unexpected parameter type in remotable processing"

getParams :: Type -> [Type]
getParams typ = case typ of
AppT (AppT ArrowT b) c -> b : getParams c
b -> [b]
Expand Down
2 changes: 1 addition & 1 deletion Remote/Channel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Remote.Channel (
terminateChannel) where

import Remote.Process (ProcessM,send,getMessageType,getMessagePayload,setDaemonic,getProcess,prNodeRef,getNewMessageLocal,localFromPid,isPidLocal,TransmitException(..),TransmitStatus(..),spawnLocalAnd,ProcessId,Node,UnknownMessageException(..))
import Remote.Encoding (getPayloadType,serialDecodePure,Serializable)
import Remote.Encoding (Serializable)

import Data.List (foldl')
import Data.Binary (Binary,get,put)
Expand Down
2 changes: 1 addition & 1 deletion Remote/Closure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data Closure a = Closure String Payload

instance Show (Closure a) where
show a = case a of
(Closure fn pl) -> show fn
(Closure fn _pl) -> show fn

instance Binary (Closure a) where
get = do s <- get
Expand Down
9 changes: 6 additions & 3 deletions Remote/Encoding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ module Remote.Encoding (
genericPut,
genericGet) where

import Prelude hiding (id)
import qualified Prelude as Prelude

import Data.Binary (Binary,encode,decode,Put,Get,put,get,putWord8,getWord8)
import Control.Monad (liftM)
import Data.ByteString.Lazy (ByteString)
Expand Down Expand Up @@ -115,7 +118,7 @@ serialDecodePure a = (\id ->
if (decode $! payloadType a) ==
show (typeOf $ id undefined)
then Just (id $! decode pc)
else Nothing ) id
else Nothing ) Prelude.id


serialDecode :: (Serializable a) => Payload -> IO (Maybe a)
Expand All @@ -128,7 +131,7 @@ serialDecode a = (\id ->
case res of
Left _ -> return $ Nothing
Right v -> return $ Just $ id v
else return Nothing ) id
else return Nothing ) Prelude.id


-- | Data types that can be used in messaging must
Expand Down Expand Up @@ -164,7 +167,7 @@ genericGet = generic `extR` genericString
g' <- genericGet
return $ n' g')
(return)
(repConstr (dataTypeOf (id undefined)) constr_rep)) id
(repConstr (dataTypeOf (id undefined)) constr_rep)) Prelude.id
genericString :: Get String
genericString = do q <- get
return $ decode q
Expand Down
10 changes: 6 additions & 4 deletions Remote/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
-- line arguments, and commonly-used system processes.
module Remote.Init (remoteInit) where

import qualified Prelude as Prelude
import Prelude hiding (lookup)

import Remote.Peer (startDiscoveryService)
import Remote.Task (__remoteCallMetaData)
import Remote.Process (startProcessRegistryService,suppressTransmitException,pbracket,localRegistryRegisterNode,localRegistryHello,localRegistryUnregisterNode,
import Remote.Process (startProcessRegistryService,suppressTransmitException,localRegistryRegisterNode,localRegistryHello,localRegistryUnregisterNode,
startProcessMonitorService,startNodeMonitorService,startLoggingService,startSpawnerService,ProcessM,readConfig,initNode,startLocalRegistry,
forkAndListenAndDeliver,waitForThreads,roleDispatch,Node,runLocalProcess,performFinalization,startFinalizerService)
import Remote.Reg (registerCalls,RemoteCallMetaData)

import System.FilePath (FilePath)
import System.Environment (getEnvironment)
import Control.Concurrent (threadDelay)
import Control.Monad.Trans (liftIO)
Expand All @@ -30,7 +32,7 @@ startServices =

dispatchServices :: MVar Node -> IO ()
dispatchServices node = do mv <- newEmptyMVar
runLocalProcess node (startServices >> liftIO (putMVar mv ()))
_ <- runLocalProcess node (startServices >> liftIO (putMVar mv ()))
takeMVar mv

-- | This is the usual way create a single node of distributed program.
Expand Down Expand Up @@ -65,6 +67,6 @@ remoteInit defaultConfig metadata f =
(roleDispatch node userFunction >> waitForThreads node) `finally` (performFinalization node)
threadDelay 500000 -- TODO make configurable, or something
where getConfigFileName = do env <- getEnvironment
return $ maybe defaultConfig Just (lookup "RH_CONFIG" env)
return $ maybe defaultConfig Just (Prelude.lookup "RH_CONFIG" env)
userFunction s = localRegistryHello >> localRegistryRegisterNode >> f s

12 changes: 7 additions & 5 deletions Remote/Peer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
-- which does it automatically.
module Remote.Peer (PeerInfo,startDiscoveryService,getPeers,getPeersStatic,getPeersDynamic,findPeerByRole) where

import Prelude hiding (all, pi)

import Network.Socket (defaultHints,sendTo,recv,sClose,Socket,getAddrInfo,AddrInfoFlag(..),setSocketOption,addrFlags,addrSocketType,addrFamily,SocketType(..),Family(..),addrProtocol,SocketOption(..),AddrInfo,bindSocket,addrAddress,SockAddr(..),socket)
import Network.BSD (getProtocolNumber)
import Control.Concurrent.MVar (takeMVar, newMVar, modifyMVar_)
import Remote.Process (PeerInfo,pingNode,makeNodeFromHost,spawnLocalAnd,setDaemonic,TransmitStatus(..),TransmitException(..),PayloadDisposition(..),ptimeout,getSelfNode,sendSimple,cfgRole,cfgKnownHosts,cfgPeerDiscoveryPort,match,receiveWait,getSelfPid,getConfig,NodeId(..),PortId,ProcessM,ptry,localRegistryQueryNodes)
import Remote.Process (PeerInfo,pingNode,makeNodeFromHost,spawnLocalAnd,setDaemonic,TransmitStatus(..),TransmitException(..),PayloadDisposition(..),ptimeout,getSelfNode,sendSimple,cfgRole,cfgKnownHosts,cfgPeerDiscoveryPort,match,receiveWait,getSelfPid,getConfig,NodeId,PortId,ProcessM,ptry,localRegistryQueryNodes)
import Control.Monad.Trans (liftIO)
import Data.Typeable (Typeable)
import Data.Maybe (catMaybes)
Expand All @@ -18,7 +20,7 @@ import Control.Exception (try,bracket,ErrorCall(..),throw)
import Data.List (nub)
import Control.Monad (filterM)
import qualified Data.Traversable as Traversable (mapM)
import qualified Data.Map as Map (keys,Map,unionsWith,insertWith,empty,lookup)
import qualified Data.Map as Map (unionsWith,insertWith,empty,lookup)

data DiscoveryInfo = DiscoveryInfo
{
Expand Down Expand Up @@ -65,7 +67,7 @@ sendBroadcast port str
(sClose)
(\sock -> do
setSocketOption sock Broadcast 1
res <- sendTo sock str (SockAddrInet (toEnum port) (-1))
_res <- sendTo sock str (SockAddrInet (toEnum port) (-1))
return ()
)

Expand All @@ -77,7 +79,7 @@ sendBroadcast port str
getPeers :: ProcessM PeerInfo
getPeers = do a <- getPeersStatic
b <- getPeersDynamic 500000
verifyPeerInfo $ Map.unionsWith (\a b -> nub $ a ++ b) [a,b]
verifyPeerInfo $ Map.unionsWith (\x y -> nub $ x ++ y) [a,b]

verifyPeerInfo :: PeerInfo -> ProcessM PeerInfo
verifyPeerInfo pi = Traversable.mapM verify1 pi
Expand Down Expand Up @@ -112,7 +114,7 @@ getPeersDynamic t =
case (cfgPeerDiscoveryPort cfg) of
0 -> return Map.empty
port -> do -- TODO should send broacast multiple times in case of packet loss
liftIO $ try $ sendBroadcast port (show pid) :: ProcessM (Either IOError ())
_ <- liftIO $ try $ sendBroadcast port (show pid) :: ProcessM (Either IOError ())
responses <- liftIO $ newMVar []
_ <- ptimeout t (receiveInfo responses)
res <- liftIO $ takeMVar responses
Expand Down
Loading

0 comments on commit 290adea

Please sign in to comment.