You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will need a codec which works in both m and STM m. cborg requires access to the ST operations, e.g. mkCodecCborStrictST but STM monad has no MonadST instance.
because of the above constraint we cannot change its signature to STM m, but we can guarantee that all recvs are non blocking (e.g. atomically $ Just <$> recv `orElse` pure Nothing).
The tryRunDecoderWithChannel one is used to implement the tryRecvMessage record field of Driver. And it is plausible to implement it with recv :: STM m (Maybe ByteString))
The question is how we can implement recvMessageSTM. For that it seems that being able to run a decoder in the STM monad (without forking a thread) is indispensable.
GHC exposes unsafeIOToSTM which could be used to lift ST to STM (via IO), but this is rather dodgy way, so a different solution is needed. On the other hand, a rudimentary inspection of cborg library shows that ST is deeply grained, e.g.
We need a new
Channel
type:The Driver type can stay as is. However codec type is not general enough:
We will need a codec which works in both
m
andSTM m
.cborg
requires access to theST
operations, e.g. mkCodecCborStrictST butSTM
monad has noMonadST
instance.In
coot/typed-protocols-rewrite
branch we have:because of the above constraint we cannot change its signature to
STM m
, but we can guarantee that allrecv
s are non blocking (e.g.atomically $ Just <$> recv `orElse` pure Nothing
).The
tryRunDecoderWithChannel
one is used to implement thetryRecvMessage
record field ofDriver
. And it is plausible to implement it withrecv :: STM m (Maybe ByteString)
)The question is how we can implement
recvMessageSTM
. For that it seems that being able to run a decoder in theSTM
monad (without forking a thread) is indispensable.GHC
exposes unsafeIOToSTM which could be used to liftST
toSTM
(viaIO
), but this is rather dodgy way, so a different solution is needed. On the other hand, a rudimentary inspection ofcborg
library shows thatST
is deeply grained, e.g.The text was updated successfully, but these errors were encountered: