on master help sign in
Add binary instance for AST.Effects.ManagerType
9db7f7eEvan Czaplicki
src/AST/Effects.hs+21
@@ -7,6 +7,7 @@ module AST.Effects
7 )
7 )
8 where
8 where
9
9
10+import Data.Binary
10import Data.Text (Text)
11import Data.Text (Text)
11
12
12import qualified AST.Type as Type
13import qualified AST.Type as Type
@@ -78,3 +79,23 @@ data PortCanonical =
78data Kind
79data Kind
79 = Outgoing Type.Canonical
80 = Outgoing Type.Canonical
80 | Incoming Type.Canonical
81 | 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"