From: Mart Lubbers Date: Tue, 1 Nov 2016 16:40:17 +0000 (+0100) Subject: state0 is zero now X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=dd0896b855fc81e10b45b9407fead457a027f645;p=mTask.git state0 is zero now --- diff --git a/mTaskSimulation.dcl b/mTaskSimulation.dcl index 2b13acf..496bd52 100644 --- a/mTaskSimulation.dcl +++ b/mTaskSimulation.dcl @@ -2,6 +2,8 @@ definition module mTaskSimulation import mTask +instance zero State + eval :: (Main (Eval t p)) -> [String] | toString t :: State = { tasks :: [(Int, State->State)] @@ -12,8 +14,6 @@ eval :: (Main (Eval t p)) -> [String] | toString t , millis:: Int } -state0 :: State - //:: TaskSim :== (Int, State->State) :: Eval t p = E ((ReadWrite t) State -> (t, State)) toS2S :: (Eval t p) -> (State->State) diff --git a/mTaskSimulation.icl b/mTaskSimulation.icl index 180d7e1..3a94811 100644 --- a/mTaskSimulation.icl +++ b/mTaskSimulation.icl @@ -5,7 +5,7 @@ import gdynamic, gCons, GenEq, StdMisc, StdArray 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)] @@ -16,8 +16,8 @@ eval {main=(E f)} = [toString (fst (f Rd state0))] , 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)) @@ -153,7 +153,7 @@ instance writePinD AnalogPin where 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) @@ -164,7 +164,7 @@ simulate {main=(E f)} = setup state0 where 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