changed JOIN adt
authorMart Lubbers <mart@martlubbers.net>
Sun, 5 Mar 2017 12:39:25 +0000 (13:39 +0100)
committerMart Lubbers <mart@martlubbers.net>
Sun, 5 Mar 2017 12:39:25 +0000 (13:39 +0100)
IRC.dcl
IRC.icl
test.icl

diff --git a/IRC.dcl b/IRC.dcl
index 337d6f9..0db138c 100644 (file)
--- a/IRC.dcl
+++ b/IRC.dcl
@@ -1,6 +1,5 @@
 definition module IRC
 
 definition module IRC
 
-from Data.Either import :: Either
 from Data.Maybe import :: Maybe
 from StdOverloaded import class fromInt, class toInt, class toString
 
 from Data.Maybe import :: Maybe
 from StdOverloaded import class fromInt, class toInt, class toString
 
@@ -13,7 +12,7 @@ from StdOverloaded import class fromInt, class toInt, class toString
        | INFO (Maybe String)
        | INVITE String String
        | ISON [String]
        | INFO (Maybe String)
        | INVITE String String
        | ISON [String]
-       | JOIN (Either () [(String, Maybe String)])
+       | JOIN [(String, Maybe String)]
        | KICK String String (Maybe String)
        | KILL String String
        | LINKS (Maybe (Maybe String, String))
        | KICK String String (Maybe String)
        | KILL String String
        | LINKS (Maybe (Maybe String, String))
diff --git a/IRC.icl b/IRC.icl
index 9b6b134..8ab91db 100644 (file)
--- a/IRC.icl
+++ b/IRC.icl
@@ -1,5 +1,6 @@
 implementation module IRC
 
 implementation module IRC
 
+import StdList
 import GenPrint
 import StdOverloaded
 import Data.Maybe
 import GenPrint
 import StdOverloaded
 import Data.Maybe
@@ -21,8 +22,8 @@ instance toString IRCCommands where
        //INFO (Maybe String)
        //INVITE String String
        //ISON [String]
        //INFO (Maybe String)
        //INVITE String String
        //ISON [String]
-               JOIN chs = "JOIN " +++ either (const "0")
-                       (\c->join ", " [join " " [ch:maybeToList mkey]\\(ch, mkey)<-c]) chs
+               JOIN chs = "JOIN " +++ (if (isEmpty chs) "0"
+                       (join ", " [join " " [ch:maybeToList mk]\\(ch, mk)<-chs]))
        //KICK String String (Maybe String)
        //KILL String String
        //LINKS (Maybe (Maybe String, String))
        //KICK String String (Maybe String)
        //KILL String String
        //LINKS (Maybe (Maybe String, String))
index da69fcd..d9ab2b7 100644 (file)
--- a/test.icl
+++ b/test.icl
@@ -10,7 +10,7 @@ Start :: [String]
 Start = map toString
        [NICK "clooglebot"
        ,USER "cloogle" 0 "Cloogle bot"
 Start = map toString
        [NICK "clooglebot"
        ,USER "cloogle" 0 "Cloogle bot"
-       ,JOIN $ Right [("#cloogle", Nothing)]
+       ,JOIN [("#cloogle", Nothing)]
        ,PRIVMSG "#cloogle" "Hello world"
        ,QUIT Nothing
        ]
        ,PRIVMSG "#cloogle" "Hello world"
        ,QUIT Nothing
        ]