From: Mart Lubbers Date: Mon, 13 Mar 2017 12:07:54 +0000 (+0100) Subject: existential types continued X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=da0d3362b957a1b9e0ef7eefb023d5817ec10ac6;p=mTask.git existential types continued --- diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index a157e0b..0304e7e 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -114,7 +114,7 @@ sendToDevice wta mTask (device, timeout) = @! () where sharename i = device.deviceChannels +++ "-" +++ toString i - toSDSRecords st = sequence "" [makeShare wta sdsi sdsbc\\{sdsi,sdspub,sdsbc}<-st.sdss]// | sdspub] + toSDSRecords st = sequence "" [makeShare wta sdsi sdsval\\{sdsi,sdspub,sdsval}<-st.sdss]// | sdspub] addTask :: MTaskTask MTaskDevice -> MTaskDevice addTask task device = {device & deviceTasks=[task:device.deviceTasks]} diff --git a/Shares/mTaskShare.dcl b/Shares/mTaskShare.dcl index df4a2f1..f97649e 100644 --- a/Shares/mTaskShare.dcl +++ b/Shares/mTaskShare.dcl @@ -2,6 +2,7 @@ definition module Shares.mTaskShare import iTasks import iTasks._Framework.Serialization +import mTask derive class iTask MTaskShareType @@ -17,11 +18,10 @@ derive gEq MTaskShare {withTask :: String ,identifier :: Int ,realShare :: MTaskShareType - ,value :: String - ,dynvalue :: Dynamic + ,value :: BCValue } manageShares :: [MTaskShare] -> Task () ///makeShare :: String Int Dynamic -> Task MTaskShare -makeShare :: String Int String -> Task MTaskShare +makeShare :: String Int BCValue -> Task MTaskShare diff --git a/Shares/mTaskShare.icl b/Shares/mTaskShare.icl index 7f9a2f4..0999cc2 100644 --- a/Shares/mTaskShare.icl +++ b/Shares/mTaskShare.icl @@ -39,20 +39,19 @@ viewShares :: [MTaskShare] -> Task MTaskShare viewShares sh = anyTask (map viewShare sh) <<@ ArrangeHorizontal >>| return (hd sh) -viewShare :: MTaskShare -> Task String +viewShare :: MTaskShare -> Task BCValue viewShare m = viewSharedInformation "" [] (getSDSShare m) <<@ Title ("SDS: " +++ toString m.identifier) -getSDSShare :: MTaskShare -> Shared String +getSDSShare :: MTaskShare -> Shared BCValue getSDSShare s=:{realShare=(MTaskWithShare id)} = memoryShare id s.MTaskShare.value -makeShare :: String Int String -> Task MTaskShare +makeShare :: String Int BCValue -> Task MTaskShare makeShare withTask identifier value = treturn {MTaskShare |withTask=withTask ,identifier=identifier ,value=value - ,dynvalue=dynamic value ,realShare=MTaskWithShare $ "mTaskSDS-" +++ toString identifier } >>= \sh->set value (getSDSShare sh) >>| treturn sh diff --git a/mTaskInterpret.dcl b/mTaskInterpret.dcl index d104b02..a6b7b61 100644 --- a/mTaskInterpret.dcl +++ b/mTaskInterpret.dcl @@ -104,8 +104,7 @@ derive gEq BCValue :: BCShare = { sdsi :: Int, sdspub :: Bool, - sdsval :: Dynamic, - sdsbc :: String + sdsval :: BCValue } :: BCState = { diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index c6a3e53..873e250 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -240,7 +240,7 @@ instance sds ByteCode where >>= \(v In bdy)->modify (addSDS sds v) >>| unBC (unMain bdy)} // >>= \(v In bdy)->modify (addSDS sds (toByteCode v)) >>| unBC (unMain bdy)} where - addSDS i v s = {s & sdss=[{sdsi=i,sdspub=False,sdsval=(dynamic v),sdsbc=toByteCode v}:s.sdss]} + addSDS i v s = {s & sdss=[{sdsi=i,sdspub=False,sdsval=(BCValue v)}:s.sdss]} con f = undef pub (BC x) = BC $ censor (\[BCSdsFetch s]->[BCSdsPublish s]) @@ -323,7 +323,7 @@ toReadableByteCode x s toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState) toMessages interval (bytes, st=:{sdss}) = ( - [MTSds s.sdsi s.sdsbc\\s<-sdss] ++ + [MTSds sdsi $ toByteCode e\\{sdsi,sdsval=(BCValue e)}<-sdss] ++ [MTTask interval bytes], st) toSDSUpdate :: Int Int -> [MTaskMSGSend]