6 itake box = IMove { m_count=1, m_recycle=False, m_tokenIn=False, m_dataIn=True,
7 m_latch=True, m_dataOut=False, m_tokenOut=False, m_dest=Nothing,
9 move box = (itake box){ m_dataOut=True }
10 send box = (move box){ m_dataIn=False, m_latch=False }
11 notify box dest = IMove { m_count=1, m_recycle=False, m_tokenIn=False, m_dataIn=False,
12 m_latch=False, m_dataOut=False, m_tokenOut=True, m_dest=(Just dest),
14 wait box = IMove { m_count=1, m_recycle=False, m_tokenIn=True, m_dataIn=False,
15 m_latch=False, m_dataOut=False, m_tokenOut=False, m_dest=Nothing,
22 | ILiteral Int BenkoBox
23 | IMove { m_benkobox :: BenkoBox ,
24 m_dest :: Maybe BenkoBox ,
33 showCount 0 True = "[*r] "
34 showCount 0 False = "[*] "
36 showCount n True = "["++(show n)++"r] "
37 showCount n False = "["++(show n)++"] "
39 instance Show Inst where
40 show (IKill bb count) = (show bb)++": "++(showCount count False)++" kill;"
41 show (ILiteral lit bb) = (show lit)++": sendto "++(show bb)++";"
42 show m@(_) = (show $ m_benkobox m) ++
44 (showCount (m_count m) $ m_recycle m) ++
45 (join ", " $ showrest m)++
48 showrest m = wait++takelatch++out++ack
50 wait = if m_tokenIn m then ["wait"] else []
51 takelatch = if m_dataIn m then (if m_latch m then ["take"] else ["drop"]) else []
52 out = if m_dataOut m then (case m_dest m of { Nothing -> ["deliver"]; (Just j) -> ["sendto "++(show j)] }) else []
53 ack = if m_tokenOut m then (case m_dest m of (Just j) -> ["notify "++(show j)]) else []