on master help sign in
Switch to liftM in binary instance
commit6b922970242f1180d35bc82f643bf72968ff39d3 authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 3 Apr 2017, 18:10 (10 years ago) parent11bd592
1 file changed+6−5
src/Elm/Package.hs+6−5
src/Elm/Package.hs+6−5
@@ -19,6 +19,7 @@ module Elm.Package
1919 where
2020
2121
22+import Control.Monad (liftM, liftM2, liftM3)
2223import Data.Binary (Binary, get, getWord8, put, putWord8)
2324import qualified Data.Char as Char
2425import Data.Function (on)
@@ -223,7 +224,7 @@ toNumber txt =
223224
224225instance Binary Name where
225226 get =
226− Name <$> get <*> get
227+ liftM2 Name get get
227228
228229 put (Name user project) =
229230 do put user
@@ -232,7 +233,7 @@ instance Binary Name where
232233
233234instance Binary Package where
234235 get =
235− Package <$> get <*> get
236+ liftM2 Package get get
236237
237238 put (Package name version) =
238239 do put name
@@ -243,10 +244,10 @@ instance Binary Version where
243244 get =
244245 do word <- getWord8
245246 if word == 0
246− then Version <$> get <*> get <*> get
247+ then liftM3 Version get get get
247248 else
248− do minor <- fromIntegral <$> getWord8
249− patch <- fromIntegral <$> getWord8
249+ do minor <- liftM fromIntegral getWord8
250+ patch <- liftM fromIntegral getWord8
250251 return (Version (fromIntegral word) minor patch)
251252
252253 put (Version major minor patch) =