on master help sign in
Switch to liftM in binary instance
6b92297Evan Czaplicki
src/Elm/Package.hs+6−5
@@ -19,6 +19,7 @@ module Elm.Package
19 where
19 where
20
20
21
21
22+import Control.Monad (liftM, liftM2, liftM3)
22import Data.Binary (Binary, get, getWord8, put, putWord8)
23import Data.Binary (Binary, get, getWord8, put, putWord8)
23import qualified Data.Char as Char
24import qualified Data.Char as Char
24import Data.Function (on)
25import Data.Function (on)
@@ -223,7 +224,7 @@ toNumber txt =
223
224
224instance Binary Name where
225instance Binary Name where
225 get =
226 get =
226− Name <$> get <*> get
227+ liftM2 Name get get
227
228
228 put (Name user project) =
229 put (Name user project) =
229 do put user
230 do put user
@@ -232,7 +233,7 @@ instance Binary Name where
232
233
233instance Binary Package where
234instance Binary Package where
234 get =
235 get =
235− Package <$> get <*> get
236+ liftM2 Package get get
236
237
237 put (Package name version) =
238 put (Package name version) =
238 do put name
239 do put name
@@ -243,10 +244,10 @@ instance Binary Version where
243 get =
244 get =
244 do word <- getWord8
245 do word <- getWord8
245 if word == 0
246 if word == 0
246− then Version <$> get <*> get <*> get
247+ then liftM3 Version get get get
247 else
248 else
248− do minor <- fromIntegral <$> getWord8
249+ do minor <- liftM fromIntegral getWord8
249− patch <- fromIntegral <$> getWord8
250+ patch <- liftM fromIntegral getWord8
250 return (Version (fromIntegral word) minor patch)
251 return (Version (fromIntegral word) minor patch)
251
252
252 put (Version major minor patch) =
253 put (Version major minor patch) =