Update to latest clean-selectloop master
authorMart Lubbers <mart@martlubbers.net>
Wed, 4 Apr 2018 08:12:05 +0000 (10:12 +0200)
committerMart Lubbers <mart@martlubbers.net>
Wed, 4 Apr 2018 08:12:05 +0000 (10:12 +0200)
IRCBot.dcl
IRCBot.icl
clean-selectloop

index a016649..85a310e 100644 (file)
@@ -24,5 +24,4 @@ from Data.Error import :: MaybeErrorString, :: MaybeError
  * param: World
  * return: Maybe an error, the state and the new world
 */
  * param: World
  * return: Maybe an error, the state and the new world
 */
-bot ::  (String,Int) [IRCMessage] [IRCMessage] a (IRCMessage -> a -> .(*World -> *(Maybe [IRCMessage],a,*World))) *World -> *(Maybe String,a,*World)
-//bot :: (String, Int) [IRCMessage] [IRCMessage] .a (IRCMessage -> (.a -> .(*World -> *(Maybe [IRCMessage], .a, *World)))) *World -> *(Maybe String, .a, *World)
+bot :: (String, Int) [IRCMessage] [IRCMessage] .a (IRCMessage -> (.a -> *(*World -> *(Maybe [IRCMessage], .a, *World)))) !*World -> *(Maybe String, .a, !*World)
index 3d5c156..daed825 100644 (file)
@@ -4,20 +4,20 @@ from Data.Func import $
 import Data.Either
 import Data.Error
 import Data.Maybe
 import Data.Either
 import Data.Error
 import Data.Maybe
+import Data.Functor
+import Data.Tuple
+import StdTuple
 import IRC
 from Text import class Text(concat,split,join), instance Text String
 import StdList, StdString
 import TCPServer.Connection
 
 import IRC
 from Text import class Text(concat,split,join), instance Text String
 import StdList, StdString
 import TCPServer.Connection
 
-bot ::  (String,Int) [IRCMessage] [IRCMessage] a (IRCMessage -> a -> .(*World -> *(Maybe [IRCMessage],a,*World))) *World -> *(Maybe String,a,*World)
-//bot :: (String, Int) [IRCMessage] [IRCMessage] .a (IRCMessage -> (.a -> .(*World -> *(Maybe [IRCMessage], .a, *World)))) *World -> *(Maybe String, .a, *World)
-bot (host, port) start end state bot w = case connect host port
+bot :: (String, Int) [IRCMessage] [IRCMessage] .a (IRCMessage -> (.a -> *(*World -> *(Maybe [IRCMessage], .a, *World)))) !*World -> *(Maybe String, .a, !*World)
+bot (host, port) start end state bot w = appSnd3 snd $ connect host port
                { emptyConnection
                & onConnect = onConnect
                , onData    = onData
                { emptyConnection
                & onConnect = onConnect
                , onData    = onData
-               } ("", state) w of
-       (Error e, w) = (Just e, state, w)
-       (Ok (acc, state), w) = (Nothing, state, w)
+               } ("", state) w
 where
        onConnect s w = (Just (concat (map toString start)), connectionResponse s, w)
        onData d (acc, s) w = case split "\r\n" (acc +++ d) of
 where
        onConnect s w = (Just (concat (map toString start)), connectionResponse s, w)
        onData d (acc, s) w = case split "\r\n" (acc +++ d) of
@@ -26,10 +26,10 @@ where
                                // Do something with the error
                                (Left err) = (Nothing, {connectionResponse ("", s) & stop=True}, w)// (Error $ "IRC Parsing error: " +++ join "\n" err, chan, state, w)
                                (Right msg)
                                // Do something with the error
                                (Left err) = (Nothing, {connectionResponse ("", s) & stop=True}, w)// (Error $ "IRC Parsing error: " +++ join "\n" err, chan, state, w)
                                (Right msg)
-                               # acc = join "\r\n" [rest:xs]
-                               # (mircc, state, w) = bot msg state w
-                               | isNothing mircc = (Just (concat (map toString end)), {connectionResponse (acc, s) & stop=True}, w)
-                               # tosendthis = concat (map toString (fromJust mircc))
-                               # (tosend, cr, w) = onData "" (acc, s) w
-                               = (Just (maybe tosendthis ((+++) tosendthis) tosend), cr, w)    
+                                       # acc = join "\r\n" [rest:xs]
+                                       # (mircc, s, w) = bot msg s w
+                                       | isNothing mircc = (Just (concat (map toString end)), {connectionResponse (acc, s) & stop=True}, w)
+                                       # tosendthis = concat (map toString (fromJust mircc))
+                                       # (tosend, cr, w) = onData "" (acc, s) w
+                                       = (Just (maybe tosendthis ((+++) tosendthis) tosend), cr, w)    
                [m] = (Nothing, connectionResponse (m, s), w)
                [m] = (Nothing, connectionResponse (m, s), w)
index bca216d..6abc922 160000 (submodule)
@@ -1 +1 @@
-Subproject commit bca216df4847e45d5b77d02c7302340b7a0dcf30
+Subproject commit 6abc92255ffc270772d7bdaa069b183045f5845d