import mTask
+instance zero State
+
eval :: (Main (Eval t p)) -> [String] | toString t
:: State =
{ tasks :: [(Int, State->State)]
, millis:: Int
}
-state0 :: State
-
//:: TaskSim :== (Int, State->State)
:: Eval t p = E ((ReadWrite t) State -> (t, State))
toS2S :: (Eval t p) -> (State->State)
import mTask
eval :: (Main (Eval t p)) -> [String] | toString t
-eval {main=(E f)} = [toString (fst (f Rd state0))]
+eval {main=(E f)} = [toString (fst (f Rd zero))]
:: State =
{ tasks :: [(Int, State->State)]
, millis:: Int
}
-state0 :: State
-state0 = {store = [], tasks = [], serial = [], millis = 0, dpins = [] , apins = []}
+instance zero State where
+ zero = {store = [], tasks = [], serial = [], millis = 0, dpins = [] , apins = []}
//:: TaskSim :== (Int, State->State)
:: Eval t p = E ((ReadWrite t) State -> (t, State))
derive class iTask DigitalPin, AnalogPin, Dyn, StateInterface, DisplayVar, Pin
simulate :: (Main (Eval a p)) -> Task ()
-simulate {main=(E f)} = setup state0 where
+simulate {main=(E f)} = setup zero where
setup s =
updateInformation "State" [] (toView s)
>>* [ OnAction ActionFinish (always shutDown)
updateInformation "State" [] (toView s)
>>* [ OnAction ActionFinish (always shutDown)
, OnAction (Action "clear serial" []) (always (simloop {s & serial = []}))
- , OnAction ActionNew (always (setup state0))
+ , OnAction ActionNew (always (setup zero))
: if (isEmpty s.tasks)
[]
[OnAction (Action "loop" []) (hasValue