-instance toByteCode BCValue where toByteCode (BCValue v) = toByteCode v
-instance toByteCode Bool where toByteCode b = toByteCode $ if b 1 0
-instance toByteCode Int where toByteCode n = {toChar $ n/256,toChar $ n rem 256}
-instance toByteCode Long where toByteCode (L n) = toByteCode n
-instance toByteCode Char where toByteCode c = toByteCode $ toInt c
+parseBCValue :: Char String -> BCValue
+parseBCValue c s = case c of
+ 'b' = BCValue $ castfbc True s
+ 'i' = BCValue $ castfbc 0 s
+ 'l' = BCValue $ castfbc (L 0) s
+ 'c' = BCValue $ castfbc ('0') s
+ 'B' = BCValue $ castfbc (NoButton) s
+ 'L' = BCValue $ castfbc (LED1) s
+
+castfbc :: a -> (String -> a) | mTaskType a
+castfbc _ = fromByteCode
+
+instance toByteCode Bool where toByteCode b = {#'b','\0',if b '\x01' '\0'}
+instance toByteCode Int where toByteCode n = {'i',toChar $ n/256,toChar $ n rem 256}
+instance toByteCode Long where toByteCode (L n) = {'l',toChar $ n/256,toChar $ n rem 256}
+instance toByteCode Char where toByteCode c = {'c','\0',c}