4 always, hasValue, :: TaskValue(..), :: Task, :: Stability,
5 :: TaskCont(..), :: Action, updateInformation, viewInformation,
6 class descr, instance descr String, :: UpdateOption, :: ViewOption(..),
7 -||-, -||, ||-, startEngine, class Publishable, >>*, class TFunctor,
8 instance TFunctor Task, class TApplicative, instance TApplicative Task,
9 instance Publishable Task, Void
10 import Data.Tuple, StdClass, StdList, iTasks._Framework.Generic, Text.JSON,
11 Data.Functor, Control.Applicative, Control.Monad, Data.Map, Data.Either
12 import qualified iTasks
14 from Text import class Text, instance Text String
17 e = Insert New (Oper New +. (Union (Integer 7) (Size (Integer 9))))
26 | Intersection Set Set
29 | Oper Element Op Element
30 | (=.) infixl 2 Ident Expression
34 :: Element :== Expression
39 :: Val = Int Int | Set Set
40 :: State :== Map String Val
42 :: Sem a = Sem (State -> (Either String a, State))
44 unsem :: (Sem a) -> (State -> (Either String a, State))
47 instance Functor Sem where
48 fmap f s = Sem \st.let (a, st`)=unsem s st in (fmap f a, st`)
50 instance Applicative Sem where
51 pure s = Sem \st.(pure s, st)
54 instance Monad Sem where
55 bind (Sem s) f = Sem \st.case s st of
56 (Right v, st`) = unsem (f v) st`
57 (Left e, st`) = (Left e, st`)
59 store :: Ident Val -> Sem Val
60 store i v = Sem \st.(pure v, put i v st)
62 read :: Ident -> Sem Val
63 read i = Sem \st.case get i st of
64 (Just v) = (Right v, st)
65 _ = unsem (fail "variable not found") st
67 fail :: String -> Sem a
68 fail s = Sem \st.(Left s,st)
74 (>>>=) :== 'iTasks'.tbind
75 (>>>|) a b :== 'iTasks'.tbind a (\_ -> b)
76 treturn :== 'iTasks'.return
77 ActionOk :== 'iTasks'.ActionOk
78 ActionQuit :== 'iTasks'.ActionQuit
79 ActionNew :== 'iTasks'.ActionNew