@@ -25,10 +25,12 @@ import Network.TypedProtocol.Codec
25
25
import Network.TypedProtocol.Core
26
26
27
27
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
29
31
-- 'BS.ByteString's.
30
32
--
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.
32
34
--
33
35
-- It takes encode and decode functions for the protocol messages that use the
34
36
-- CBOR library encoder and decoder.
@@ -38,7 +40,7 @@ import Network.TypedProtocol.Core
38
40
-- natively produces chunks).
39
41
--
40
42
mkCodecCborStrictBS
41
- :: forall ps m . MonadST m
43
+ :: forall ps m f . MonadST m
42
44
43
45
=> (forall (st :: ps ) (st' :: ps ).
44
46
StateTokenI st
@@ -49,10 +51,10 @@ mkCodecCborStrictBS
49
51
-> (forall (st :: ps ) s .
50
52
ActiveState st
51
53
=> StateToken st
52
- -> CBOR. Decoder s (SomeMessage st ))
54
+ -> CBOR. Decoder s (f st ))
53
55
-- ^ cbor decoder
54
56
55
- -> Codec ps CBOR. DeserialiseFailure m BS. ByteString
57
+ -> CodecF ps DeserialiseFailure m f BS. ByteString
56
58
mkCodecCborStrictBS cborMsgEncode cborMsgDecode =
57
59
Codec {
58
60
encode = \ msg -> convertCborEncoder cborMsgEncode msg,
@@ -65,11 +67,12 @@ mkCodecCborStrictBS cborMsgEncode cborMsgDecode =
65
67
. cborEncode
66
68
67
69
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 ) )
70
72
convertCborDecoder cborDecode =
71
73
convertCborDecoderBS cborDecode stToIO
72
74
75
+
73
76
convertCborDecoderBS
74
77
:: forall s m a . Functor m
75
78
=> CBOR. Decoder s a
@@ -89,16 +92,16 @@ convertCborDecoderBS cborDecode liftST =
89
92
go (CBOR. Partial k) = DecodePartial (fmap go . liftST . k)
90
93
91
94
92
- -- | Construct a 'Codec ' for a CBOR based serialisation format, using lazy
95
+ -- | Construct a 'CodecF ' for a CBOR based serialisation format, using lazy
93
96
-- 'BS.ByteString's.
94
97
--
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.
96
99
--
97
100
-- It takes encode and decode functions for the protocol messages that use the
98
101
-- CBOR library encoder and decoder.
99
102
--
100
103
mkCodecCborLazyBS
101
- :: forall ps m . MonadST m
104
+ :: forall ps m f . MonadST m
102
105
103
106
=> (forall (st :: ps ) (st' :: ps ).
104
107
StateTokenI st
@@ -109,10 +112,10 @@ mkCodecCborLazyBS
109
112
-> (forall (st :: ps ) s .
110
113
ActiveState st
111
114
=> StateToken st
112
- -> CBOR. Decoder s (SomeMessage st ))
115
+ -> CBOR. Decoder s (f st ))
113
116
-- ^ cbor decoder
114
117
115
- -> Codec ps CBOR. DeserialiseFailure m LBS. ByteString
118
+ -> CodecF ps CBOR. DeserialiseFailure m f LBS. ByteString
116
119
mkCodecCborLazyBS cborMsgEncode cborMsgDecode =
117
120
Codec {
118
121
encode = \ msg -> convertCborEncoder cborMsgEncode msg,
@@ -126,11 +129,12 @@ mkCodecCborLazyBS cborMsgEncode cborMsgDecode =
126
129
. cborEncode
127
130
128
131
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 ) )
131
134
convertCborDecoder cborDecode =
132
135
convertCborDecoderLBS cborDecode stToIO
133
136
137
+
134
138
convertCborDecoderLBS
135
139
:: forall s m a . Monad m
136
140
=> CBOR. Decoder s a
0 commit comments