added more parsing of commands
[cloogle-irc.git] / IRC.dcl
diff --git a/IRC.dcl b/IRC.dcl
index 0db138c..3c5a3d1 100644 (file)
--- a/IRC.dcl
+++ b/IRC.dcl
@@ -1,12 +1,27 @@
 definition module IRC
 
 from Data.Maybe import :: Maybe
-from StdOverloaded import class fromInt, class toInt, class toString
+from Data.Either import :: Either
+from StdOverloaded import class fromInt, class toInt, class toString, class fromString
 
-:: IRCCommands
+:: IRCMessage =
+       { irc_prefix :: Maybe (Either String IRCUser)
+       , irc_command :: IRCCommand}
+
+:: IRCUser = 
+       { irc_nick :: String
+       , irc_user :: Maybe String
+       , irc_host :: Maybe String
+       }
+
+instance toString IRCCommand, IRCReplies, IRCErrors, IRCMessage, IRCUser
+instance fromInt IRCReplies, IRCErrors
+instance toInt IRCReplies, IRCErrors
+
+:: IRCCommand
        = ADMIN (Maybe String)
        | AWAY String
-       | CONNECT String Int (Maybe String)
+       | CONNECT String (Maybe (Int, Maybe String))
        | DIE 
        | ERROR String
        | INFO (Maybe String)
@@ -27,8 +42,8 @@ from StdOverloaded import class fromInt, class toInt, class toString
        | OPER String String 
        | PART [String]
        | PASS String
-       | PING [String]
-       | PONG [String]
+       | PING String (Maybe String)
+       | PONG String (Maybe String)
        | PRIVMSG String String
        | QUIT (Maybe String)
        | REHASH 
@@ -90,7 +105,3 @@ from StdOverloaded import class fromInt, class toInt, class toString
        ERR_NOPRIVILEGES | ERR_CHANOPRIVSNEEDED | ERR_CANTKILLSERVER |
        ERR_RESTRICTED | ERR_UNIQOPPRIVSNEEDED | ERR_NOOPERHOST |
        ERR_UMODEUNKNOWNFLAG | ERR_USERSDONTMATCH
-
-instance toString IRCCommands, IRCReplies, IRCErrors
-instance fromInt IRCReplies, IRCErrors
-instance toInt IRCReplies, IRCErrors