-- Start
--- Helper Function, takes Hostname, Port, Playername, Password from the command line
-parttyMain :: DayCallback d -> NightCallback d -> d -> IO ()
+-- | The 'parttyMain' is a small wrapper around 'runPartty' which reads the
+-- hostname, the port, the username and the password from the command line.
+-- The other arguments are the same as for 'runPartty'.
+
+parttyMain :: DayCallback d
+ -> NightCallback d
+ -> d
+ -> IO ()
parttyMain dcb ncb d = do
[host,port_s,username,password] <- getArgs
runPartty host (read port_s) username password dcb ncb d
--- Hostname, Port, Playername, Password, Callback
-runPartty :: String -> Int -> String -> String -> DayCallback d -> NightCallback d -> d -> IO ()
+-- | The 'runPartty' function is the main entry point in Partty. It tries to connect to the
+-- server, logs in, and begins to call the callbacks ('DayCallback' and 'NightCallback') with
+-- the appropriate messages.
+
+runPartty :: String -- ^ Hostname
+ -> Int -- ^ Port
+ -> String -- ^ Username
+ -> String -- ^ Password
+ -> DayCallback d -- ^ The callback for day events
+ -> NightCallback d -- ^ The callback for the night result
+ -> d -- ^ The initial user state to be kept
+ -> IO ()
runPartty host port username password dcb ncb d = do
h <- connectTo host (PortNumber (fromIntegral port))
hSetBuffering h LineBuffering