on master help sign in
Use liftM in binary instances for types
commitfa7b51dce82d7ae86c259a4340190e97a9e960c4 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 30 Mar 2017, 18:01 (10 years ago) parentd7a266b
1 file changed+9−8
src/AST/Type.hs+9−8
src/AST/Type.hs+9−8
@@ -10,6 +10,7 @@ module AST.Type
1010 where
1111
1212import Control.Arrow (second)
13+import Control.Monad (liftM, liftM2, liftM3)
1314import Data.Binary
1415import qualified Data.Map as Map
1516import qualified Data.Text as Text
@@ -197,12 +198,12 @@ instance Binary Canonical where
197198 get =
198199 do n <- getWord8
199200 case n of
200− 0 -> Lambda <$> get <*> get
201− 1 -> Var <$> get
202− 2 -> Type <$> get
203− 3 -> App <$> get <*> get
204− 4 -> Record <$> get <*> get
205− 5 -> Aliased <$> get <*> get <*> get
201+ 0 -> liftM2 Lambda get get
202+ 1 -> liftM Var get
203+ 2 -> liftM Type get
204+ 3 -> liftM2 App get get
205+ 4 -> liftM2 Record get get
206+ 5 -> liftM3 Aliased get get get
206207 _ -> error "Error reading a valid type from serialized string"
207208
208209
@@ -218,6 +219,6 @@ instance Binary t => Binary (Aliased t) where
218219 get =
219220 do n <- getWord8
220221 case n of
221− 0 -> Holey <$> get
222− 1 -> Filled <$> get
222+ 0 -> liftM Holey get
223+ 1 -> liftM Filled get
223224 _ -> error "Error reading a valid type from serialized string"