@@ -29,7 +29,7 @@ codecReqResp
2929 -- ^ encode `req resp`
3030 -> (String -> Maybe (Some req ))
3131 -- ^ decode `req resp`
32- -> (forall resp . resp -> String )
32+ -> (forall resp . req resp -> resp -> String )
3333 -- ^ encode resp
3434 -> (forall resp . req resp -> String -> Maybe resp )
3535 -- ^ decode resp
@@ -40,9 +40,9 @@ codecReqResp encodeReq decodeReq encodeResp decodeResp =
4040 encode :: State st'
4141 -> Message (ReqResp req ) st st'
4242 -> String
43- encode _ (MsgReq req) = " MsgReq " ++ encodeReq req ++ " \n "
44- encode _ MsgDone = " MsgDone\n "
45- encode _ (MsgResp resp) = " MsgResp " ++ encodeResp resp ++ " \n "
43+ encode _ (MsgReq req) = " MsgReq " ++ encodeReq req ++ " \n "
44+ encode _ MsgDone = " MsgDone\n "
45+ encode _ (MsgResp req resp) = " MsgResp " ++ encodeResp req resp ++ " \n "
4646
4747 decode :: forall (st :: ReqResp req ).
4848 ActiveState st
@@ -60,7 +60,7 @@ codecReqResp encodeReq decodeReq encodeResp decodeResp =
6060 (SingBusy , StateBusy req, (" MsgResp" , str'))
6161 -- note that we need `req` to decode response of the given type
6262 | Just resp <- decodeResp req str'
63- -> DecodeDone (SomeMessage (MsgResp resp)) trailing
63+ -> DecodeDone (SomeMessage (MsgResp req resp)) trailing
6464 (_, _, _) -> DecodeFail failure
6565 where failure = CodecFailure (" unexpected server message: " ++ str)
6666
@@ -95,7 +95,7 @@ codecReqRespId eqRespTypes = Codec { encode, decode }
9595 -> DecodeDone (SomeMessage msg) Nothing
9696 (SingIdle , StateIdle , Just (Bytes msg@ MsgReq {}))
9797 -> DecodeDone (SomeMessage msg) Nothing
98- (SingBusy , StateBusy req, Just (Bytes msg@ ( MsgResp _) ))
98+ (SingBusy , StateBusy req, Just (Bytes msg@ MsgResp {} ))
9999 -- the codec needs to verify that response type of `req` and `msg` agrees
100100 | Just Refl <- eqRespTypes (reqRespType req) (msgRespType msg)
101101 -> DecodeDone (SomeMessage msg) Nothing
@@ -106,7 +106,7 @@ codecReqRespId eqRespTypes = Codec { encode, decode }
106106
107107 msgRespType :: forall resp . Message (ReqResp FileAPI ) (StBusy resp ) StIdle
108108 -> Proxy resp
109- msgRespType (MsgResp _) = Proxy
109+ msgRespType (MsgResp _ _ ) = Proxy
110110
111111 reqRespType :: forall resp . FileAPI resp -> Proxy resp
112112 reqRespType _ = Proxy
0 commit comments