rewrite generation to rws
[mTask.git] / mTaskInterpret.dcl
index f853c65..24dc6a6 100644 (file)
@@ -2,7 +2,8 @@ definition module mTaskInterpret
 
 from Data.Functor.Identity import :: Identity
 from Control.Monad.State import :: State, :: StateT
-from Data.Monoid import class Semigroup, class Monoid
+from Control.Monad.RWST import :: RWST, :: RWS
+from Data.Either import :: Either
 import mTask
 
 :: MTaskMSGRecv
@@ -80,9 +81,7 @@ decode :: String -> MTaskMSGRecv
 derive gPrint BC
 derive class gCons BC
 
-:: ByteCode a p = BC (BCState -> ([BC], BCState))
-instance Semigroup (ByteCode a p)
-instance Monoid (ByteCode a p)
+:: ByteCode a p = BC (RWS () [BC] BCState ())
 
 :: BCShare = {
                sdsi :: Int,
@@ -99,7 +98,7 @@ instance zero BCState
 
 class toByteCode a :: a -> String
 class fromByteCode a :: String -> a
-class mTaskType a | toByteCode, fromByteCode, zero a
+class mTaskType a | toByteCode, fromByteCode a
 
 instance toByteCode Int, Bool, Char, Long, String, Button, UserLED
 instance fromByteCode Int, Bool, Char, Long, String, Button, UserLED
@@ -128,5 +127,5 @@ toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState)
 toSDSUpdate :: Int Int -> [MTaskMSGSend]
 
 toByteVal :: BC -> String
-toReadableByteCode :: (ByteCode a b) -> (String, BCState)
+toReadableByteCode :: (ByteCode a b) BCState -> (String, BCState)
 toRealByteCode :: (ByteCode a b) BCState -> (String, BCState)