From 57707b61bf7f52bf8614dbf6860ff116519533e7 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sun, 5 Mar 2017 13:39:25 +0100 Subject: [PATCH] changed JOIN adt --- IRC.dcl | 3 +-- IRC.icl | 5 +++-- test.icl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/IRC.dcl b/IRC.dcl index 337d6f9..0db138c 100644 --- a/IRC.dcl +++ b/IRC.dcl @@ -1,6 +1,5 @@ definition module IRC -from Data.Either import :: Either 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] - | JOIN (Either () [(String, Maybe String)]) + | JOIN [(String, Maybe 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 --- a/IRC.icl +++ b/IRC.icl @@ -1,5 +1,6 @@ implementation module IRC +import StdList import GenPrint import StdOverloaded import Data.Maybe @@ -21,8 +22,8 @@ instance toString IRCCommands where //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)) diff --git a/test.icl b/test.icl index da69fcd..d9ab2b7 100644 --- a/test.icl +++ b/test.icl @@ -10,7 +10,7 @@ Start :: [String] Start = map toString [NICK "clooglebot" ,USER "cloogle" 0 "Cloogle bot" - ,JOIN $ Right [("#cloogle", Nothing)] + ,JOIN [("#cloogle", Nothing)] ,PRIVMSG "#cloogle" "Hello world" ,QUIT Nothing ] -- 2.20.1