definition module mTaskInterpret from Data.Functor.Identity import :: Identity from Control.Monad.State import :: State, :: StateT from Data.Monoid import class Semigroup, class Monoid import mTask :: MTaskMessage = MTSds Int String | MTTask Int String | MTPub Int String | MTUpd Int String | MTEmpty instance toString MTaskMessage encode :: MTaskMessage -> String decode :: String -> MTaskMessage :: BC = BCNop | BCLab Int | BCPush [Char] | 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 //Serial | BCSerialAvail | BCSerialPrint | BCSerialPrintln | BCSerialRead | BCSerialParseInt //Pins | BCAnalogRead Pin | BCAnalogWrite Pin | BCDigitalRead Pin | BCDigitalWrite Pin | BCTest AnalogPin :: ByteCode a p = BC (BCState -> ([BC], BCState)) instance Semigroup (ByteCode a p) instance Monoid (ByteCode a p) :: BCState = { freshl :: [Int], freshs :: [Int], sdss :: [(Int, [Char])] } instance zero BCState class toByteCode a :: a -> [Char] instance toByteCode Int instance toByteCode Bool instance toByteCode Char instance toByteCode String instance toByteCode Long instance toByteCode Button instance toChar Pin instance arith ByteCode instance boolExpr ByteCode instance analogIO ByteCode instance digitalIO ByteCode instance If ByteCode Stmt Stmt Stmt instance If ByteCode Stmt e Stmt instance If ByteCode Stmt Stmt e instance If ByteCode x y Expr instance IF ByteCode instance noOp ByteCode instance sds ByteCode instance assign ByteCode instance seq ByteCode instance serial ByteCode //pub :: (ByteCode a b) -> ByteCode a b toMessages :: Int (String, BCState) -> [MTaskMessage] toByteVal :: BC -> [Char] toReadableByteCode :: (ByteCode a b) -> (String, BCState) toRealByteCode :: (ByteCode a b) -> (String, BCState)