definition module mTaskInterpret from Data.Functor.Identity import :: Identity from Control.Monad.State import :: State, :: StateT from Control.Monad.RWST import :: RWST, :: RWS from Data.Either import :: Either import mTask :: MTaskMSGRecv = MTTaskAck Int | MTTaskDelAck Int | MTSDSAck Int | MTSDSDelAck Int | MTPub Int String | MTMessage String | MTEmpty :: MTaskMSGSend = MTTask MTaskInterval String | MTTaskDel Int | MTSds Int String | MTUpd Int String :: MTaskInterval = OneShot | OnInterval Int | OnInterrupt Int instance toString MTaskInterval instance toString MTaskMSGRecv instance toString MTaskMSGSend encode :: MTaskMSGSend -> String decode :: String -> MTaskMSGRecv :: BC = BCNop | BCLab Int // | E.e: BCPush e & toByteCode e | BCPush String | BCPop //SDS functions | BCSdsStore Int | BCSdsFetch Int | BCSdsPublish Int //Unary ops | BCNot //Binary Int ops | BCAdd | BCSub | BCMul | BCDiv //Binary Bool ops | BCAnd | BCOr | BCEq | BCNeq | BCLes | BCGre | BCLeq | BCGeq //Conditionals and jumping | BCJmp Int | BCJmpT Int | BCJmpF Int //UserLED | BCLedOn | BCLedOff //Serial | BCSerialAvail | BCSerialPrint | BCSerialPrintln | BCSerialRead | BCSerialParseInt //Pins | BCAnalogRead Pin | BCAnalogWrite Pin | BCDigitalRead Pin | BCDigitalWrite Pin | BCTest AnalogPin derive class gCons BC :: ByteCode a p = BC (RWS () [BC] BCState ()) :: BCShare = { sdsi :: Int, sdspub :: Bool, sdsval :: Dynamic, sdsbc :: String } :: BCState = { freshl :: [Int], freshs :: [Int], sdss :: [BCShare] } instance zero BCState class toByteCode a :: a -> String class fromByteCode a :: String -> a class mTaskType a | toByteCode, fromByteCode, TC a instance toByteCode Int, Bool, Char, Long, String, Button, UserLED instance fromByteCode Int, Bool, Char, Long, String, Button, UserLED instance toByteCode MTaskInterval instance fromByteCode MTaskInterval instance toChar Pin instance arith ByteCode instance boolExpr ByteCode instance analogIO ByteCode instance digitalIO ByteCode instance userLed ByteCode instance If ByteCode Stmt Stmt Stmt instance If ByteCode e Stmt Stmt instance If ByteCode Stmt e Stmt instance If ByteCode x y Stmt instance IF ByteCode instance noOp ByteCode instance sds ByteCode instance assign ByteCode instance seq ByteCode instance serial ByteCode toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState) toSDSUpdate :: Int Int -> [MTaskMSGSend] toByteVal :: BC -> String toReadableByteCode :: (ByteCode a b) BCState -> (String, BCState) toRealByteCode :: (ByteCode a b) BCState -> (String, BCState)