@@ -8,6 +8,7 @@ module AST.Expression.Optimized
11+import Control.Monad (liftM, liftM2, liftM3, liftM4)
11import Data.Binary
12import Data.Binary
12import qualified Data.Set as Set
13import qualified Data.Set as Set
13import Data.Text (Text)
14import Data.Text (Text)
@@ -99,7 +100,7 @@ data Choice
100instance Binary Decl where
101instance Binary Decl where
102− Decl <$> get <*> get <*> get
103+ liftM3 Decl get get get
104 put (Decl deps fx body) =
105 put (Decl deps fx body) =
105 put deps >> put fx >> put body
106 put deps >> put fx >> put body
@@ -126,29 +127,29 @@ instance Binary Expr where
127 do word <- getWord8
128 do word <- getWord8
128 case word of
129 case word of
129− 0 -> Literal <$> get
130+ 0 -> liftM Literal get
130− 1 -> VarLocal <$> get
131+ 1 -> liftM VarLocal get
131− 2 -> VarGlobal <$> get <*> get
132+ 2 -> liftM2 VarGlobal get get
132− 3 -> List <$> get
133+ 3 -> liftM List get
133− 4 -> Binop <$> get <*> get <*> get <*> get
134+ 4 -> liftM4 Binop get get get get
134− 5 -> Function <$> get <*> get
135+ 5 -> liftM2 Function get get
135− 6 -> Call <$> get <*> get
136+ 6 -> liftM2 Call get get
136− 7 -> TailCall <$> get <*> get <*> get
137+ 7 -> liftM3 TailCall get get get
137− 8 -> If <$> get <*> get
138+ 8 -> liftM2 If get get
138− 9 -> Let <$> get <*> get
139+ 9 -> liftM2 Let get get
139− 10 -> Case <$> get <*> get <*> get
140+ 10 -> liftM3 Case get get get
140− 11 -> Ctor <$> get <*> get
141+ 11 -> liftM2 Ctor get get
141− 12 -> CtorAccess <$> get <*> get
142+ 12 -> liftM2 CtorAccess get get
142− 13 -> Access <$> get <*> get
143+ 13 -> liftM2 Access get get
143− 14 -> Update <$> get <*> get
144+ 14 -> liftM2 Update get get
144− 15 -> Record <$> get
145+ 15 -> liftM Record get
145− 16 -> Cmd <$> get <*> get
146+ 16 -> liftM2 Cmd get get
146− 17 -> Sub <$> get <*> get
147+ 17 -> liftM2 Sub get get
147− 18 -> OutgoingPort <$> get <*> get
148+ 18 -> liftM2 OutgoingPort get get
148− 19 -> IncomingPort <$> get <*> get
149+ 19 -> liftM2 IncomingPort get get
149− 20 -> Program <$> get <*> get
150+ 20 -> liftM2 Program get get
150− 21 -> GLShader <$> get
151+ 21 -> liftM GLShader get
151− 22 -> Crash <$> get <*> get <*> get
152+ 22 -> liftM3 Crash get get get
152 _ -> error "problem getting Opt.Expr binary"
153 _ -> error "problem getting Opt.Expr binary"
154 put expr =
155 put expr =
@@ -182,9 +183,9 @@ instance (Binary a) => Binary (Decider a) where
183 do word <- getWord8
184 do word <- getWord8
184 case word of
185 case word of
185− 0 -> Leaf <$> get
186+ 0 -> liftM Leaf get
186− 1 -> Chain <$> get <*> get <*> get
187+ 1 -> liftM3 Chain get get get
187− 2 -> FanOut <$> get <*> get <*> get
188+ 2 -> liftM3 FanOut get get get
188 _ -> error "problem getting Opt.Decider binary"
189 _ -> error "problem getting Opt.Decider binary"
190 put decider =
191 put decider =
@@ -215,7 +216,7 @@ instance Binary Choice where
216 do word <- getWord8
217 do word <- getWord8
217 case word of
218 case word of
218− 0 -> Inline <$> get
219+ 0 -> liftM Inline get
219− 1 -> Jump <$> get
220+ 1 -> liftM Jump get
220 _ -> error "problem getting Opt.Choice binary"
221 _ -> error "problem getting Opt.Choice binary"