on master help sign in
cosmetic: more consistent Binary instances
commited195c15d67e52f04b5013fb0248fa0918a6b40d authorEvan Czaplicki <info@elm-lang.org> dateSun 1 Jun 2014, 22:56 (12 years ago) parent0e73928
2 files changed+6−11
compiler/AST/Module.hs+2−3 compiler/AST/Variable.hs+4−8
compiler/AST/Module.hs+2−3
@@ -96,10 +96,9 @@ importing xs = Open (Var.Listing (map Var.Value xs) False)
9696
9797instance Binary ImportMethod where
9898 put method =
99− let put' n info = putWord8 n >> put info in
10099 case method of
101− As alias -> put' 0 alias
102− Open listing -> put' 1 listing
100+ As alias -> putWord8 0 >> put alias
101+ Open listing -> putWord8 1 >> put listing
103102
104103 get = do tag <- getWord8
105104 case tag of
compiler/AST/Variable.hs+4−8
@@ -133,13 +133,10 @@ instance Binary Canonical where
133133
134134instance Binary Value where
135135 put portable =
136− let put' n info = putWord8 n >> put info in
137136 case portable of
138− Value name -> put' 0 name
139− Alias name -> put' 1 name
140− ADT name ctors ->
141− do put' 2 name
142− put ctors
137+ Value name -> putWord8 0 >> put name
138+ Alias name -> putWord8 1 >> put name
139+ ADT name ctors -> putWord8 2 >> put name >> put ctors
143140
144141 get = do tag <- getWord8
145142 case tag of
@@ -150,7 +147,6 @@ instance Binary Value where
150147
151148instance (Binary a) => Binary (Listing a) where
152149 put (Listing explicits open) =
153− do put explicits
154− put open
150+ put explicits >> put open
155151
156152 get = Listing <$> get <*> get