(==.) l r = (==) <$> l <*> r
pToken c = pSatisfy ((==)c)
-class parseExpr a :: Parser Char a
-instance parseExpr a:: parseExpr
-parseExpr :: Parser Char (v a) | expr, div v & parsable, ==, +, /, zero, toString a
-parseExpr = foldr ($) parseBasic
+class parseExpr v a | expr, div v
+where
+ parseExpr :: Parser Char (v a)
+instance parseExpr v Int | expr, div v where
+ parseExpr = parseE
+instance parseExpr v Real | expr, div v where
+ parseExpr = parseE
+//instance parseExpr (v Real) where
+// parseExpr
+
+parseE :: Parser Char (v a) | expr, div v & parsable, ==, +, /, zero, toString a
+parseE = foldr ($) parseBasic
[ flip pChainl1 (pToken '+' $> (+.))
, flip pChainl1 (pToken '/' $> (/.))
]
class parsable a :: Parser Char a
instance parsable Int where parsable = foldl (\a b->10*a+digitToInt b) 0 <$> some pDigit
+instance parsable Real where parsable = foldl (\a b->10*a+digitToInt b) 0 <$> some pDigit
Start :: Either [Error] (Print Int)
Start = parse parseExpr ['42+42']
module test
+import iTasks
+
+import iTasks.Extensions.DateTime
+import iTasks.UI.Layout.Minimal
+
+Start w = doTasksWithOptions opt p2 w
+where
+ t :: Task DateTime
+ t = waitForTimer 7
+ t2 :: Task Int
+ t2 = enterInformation () [] >>= viewInformation () []
+ t3 :: Task String
+ t3 = withShared 3 \sh->
+ withTemporaryDirectory (viewInformation () [])
+ >>= viewInformation () []
+ t4 = updateInformation () [] 42
+
+ t5 = sequence [return i\\i<-[0..1000]] >>= viewInformation () []
+ t6 = waitForTimer 10
+
+ t7 :: Int -> Task Int
+ t7 i = viewInformation () [] i >>= \x->t7 (x + 1)
+
+ p = parallel [(Embedded, \_->waitForTimer 5)] []
+ p1 = waitForTimer 5 -||- waitForTimer 10
+ p2 = withShared 3 \sh->watch sh
+
+ opt args eo = Ok eo
+// opt args eo = Ok {eo & autoLayout=False}
+
+/*
//import StdEnv
//import Data.Error
//import Data.Maybe
//import System.Socket.Ipv4
////import System.Select
//
-import Data.Map => qualified get, updateAt
+from Data.Map import singleton
import Data.Map.GenJSON
-import Data.Func
+//import Data.Func
import iTasks
-Start w = doTasks t2 w
+import iTasks.Extensions.Files
+
+//Start w = doTasks (onStartup (copyFile "/home/mrl/test.txt" "/home/mrl/test2.txt")) w
+//Start w = doTasks (onStartup (workAs SystemUser (return 42))) w
+Start w = doTasks t w
-t2 = enterInformation "bork" []
- >>* [OnAction ActionOk $ ifValue ((==)42) return]
+t = viewInformation () [] ()
+ >>* [OnAction ActionOk (always (return ()))
+ ,OnAction ActionQuit (always (return ()))
+ ]
-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" []
+//Start w = doTasks t w
+//
+//t :: Task [(Int, TaskValue Int)]
+//t = parallel
+// [(Embedded, \stl->
+// appendTask Embedded (\_->viewInformation "Int" [] 42) stl
+// >>! \i->set (singleton "focus" "true") (sdsFocus i (taskListEntryMeta 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"
+// )] []
//import StdGeneric
// # (merr, w) = close sockfd w
// | isError merr = (liftError merr, w)
// = (Ok msg, w)
+*/