.
[clean-tests.git] / test.icl
index 06b0dec..822f41d 100644 (file)
--- a/test.icl
+++ b/test.icl
@@ -1,65 +1,38 @@
 module test
 
-//import StdEnv
-//import Data.Error
-//import Data.Maybe
-//import Network.IP
-//import System.Socket
-//import System.Socket.Ipv4
-////import System.Select
-//
-import Data.Map => qualified get, updateAt
-import Data.Map.GenJSON
-import Data.Func
-import iTasks
+import StdEnv
+import Data.Maybe
+import Data.Functor
+import Control.Monad
+import Control.Applicative
 
-Start w = doTasks t2 w
+class expr v where
+       lit :: i -> v i | toString i
+       (+.) infixl 6 :: (v i) (v i) -> v i | + i
 
-t2 = enterInformation "bork" []
-       >>* [OnAction ActionOk $ ifValue ((==)42) return]
+instance + (v a) | expr v & + a where
+       + l r = l +. r
 
-t = parallel
-       [(Embedded,
-                   \stl->appendTask Embedded (\_->viewInformation "int" [] 42 <<@ markActive <<@ markActive) stl
-               >>= \tid->viewInformation "go" [] "go" @! 42
-//             >>* [OnAction ActionOk $ always $ set
-//                     ([(tid, put "answer" "42" (singleton "bork" "bork"))])
-//                     (sdsFocus {onlyIndex=Nothing,onlyTaskId=Just [tid],onlySelf=False,includeValue=True,includeAttributes=True,includeProgress=True} stl)]
-//             >>= \_->viewSharedInformation "parallel task list" []
-//                     (sdsFocus {onlyIndex=Nothing,onlyTaskId=Nothing,onlySelf=False,includeValue=True,includeProgress=True,includeAttributes=True} stl)
-//             @! 42
-//     ),(Embedded, \stl->viewSharedInformation "parallel task list" []
-//             (sdsFocus {onlyIndex=Nothing,onlyTaskId=Nothing,onlySelf=False,includeValue=True,includeProgress=True,includeAttributes=True} stl)
-//             @! 42
-       )] []
-//     [OnAction (Action "bork") $ ifValue (\v->not (v =: []))
-//             \_->(Embedded, \stl->
-//                     get (sdsFocus defaultValue stl) >>= \(_, [_,{TaskListItem|taskId}:_])->
-//                             set (singleton "title" "true")
-//                                     (sdsFocus taskId (taskListEntryMeta stl)) @! ())
-//                             set [(taskId, singleton "title" "true")]
-//                                     (sdsFocus listFilter stl) @! ())]
-       <<@ ArrangeWithTabs True
-where
-       markActive = ApplyAttribute "class" "focus"
+eval :: (Maybe a) -> Maybe a
+eval x = x
+instance expr Maybe where
+       lit i = Just i
+       +. x y = (+) <$> x <*> y
 
+:: Print a =: Print String
+print :: (Print a) -> String
+print (Print a) = a
+instance expr Print where
+       lit i = Print (toString i)
+       +. (Print l) (Print r) = Print (l +++ "+" +++ r)
 
-//import StdGeneric
-//
-//generic g a :: a
-//
-//g{|*|} = 42
+printEval :: (A.v: v a | expr v) -> (Maybe a, String)
+//printEval f = (f, let (Print p) = f in p)
+printEval f = (eval f, print f)
 
-//Start :: *World -> (MaybeOSError String, *World)
-//Start w
-//     = case socket SocketStream w of
-//             (Error e, w) = (Error e, w)
-//             (Ok sockfd, w)
-//                     #! (merr, sockfd) = connect {ipv4_socket_port=8124,ipv4_socket_addr=Just (fromString "127.0.0.1")} sockfd
-//                     | isError merr = (liftError merr, w)
-//                     #! (merr, sockfd) = recv 128 [] sockfd
-//                     | isError merr = (merr, w)
-//                     # (Ok msg) = merr
-//                     # (merr, w) = close sockfd w
-//                     | isError merr = (liftError merr, w)
-//                     = (Ok msg, w)
+//Mag niet
+//Start :: (Maybe Int, String)
+//Start = printEval (lit 4 + lit 38)
+
+//Mag wel
+Start = let (Print f) = lit 4 + lit 38 in f