implementation module mTaskSerial import iTasks import GenEq, StdMisc, StdArray import mTask instance serial Code where serialAvailable = embed (c "Serial.available()") serialPrint x = embed (c "Serial.print(" +.+ x +.+ c ")") serialPrintln x = embed (c "Serial.println(" +.+ x +.+ c ")") serialRead = embed (c "Serial.read()") serialParseInt = embed (c "Serial.parseInt()") instance serial Eval where serialAvailable = rtrn False serialPrint x = x >>== \a.E \r s.let str = toCode a in (size str,{s & serial = s.serial ++ [str]}) serialPrintln x = x >>== \a.E \r s.let str = toCode a + "\n" in (size str,{s & serial = s.serial ++ [str]}) serialRead = rtrn undef serialParseInt = rtrn undef instance char2int Code where char2int (C f) = C \rw c.f Rd c :: SerialObject v t p = { available :: v Bool Expr , print :: (v t p) -> v Int Expr , println :: (v t p) -> v Int Expr , read :: (v Char Expr) }