From: Mart Lubbers Date: Thu, 1 Jun 2017 11:52:58 +0000 (+0200) Subject: share waiting with parametric lenses X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=bc19cda87c727d85893f56adcb8c6901715c2326;p=mTask.git share waiting with parametric lenses --- diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index 99a3533..9de7c72 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -40,7 +40,9 @@ from Generics.gCons import class gCons, generic conses, generic consName, generi ,bytesMemory :: Int } -:: BCValue = E.e: BCValue e & mTaskType e +:: BCValue = E.e: BCValue e & mTaskType, TC e + +instance == BCValue instance toString MTaskInterval instance toString MTaskMSGRecv diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index 80d458a..5504a21 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -40,6 +40,8 @@ import Text.Encodings.Base64 import Tasks.Examples +instance == BCValue where (==) a b = toByteCode a == toByteCode b + encode :: MTaskMSGSend -> String encode (MTTask to data) = "t" +++ toByteCode to +++ to16bit (size data) +++ data +++ "\n" encode (MTTaskDel i) = "d" +++ to16bit i +++ "\n" diff --git a/miTask.icl b/miTask.icl index 8e43544..f044e36 100644 --- a/miTask.icl +++ b/miTask.icl @@ -37,9 +37,20 @@ demo = viewSharedInformation "Devices" [] deviceStore pred [x:_] = not $ isEmpty x.deviceShares cont :: MTaskDevice -> Task () - cont dev = updateSharedInformation "Blinkyblink" [] (getRealShare dev (hd dev.deviceShares)) - >>* [OnAction ActionContinue (const $ Just $ cont dev)] - + cont dev + # rs = getRealShare dev (hd dev.deviceShares) + = get rs >>= \oldvalue-> + forever (updateSharedInformation "Blinkyblink" [] (getRealShare dev (hd dev.deviceShares)) + >>* [OnAction ActionContinue (const $ Just $ treturn ())]) + -|| (wait "bigger than 10" (\x->x == oldvalue) rs + >>= viewInformation "Bigger:)" []) + + toInt :: BCValue -> Int + toInt (BCValue e) = dynToInt (dynamic e) + + dynToInt :: Dynamic -> Int + dynToInt (a :: Int) = a + dynToInt x = abort "Not an int" mTaskManager :: Task () mTaskManager = (>>|) startupDevices $