@@ -25,10 +25,12 @@ import Network.TypedProtocol.Codec
2525import Network.TypedProtocol.Core
2626
2727
28- -- | Construct a 'Codec' for a CBOR based serialisation format, using strict
28+ type DeserialiseFailure = CBOR. DeserialiseFailure
29+
30+ -- | Construct a 'CodecF' for a CBOR based serialisation format, using strict
2931-- 'BS.ByteString's.
3032--
31- -- This is an adaptor between the @cborg@ library and the 'Codec ' abstraction.
33+ -- This is an adaptor between the @cborg@ library and the 'CodecF ' abstraction.
3234--
3335-- It takes encode and decode functions for the protocol messages that use the
3436-- CBOR library encoder and decoder.
@@ -38,7 +40,7 @@ import Network.TypedProtocol.Core
3840-- natively produces chunks).
3941--
4042mkCodecCborStrictBS
41- :: forall ps m . MonadST m
43+ :: forall ps m f . MonadST m
4244
4345 => (forall (st :: ps ) (st' :: ps ).
4446 StateTokenI st
@@ -49,10 +51,10 @@ mkCodecCborStrictBS
4951 -> (forall (st :: ps ) s .
5052 ActiveState st
5153 => StateToken st
52- -> CBOR. Decoder s (SomeMessage st ))
54+ -> CBOR. Decoder s (f st ))
5355 -- ^ cbor decoder
5456
55- -> Codec ps CBOR. DeserialiseFailure m BS. ByteString
57+ -> CodecF ps DeserialiseFailure m f BS. ByteString
5658mkCodecCborStrictBS cborMsgEncode cborMsgDecode =
5759 Codec {
5860 encode = \ msg -> convertCborEncoder cborMsgEncode msg,
@@ -65,11 +67,12 @@ mkCodecCborStrictBS cborMsgEncode cborMsgDecode =
6567 . cborEncode
6668
6769 convertCborDecoder
68- :: (forall s . CBOR. Decoder s a )
69- -> m (DecodeStep BS. ByteString CBOR. DeserialiseFailure m a )
70+ :: (forall s . CBOR. Decoder s ( f a ) )
71+ -> m (DecodeStep BS. ByteString DeserialiseFailure m ( f a ) )
7072 convertCborDecoder cborDecode =
7173 convertCborDecoderBS cborDecode stToIO
7274
75+
7376convertCborDecoderBS
7477 :: forall s m a . Functor m
7578 => CBOR. Decoder s a
@@ -89,16 +92,16 @@ convertCborDecoderBS cborDecode liftST =
8992 go (CBOR. Partial k) = DecodePartial (fmap go . liftST . k)
9093
9194
92- -- | Construct a 'Codec ' for a CBOR based serialisation format, using lazy
95+ -- | Construct a 'CodecF ' for a CBOR based serialisation format, using lazy
9396-- 'BS.ByteString's.
9497--
95- -- This is an adaptor between the @cborg@ library and the 'Codec ' abstraction.
98+ -- This is an adaptor between the @cborg@ library and the 'CodecF ' abstraction.
9699--
97100-- It takes encode and decode functions for the protocol messages that use the
98101-- CBOR library encoder and decoder.
99102--
100103mkCodecCborLazyBS
101- :: forall ps m . MonadST m
104+ :: forall ps m f . MonadST m
102105
103106 => (forall (st :: ps ) (st' :: ps ).
104107 StateTokenI st
@@ -109,10 +112,10 @@ mkCodecCborLazyBS
109112 -> (forall (st :: ps ) s .
110113 ActiveState st
111114 => StateToken st
112- -> CBOR. Decoder s (SomeMessage st ))
115+ -> CBOR. Decoder s (f st ))
113116 -- ^ cbor decoder
114117
115- -> Codec ps CBOR. DeserialiseFailure m LBS. ByteString
118+ -> CodecF ps CBOR. DeserialiseFailure m f LBS. ByteString
116119mkCodecCborLazyBS cborMsgEncode cborMsgDecode =
117120 Codec {
118121 encode = \ msg -> convertCborEncoder cborMsgEncode msg,
@@ -126,11 +129,12 @@ mkCodecCborLazyBS cborMsgEncode cborMsgDecode =
126129 . cborEncode
127130
128131 convertCborDecoder
129- :: (forall s . CBOR. Decoder s a )
130- -> m (DecodeStep LBS. ByteString CBOR. DeserialiseFailure m a )
132+ :: (forall s . CBOR. Decoder s ( f a ) )
133+ -> m (DecodeStep LBS. ByteString CBOR. DeserialiseFailure m ( f a ) )
131134 convertCborDecoder cborDecode =
132135 convertCborDecoderLBS cborDecode stToIO
133136
137+
134138convertCborDecoderLBS
135139 :: forall s m a . Monad m
136140 => CBOR. Decoder s a
0 commit comments