on master help sign in
cosmetic: more consistent Binary instances
ed195c1Evan Czaplicki
compiler/AST/Module.hs+2−3
@@ -96,10 +96,9 @@ importing xs = Open (Var.Listing (map Var.Value xs) False)
96
96
97instance Binary ImportMethod where
97instance Binary ImportMethod where
98 put method =
98 put method =
99− let put' n info = putWord8 n >> put info in
100 case method of
99 case method of
101− As alias -> put' 0 alias
100+ As alias -> putWord8 0 >> put alias
102− Open listing -> put' 1 listing
101+ Open listing -> putWord8 1 >> put listing
103
102
104 get = do tag <- getWord8
103 get = do tag <- getWord8
105 case tag of
104 case tag of
compiler/AST/Variable.hs+4−8
@@ -133,13 +133,10 @@ instance Binary Canonical where
133
133
134instance Binary Value where
134instance Binary Value where
135 put portable =
135 put portable =
136− let put' n info = putWord8 n >> put info in
137 case portable of
136 case portable of
138− Value name -> put' 0 name
137+ Value name -> putWord8 0 >> put name
139− Alias name -> put' 1 name
138+ Alias name -> putWord8 1 >> put name
140− ADT name ctors ->
139+ ADT name ctors -> putWord8 2 >> put name >> put ctors
141− do put' 2 name
142− put ctors
143
140
144 get = do tag <- getWord8
141 get = do tag <- getWord8
145 case tag of
142 case tag of
@@ -150,7 +147,6 @@ instance Binary Value where
150
147
151instance (Binary a) => Binary (Listing a) where
148instance (Binary a) => Binary (Listing a) where
152 put (Listing explicits open) =
149 put (Listing explicits open) =
153− do put explicits
150+ put explicits >> put open
154− put open
155
151
156 get = Listing <$> get <*> get
152 get = Listing <$> get <*> get