compiles, but doesn't work, probably strictness?
[cloogle-irc.git] / IRC.dcl
1 definition module IRC
2
3 from Data.Maybe import :: Maybe
4 from Data.Either import :: Either
5 from StdOverloaded import class fromInt, class toInt, class toString, class fromString
6 from Text.Parsers.Simple.Core import :: Error
7
8 :: IRCMessage =
9 { irc_prefix :: Maybe (Either IRCUser String)
10 , irc_command :: Either IRCNumReply IRCCommand}
11
12 :: IRCNumReply =
13 { irc_reply :: IRCReplies
14 , irc_recipient :: String
15 , irc_message :: String
16 }
17
18 :: IRCUser =
19 { irc_nick :: String
20 , irc_user :: Maybe String
21 , irc_host :: Maybe String
22 }
23
24 parseIRCMessage :: String -> Either [Error] IRCMessage
25
26 instance toString IRCCommand, IRCReplies, IRCErrors, IRCMessage, IRCUser, IRCNumReply
27 instance fromInt IRCReplies, IRCErrors
28 instance toInt IRCReplies, IRCErrors
29
30 :: CSepList = CSepList [String]
31 :: IRCCommand
32 = ADMIN (Maybe String)
33 | AWAY String
34 | CONNECT String (Maybe (Int, Maybe String))
35 | DIE
36 | ERROR String
37 | INFO (Maybe String)
38 | INVITE String String
39 | ISON [String]
40 | JOIN CSepList (Maybe String)
41 | KICK String String (Maybe String)
42 | KILL String String
43 | LINKS (Maybe (Maybe String, String))
44 | LIST (Maybe (CSepList, Maybe String))
45 | LUSERS (Maybe (String, Maybe String))
46 | MODE String String (Maybe String) (Maybe String) (Maybe String)
47 | MOTD (Maybe String)
48 | NAMES CSepList
49 | NICK String (Maybe String)
50 | NJOIN
51 | NOTICE String String
52 | OPER String String
53 | PART CSepList
54 | PASS String
55 | PING String (Maybe String)
56 | PONG String (Maybe String)
57 | PRIVMSG CSepList String
58 | QUIT (Maybe String)
59 | REHASH
60 | RESTART
61 | SERVER
62 | SERVICE String String String String
63 | SERVLIST (Maybe (String, Maybe String))
64 | SQUERY String String
65 | SQUIRT
66 | SQUIT String String
67 | STATS (Maybe (String, Maybe String))
68 | SUMMON String (Maybe (String, Maybe String))
69 | TIME (Maybe String)
70 | TOPIC String (Maybe String)
71 | TRACE (Maybe String)
72 | USER String String String String
73 | USERHOST CSepList
74 | USERS (Maybe String)
75 | VERSION (Maybe String)
76 | WALLOPS String
77 | WHO (Maybe String)
78 | WHOIS (Maybe String) String
79 | WHOWAS String (Maybe (String, Maybe String))
80
81 :: IRCReplies = RPL_WELCOME | RPL_YOURHOST | RPL_CREATED | RPL_MYINFO |
82 RPL_BOUNCE | RPL_TRACELINK | RPL_TRACECONNECTING | RPL_TRACEHANDSHAKE |
83 RPL_TRACEUNKNOWN | RPL_TRACEOPERATOR | RPL_TRACEUSER | RPL_TRACESERVER |
84 RPL_TRACESERVICE | RPL_TRACENEWTYPE | RPL_TRACECLASS | RPL_TRACERECONNECT |
85 RPL_STATSLINKINFO | RPL_STATSCOMMANDS | RPL_ENDOFSTATS | RPL_UMODEIS |
86 RPL_SERVLIST | RPL_SERVLISTEND | RPL_STATSUPTIME | RPL_STATSOLINE |
87 RPL_LUSERCLIENT | RPL_LUSEROP | RPL_LUSERUNKNOWN | RPL_LUSERCHANNELS |
88 RPL_LUSERME | RPL_ADMINME | RPL_ADMINLOC1 | RPL_ADMINLOC2 | RPL_ADMINEMAIL |
89 RPL_TRACELOG | RPL_TRACEEND | RPL_TRYAGAIN | RPL_AWAY | RPL_USERHOST |
90 RPL_ISON | RPL_UNAWAY | RPL_NOWAWAY | RPL_WHOISUSER | RPL_WHOISSERVER |
91 RPL_WHOISOPERATOR | RPL_WHOWASUSER | RPL_ENDOFWHO | RPL_WHOISIDLE |
92 RPL_ENDOFWHOIS | RPL_WHOISCHANNELS | RPL_LISTSTART | RPL_LIST |
93 RPL_LISTEND | RPL_CHANNELMODEIS | RPL_UNIQOPIS | RPL_NOTOPIC | RPL_TOPIC |
94 RPL_INVITING | RPL_SUMMONING | RPL_INVITELIST | RPL_ENDOFINVITELIST |
95 RPL_EXCEPTLIST | RPL_ENDOFEXCEPTLIST | RPL_VERSION | RPL_WHOREPLY |
96 RPL_NAMREPLY | RPL_LINKS | RPL_ENDOFLINKS | RPL_ENDOFNAMES | RPL_BANLIST |
97 RPL_ENDOFBANLIST | RPL_ENDOFWHOWAS | RPL_INFO | RPL_MOTD | RPL_ENDOFINFO |
98 RPL_MOTDSTART | RPL_ENDOFMOTD | RPL_YOUREOPER | RPL_REHASHING |
99 RPL_YOURESERVICE | RPL_TIME | RPL_USERSSTART | RPL_USERS | RPL_ENDOFUSERS |
100 RPL_NOUSERS
101
102 :: IRCErrors = ERR_NOSUCHNICK | ERR_NOSUCHSERVER | ERR_NOSUCHCHANNEL |
103 ERR_CANNOTSENDTOCHAN | ERR_TOOMANYCHANNELS | ERR_WASNOSUCHNICK |
104 ERR_TOOMANYTARGETS | ERR_NOSUCHSERVICE | ERR_NOORIGIN | ERR_NORECIPIENT |
105 ERR_NOTEXTTOSEND | ERR_NOTOPLEVEL | ERR_WILDTOPLEVEL | ERR_BADMASK |
106 ERR_UNKNOWNCOMMAND | ERR_NOMOTD | ERR_NOADMININFO | ERR_FILEERROR |
107 ERR_NONICKNAMEGIVEN | ERR_ERRONEUSNICKNAME | ERR_NICKNAMEINUSE |
108 ERR_NICKCOLLISION | ERR_UNAVAILRESOURCE | ERR_USERNOTINCHANNEL |
109 ERR_NOTONCHANNEL | ERR_USERONCHANNEL | ERR_NOLOGIN | ERR_SUMMONDISABLED |
110 ERR_USERSDISABLED | ERR_NOTREGISTERED | ERR_NEEDMOREPARAMS |
111 ERR_ALREADYREGISTRED | ERR_NOPERMFORHOST | ERR_PASSWDMISMATCH |
112 ERR_YOUREBANNEDCREEP | ERR_YOUWILLBEBANNED | ERR_KEYSET |
113 ERR_CHANNELISFULL | ERR_UNKNOWNMODE | ERR_INVITEONLYCHAN |
114 ERR_BANNEDFROMCHAN | ERR_BADCHANNELKEY | ERR_BADCHANMASK |
115 ERR_NOCHANMODES | ERR_BANLISTFULL | ERR_NOPRIVILEGES |
116 ERR_CHANOPRIVSNEEDED | ERR_CANTKILLSERVER | ERR_RESTRICTED |
117 ERR_UNIQOPPRIVSNEEDED | ERR_NOOPERHOST | ERR_UMODEUNKNOWNFLAG |
118 ERR_USERSDONTMATCH