Add binary instance for AST.Effects.ManagerType
commit9db7f7eb8542c4d3482153e3b8bc5e85a9962be2
authorEvan Czaplicki <evancz@users.noreply.github.com>
dateTue 28 Mar 2017, 14:12 (10 years ago)
parent22300f3
src/AST/Effects.hs+21
@@ -7,6 +7,7 @@ module AST.Effects
77 )
88 where
99
10+import Data.Binary
1011import Data.Text (Text)
1112
1213import qualified AST.Type as Type
@@ -78,3 +79,23 @@ data PortCanonical =
7879data Kind
7980 = Outgoing Type.Canonical
8081 | Incoming Type.Canonical
82+
83+
84+
85+-- BINARY
86+
87+
88+instance Binary ManagerType where
89+ put managerType =
90+ case managerType of
91+ Cmds -> putWord8 0
92+ Subs -> putWord8 1
93+ Both -> putWord8 2
94+
95+ get =
96+ do word <- getWord8
97+ case word of
98+ 0 -> pure Cmds
99+ 1 -> pure Subs
100+ 2 -> pure Both
101+ _ -> error "problem getting Effects.ManagerType binary"