{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
module Network.TypedProtocol.Codec
(
Codec (..)
, hoistCodec
, isoCodec
, mapFailureCodec
, PeerRole (..)
, PeerHasAgency (..)
, WeHaveAgency
, TheyHaveAgency
, SomeMessage (..)
, CodecFailure (..)
, DecodeStep (..)
, runDecoder
, runDecoderPure
, AnyMessage (..)
, AnyMessageAndAgency (..)
, prop_codecM
, prop_codec
, prop_codec_splitsM
, prop_codec_splits
, prop_codec_binary_compatM
, prop_codec_binary_compat
, prop_codecs_compatM
, prop_codecs_compat
, SamePeerHasAgency (..)
) where
import Control.Exception (Exception)
import Data.Kind (Type)
import Data.Monoid (All (..))
import Network.TypedProtocol.Core (PeerHasAgency (..), PeerRole (..),
Protocol (..), TheyHaveAgency, WeHaveAgency)
import Network.TypedProtocol.Driver (SomeMessage (..))
data Codec ps failure m bytes = Codec {
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st
-> Message ps st st'
-> bytes,
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
}
hoistCodec
:: ( Functor n )
=> (forall x . m x -> n x)
-> Codec ps failure m bytes
-> Codec ps failure n bytes
hoistCodec :: (forall x. m x -> n x)
-> Codec ps failure m bytes -> Codec ps failure n bytes
hoistCodec forall x. m x -> n x
nat Codec ps failure m bytes
codec = Codec ps failure m bytes
codec
{ decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> n (DecodeStep bytes failure n (SomeMessage st))
decode = (DecodeStep bytes failure m (SomeMessage st)
-> DecodeStep bytes failure n (SomeMessage st))
-> n (DecodeStep bytes failure m (SomeMessage st))
-> n (DecodeStep bytes failure n (SomeMessage st))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall x. m x -> n x)
-> DecodeStep bytes failure m (SomeMessage st)
-> DecodeStep bytes failure n (SomeMessage st)
forall (n :: * -> *) (m :: * -> *) bytes failure a.
Functor n =>
(forall x. m x -> n x)
-> DecodeStep bytes failure m a -> DecodeStep bytes failure n a
hoistDecodeStep forall x. m x -> n x
nat) (n (DecodeStep bytes failure m (SomeMessage st))
-> n (DecodeStep bytes failure n (SomeMessage st)))
-> (PeerHasAgency pr st
-> n (DecodeStep bytes failure m (SomeMessage st)))
-> PeerHasAgency pr st
-> n (DecodeStep bytes failure n (SomeMessage st))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (DecodeStep bytes failure m (SomeMessage st))
-> n (DecodeStep bytes failure m (SomeMessage st))
forall x. m x -> n x
nat (m (DecodeStep bytes failure m (SomeMessage st))
-> n (DecodeStep bytes failure m (SomeMessage st)))
-> (PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st)))
-> PeerHasAgency pr st
-> n (DecodeStep bytes failure m (SomeMessage st))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode Codec ps failure m bytes
codec
}
isoCodec :: Functor m
=> (bytes -> bytes')
-> (bytes' -> bytes)
-> Codec ps failure m bytes
-> Codec ps failure m bytes'
isoCodec :: (bytes -> bytes')
-> (bytes' -> bytes)
-> Codec ps failure m bytes
-> Codec ps failure m bytes'
isoCodec bytes -> bytes'
f bytes' -> bytes
finv Codec {forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode, forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode} = Codec :: forall ps failure (m :: * -> *) bytes.
(forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes)
-> (forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st)))
-> Codec ps failure m bytes
Codec {
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes'
encode = \PeerHasAgency pr st
tok Message ps st st'
msg -> bytes -> bytes'
f (bytes -> bytes') -> bytes -> bytes'
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> Message ps st st' -> bytes
forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode PeerHasAgency pr st
tok Message ps st st'
msg,
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes' failure m (SomeMessage st))
decode = \PeerHasAgency pr st
tok -> (bytes -> bytes')
-> (bytes' -> bytes)
-> DecodeStep bytes failure m (SomeMessage st)
-> DecodeStep bytes' failure m (SomeMessage st)
forall (m :: * -> *) bytes bytes' failure a.
Functor m =>
(bytes -> bytes')
-> (bytes' -> bytes)
-> DecodeStep bytes failure m a
-> DecodeStep bytes' failure m a
isoDecodeStep bytes -> bytes'
f bytes' -> bytes
finv (DecodeStep bytes failure m (SomeMessage st)
-> DecodeStep bytes' failure m (SomeMessage st))
-> m (DecodeStep bytes failure m (SomeMessage st))
-> m (DecodeStep bytes' failure m (SomeMessage st))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode PeerHasAgency pr st
tok
}
mapFailureCodec
:: Functor m
=> (failure -> failure')
-> Codec ps failure m bytes
-> Codec ps failure' m bytes
mapFailureCodec :: (failure -> failure')
-> Codec ps failure m bytes -> Codec ps failure' m bytes
mapFailureCodec failure -> failure'
f Codec {forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode, forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode} = Codec :: forall ps failure (m :: * -> *) bytes.
(forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes)
-> (forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st)))
-> Codec ps failure m bytes
Codec {
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode = forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode,
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure' m (SomeMessage st))
decode = \PeerHasAgency pr st
tok -> (failure -> failure')
-> DecodeStep bytes failure m (SomeMessage st)
-> DecodeStep bytes failure' m (SomeMessage st)
forall (m :: * -> *) failure failure' bytes a.
Functor m =>
(failure -> failure')
-> DecodeStep bytes failure m a -> DecodeStep bytes failure' m a
mapFailureDecodeStep failure -> failure'
f (DecodeStep bytes failure m (SomeMessage st)
-> DecodeStep bytes failure' m (SomeMessage st))
-> m (DecodeStep bytes failure m (SomeMessage st))
-> m (DecodeStep bytes failure' m (SomeMessage st))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode PeerHasAgency pr st
tok
}
data DecodeStep bytes failure m a =
DecodePartial (Maybe bytes -> m (DecodeStep bytes failure m a))
| DecodeDone a (Maybe bytes)
| DecodeFail failure
isoDecodeStep
:: Functor m
=> (bytes -> bytes')
-> (bytes' -> bytes)
-> DecodeStep bytes failure m a
-> DecodeStep bytes' failure m a
isoDecodeStep :: (bytes -> bytes')
-> (bytes' -> bytes)
-> DecodeStep bytes failure m a
-> DecodeStep bytes' failure m a
isoDecodeStep bytes -> bytes'
f bytes' -> bytes
finv (DecodePartial Maybe bytes -> m (DecodeStep bytes failure m a)
g) = (Maybe bytes' -> m (DecodeStep bytes' failure m a))
-> DecodeStep bytes' failure m a
forall bytes failure (m :: * -> *) a.
(Maybe bytes -> m (DecodeStep bytes failure m a))
-> DecodeStep bytes failure m a
DecodePartial ((DecodeStep bytes failure m a -> DecodeStep bytes' failure m a)
-> m (DecodeStep bytes failure m a)
-> m (DecodeStep bytes' failure m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((bytes -> bytes')
-> (bytes' -> bytes)
-> DecodeStep bytes failure m a
-> DecodeStep bytes' failure m a
forall (m :: * -> *) bytes bytes' failure a.
Functor m =>
(bytes -> bytes')
-> (bytes' -> bytes)
-> DecodeStep bytes failure m a
-> DecodeStep bytes' failure m a
isoDecodeStep bytes -> bytes'
f bytes' -> bytes
finv) (m (DecodeStep bytes failure m a)
-> m (DecodeStep bytes' failure m a))
-> (Maybe bytes' -> m (DecodeStep bytes failure m a))
-> Maybe bytes'
-> m (DecodeStep bytes' failure m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe bytes -> m (DecodeStep bytes failure m a)
g (Maybe bytes -> m (DecodeStep bytes failure m a))
-> (Maybe bytes' -> Maybe bytes)
-> Maybe bytes'
-> m (DecodeStep bytes failure m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (bytes' -> bytes) -> Maybe bytes' -> Maybe bytes
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap bytes' -> bytes
finv)
isoDecodeStep bytes -> bytes'
f bytes' -> bytes
_finv (DecodeDone a
a Maybe bytes
bytes) = a -> Maybe bytes' -> DecodeStep bytes' failure m a
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone a
a ((bytes -> bytes') -> Maybe bytes -> Maybe bytes'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap bytes -> bytes'
f Maybe bytes
bytes)
isoDecodeStep bytes -> bytes'
_f bytes' -> bytes
_finv (DecodeFail failure
failure) = failure -> DecodeStep bytes' failure m a
forall bytes failure (m :: * -> *) a.
failure -> DecodeStep bytes failure m a
DecodeFail failure
failure
hoistDecodeStep
:: ( Functor n )
=> (forall x . m x -> n x)
-> DecodeStep bytes failure m a
-> DecodeStep bytes failure n a
hoistDecodeStep :: (forall x. m x -> n x)
-> DecodeStep bytes failure m a -> DecodeStep bytes failure n a
hoistDecodeStep forall x. m x -> n x
nat DecodeStep bytes failure m a
step = case DecodeStep bytes failure m a
step of
DecodeDone a
a Maybe bytes
mb -> a -> Maybe bytes -> DecodeStep bytes failure n a
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone a
a Maybe bytes
mb
DecodeFail failure
fail_AvoidNameShadow -> failure -> DecodeStep bytes failure n a
forall bytes failure (m :: * -> *) a.
failure -> DecodeStep bytes failure m a
DecodeFail failure
fail_AvoidNameShadow
DecodePartial Maybe bytes -> m (DecodeStep bytes failure m a)
k -> (Maybe bytes -> n (DecodeStep bytes failure n a))
-> DecodeStep bytes failure n a
forall bytes failure (m :: * -> *) a.
(Maybe bytes -> m (DecodeStep bytes failure m a))
-> DecodeStep bytes failure m a
DecodePartial ((DecodeStep bytes failure m a -> DecodeStep bytes failure n a)
-> n (DecodeStep bytes failure m a)
-> n (DecodeStep bytes failure n a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall x. m x -> n x)
-> DecodeStep bytes failure m a -> DecodeStep bytes failure n a
forall (n :: * -> *) (m :: * -> *) bytes failure a.
Functor n =>
(forall x. m x -> n x)
-> DecodeStep bytes failure m a -> DecodeStep bytes failure n a
hoistDecodeStep forall x. m x -> n x
nat) (n (DecodeStep bytes failure m a)
-> n (DecodeStep bytes failure n a))
-> (Maybe bytes -> n (DecodeStep bytes failure m a))
-> Maybe bytes
-> n (DecodeStep bytes failure n a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (DecodeStep bytes failure m a)
-> n (DecodeStep bytes failure m a)
forall x. m x -> n x
nat (m (DecodeStep bytes failure m a)
-> n (DecodeStep bytes failure m a))
-> (Maybe bytes -> m (DecodeStep bytes failure m a))
-> Maybe bytes
-> n (DecodeStep bytes failure m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe bytes -> m (DecodeStep bytes failure m a)
k)
mapFailureDecodeStep
:: Functor m
=> (failure -> failure')
-> DecodeStep bytes failure m a
-> DecodeStep bytes failure' m a
mapFailureDecodeStep :: (failure -> failure')
-> DecodeStep bytes failure m a -> DecodeStep bytes failure' m a
mapFailureDecodeStep failure -> failure'
f DecodeStep bytes failure m a
step = case DecodeStep bytes failure m a
step of
DecodeDone a
a Maybe bytes
mb -> a -> Maybe bytes -> DecodeStep bytes failure' m a
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone a
a Maybe bytes
mb
DecodeFail failure
failure -> failure' -> DecodeStep bytes failure' m a
forall bytes failure (m :: * -> *) a.
failure -> DecodeStep bytes failure m a
DecodeFail (failure -> failure'
f failure
failure)
DecodePartial Maybe bytes -> m (DecodeStep bytes failure m a)
k -> (Maybe bytes -> m (DecodeStep bytes failure' m a))
-> DecodeStep bytes failure' m a
forall bytes failure (m :: * -> *) a.
(Maybe bytes -> m (DecodeStep bytes failure m a))
-> DecodeStep bytes failure m a
DecodePartial ((DecodeStep bytes failure m a -> DecodeStep bytes failure' m a)
-> m (DecodeStep bytes failure m a)
-> m (DecodeStep bytes failure' m a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((failure -> failure')
-> DecodeStep bytes failure m a -> DecodeStep bytes failure' m a
forall (m :: * -> *) failure failure' bytes a.
Functor m =>
(failure -> failure')
-> DecodeStep bytes failure m a -> DecodeStep bytes failure' m a
mapFailureDecodeStep failure -> failure'
f) (m (DecodeStep bytes failure m a)
-> m (DecodeStep bytes failure' m a))
-> (Maybe bytes -> m (DecodeStep bytes failure m a))
-> Maybe bytes
-> m (DecodeStep bytes failure' m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe bytes -> m (DecodeStep bytes failure m a)
k)
data CodecFailure = CodecFailureOutOfInput
| CodecFailure String
deriving (CodecFailure -> CodecFailure -> Bool
(CodecFailure -> CodecFailure -> Bool)
-> (CodecFailure -> CodecFailure -> Bool) -> Eq CodecFailure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodecFailure -> CodecFailure -> Bool
$c/= :: CodecFailure -> CodecFailure -> Bool
== :: CodecFailure -> CodecFailure -> Bool
$c== :: CodecFailure -> CodecFailure -> Bool
Eq, Int -> CodecFailure -> ShowS
[CodecFailure] -> ShowS
CodecFailure -> String
(Int -> CodecFailure -> ShowS)
-> (CodecFailure -> String)
-> ([CodecFailure] -> ShowS)
-> Show CodecFailure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodecFailure] -> ShowS
$cshowList :: [CodecFailure] -> ShowS
show :: CodecFailure -> String
$cshow :: CodecFailure -> String
showsPrec :: Int -> CodecFailure -> ShowS
$cshowsPrec :: Int -> CodecFailure -> ShowS
Show)
instance Exception CodecFailure
runDecoder :: Monad m
=> [bytes]
-> DecodeStep bytes failure m a
-> m (Either failure a)
runDecoder :: [bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [bytes]
_ (DecodeDone a
x Maybe bytes
_trailing) = Either failure a -> m (Either failure a)
forall (m :: * -> *) a. Monad m => a -> m a
return (a -> Either failure a
forall a b. b -> Either a b
Right a
x)
runDecoder [bytes]
_ (DecodeFail failure
failure) = Either failure a -> m (Either failure a)
forall (m :: * -> *) a. Monad m => a -> m a
return (failure -> Either failure a
forall a b. a -> Either a b
Left failure
failure)
runDecoder [] (DecodePartial Maybe bytes -> m (DecodeStep bytes failure m a)
k) = Maybe bytes -> m (DecodeStep bytes failure m a)
k Maybe bytes
forall a. Maybe a
Nothing m (DecodeStep bytes failure m a)
-> (DecodeStep bytes failure m a -> m (Either failure a))
-> m (Either failure a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder []
runDecoder (bytes
b:[bytes]
bs) (DecodePartial Maybe bytes -> m (DecodeStep bytes failure m a)
k) = Maybe bytes -> m (DecodeStep bytes failure m a)
k (bytes -> Maybe bytes
forall a. a -> Maybe a
Just bytes
b) m (DecodeStep bytes failure m a)
-> (DecodeStep bytes failure m a -> m (Either failure a))
-> m (Either failure a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [bytes]
bs
runDecoderPure :: Monad m
=> (forall b. m b -> b)
-> m (DecodeStep bytes failure m a)
-> [bytes]
-> Either failure a
runDecoderPure :: (forall b. m b -> b)
-> m (DecodeStep bytes failure m a) -> [bytes] -> Either failure a
runDecoderPure forall b. m b -> b
runM m (DecodeStep bytes failure m a)
decoder [bytes]
bs = m (Either failure a) -> Either failure a
forall b. m b -> b
runM ([bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [bytes]
bs (DecodeStep bytes failure m a -> m (Either failure a))
-> m (DecodeStep bytes failure m a) -> m (Either failure a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< m (DecodeStep bytes failure m a)
decoder)
data AnyMessage ps where
AnyMessage :: Message ps st st' -> AnyMessage ps
instance (forall st st'. Show (Message ps st st')) => Show (AnyMessage ps) where
show :: AnyMessage ps -> String
show (AnyMessage Message ps st st'
msg) = Message ps st st' -> String
forall a. Show a => a -> String
show Message ps st st'
msg
data AnyMessageAndAgency ps where
AnyMessageAndAgency :: PeerHasAgency pr (st :: ps)
-> Message ps (st :: ps) (st' :: ps)
-> AnyMessageAndAgency ps
instance
( forall (st :: ps). Show (ClientHasAgency st)
, forall (st :: ps). Show (ServerHasAgency st)
, forall (st :: ps) (st' :: ps). Show (Message ps st st')
) => Show (AnyMessageAndAgency ps) where
show :: AnyMessageAndAgency ps -> String
show (AnyMessageAndAgency PeerHasAgency pr st
agency Message ps st st'
msg) = (PeerHasAgency pr st, Message ps st st') -> String
forall a. Show a => a -> String
show (PeerHasAgency pr st
agency, Message ps st st'
msg)
prop_codecM
:: forall ps failure m bytes.
( Monad m
, Eq (AnyMessage ps)
)
=> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> m Bool
prop_codecM :: Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
prop_codecM Codec {forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode, forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode} (AnyMessageAndAgency PeerHasAgency pr st
stok Message ps st st'
msg) = do
Either failure (SomeMessage st)
r <- PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode PeerHasAgency pr st
stok m (DecodeStep bytes failure m (SomeMessage st))
-> (DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st)))
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes]
-> DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [PeerHasAgency pr st -> Message ps st st' -> bytes
forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode PeerHasAgency pr st
stok Message ps st st'
msg]
case Either failure (SomeMessage st)
r of
Right (SomeMessage Message ps st st'
msg') -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> m Bool) -> Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg' AnyMessage ps -> AnyMessage ps -> Bool
forall a. Eq a => a -> a -> Bool
== Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg
Left failure
_ -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
prop_codec
:: forall ps failure m bytes.
(Monad m, Eq (AnyMessage ps))
=> (forall a. m a -> a)
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> Bool
prop_codec :: (forall a. m a -> a)
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> Bool
prop_codec forall a. m a -> a
runM Codec ps failure m bytes
codec AnyMessageAndAgency ps
msg =
m Bool -> Bool
forall a. m a -> a
runM (Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
forall ps failure (m :: * -> *) bytes.
(Monad m, Eq (AnyMessage ps)) =>
Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
prop_codecM Codec ps failure m bytes
codec AnyMessageAndAgency ps
msg)
prop_codec_splitsM
:: forall ps failure m bytes.
(Monad m, Eq (AnyMessage ps))
=> (bytes -> [[bytes]])
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> m Bool
prop_codec_splitsM :: (bytes -> [[bytes]])
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
prop_codec_splitsM bytes -> [[bytes]]
splits
Codec {forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode, forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode :: forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode} (AnyMessageAndAgency PeerHasAgency pr st
stok Message ps st st'
msg) = do
[Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and ([Bool] -> Bool) -> m [Bool] -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [m Bool] -> m [Bool]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
[ do Either failure (SomeMessage st)
r <- PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode PeerHasAgency pr st
stok m (DecodeStep bytes failure m (SomeMessage st))
-> (DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st)))
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes]
-> DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [bytes]
bytes'
case Either failure (SomeMessage st)
r of
Right (SomeMessage Message ps st st'
msg') -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> m Bool) -> Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg' AnyMessage ps -> AnyMessage ps -> Bool
forall a. Eq a => a -> a -> Bool
== Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg
Left failure
_ -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
| let bytes :: bytes
bytes = PeerHasAgency pr st -> Message ps st st' -> bytes
forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode PeerHasAgency pr st
stok Message ps st st'
msg
, [bytes]
bytes' <- bytes -> [[bytes]]
splits bytes
bytes ]
prop_codec_splits
:: forall ps failure m bytes.
(Monad m, Eq (AnyMessage ps))
=> (bytes -> [[bytes]])
-> (forall a. m a -> a)
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> Bool
prop_codec_splits :: (bytes -> [[bytes]])
-> (forall a. m a -> a)
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> Bool
prop_codec_splits bytes -> [[bytes]]
splits forall a. m a -> a
runM Codec ps failure m bytes
codec AnyMessageAndAgency ps
msg =
m Bool -> Bool
forall a. m a -> a
runM (m Bool -> Bool) -> m Bool -> Bool
forall a b. (a -> b) -> a -> b
$ (bytes -> [[bytes]])
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
forall ps failure (m :: * -> *) bytes.
(Monad m, Eq (AnyMessage ps)) =>
(bytes -> [[bytes]])
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
prop_codec_splitsM bytes -> [[bytes]]
splits Codec ps failure m bytes
codec AnyMessageAndAgency ps
msg
data SamePeerHasAgency (pr :: PeerRole) (ps :: Type) where
SamePeerHasAgency
:: forall (pr :: PeerRole) ps (st :: ps).
PeerHasAgency pr st
-> SamePeerHasAgency pr ps
prop_codec_binary_compatM
:: forall psA psB failure m bytes.
( Monad m
, Eq (AnyMessage psA)
)
=> Codec psA failure m bytes
-> Codec psB failure m bytes
-> (forall pr (stA :: psA). PeerHasAgency pr stA -> SamePeerHasAgency pr psB)
-> AnyMessageAndAgency psA
-> m Bool
prop_codec_binary_compatM :: Codec psA failure m bytes
-> Codec psB failure m bytes
-> (forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB)
-> AnyMessageAndAgency psA
-> m Bool
prop_codec_binary_compatM
Codec psA failure m bytes
codecA Codec psB failure m bytes
codecB forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB
stokEq
(AnyMessageAndAgency (PeerHasAgency pr st
stokA :: PeerHasAgency pr stA) Message psA st st'
msgA) =
case PeerHasAgency pr st -> SamePeerHasAgency pr psB
forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB
stokEq PeerHasAgency pr st
stokA of
SamePeerHasAgency PeerHasAgency pr st
stokB -> do
let bytesA :: bytes
bytesA = Codec psA failure m bytes
-> PeerHasAgency pr st -> Message psA st st' -> bytes
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode Codec psA failure m bytes
codecA PeerHasAgency pr st
stokA Message psA st st'
msgA
Either failure (SomeMessage st)
r1 <- Codec psB failure m bytes
-> PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode Codec psB failure m bytes
codecB PeerHasAgency pr st
stokB m (DecodeStep bytes failure m (SomeMessage st))
-> (DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st)))
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes]
-> DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [bytes
bytesA]
case Either failure (SomeMessage st)
r1 of
Left failure
_ -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
Right (SomeMessage Message psB st st'
msgB) -> do
let bytesB :: bytes
bytesB = Codec psB failure m bytes
-> PeerHasAgency pr st -> Message psB st st' -> bytes
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode Codec psB failure m bytes
codecB PeerHasAgency pr st
stokB Message psB st st'
msgB
Either failure (SomeMessage st)
r2 <- Codec psA failure m bytes
-> PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode Codec psA failure m bytes
codecA PeerHasAgency pr st
stokA m (DecodeStep bytes failure m (SomeMessage st))
-> (DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st)))
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes]
-> DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [bytes
bytesB]
case Either failure (SomeMessage st)
r2 of
Left failure
_ -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
Right (SomeMessage Message psA st st'
msgA') -> Bool -> m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> m Bool) -> Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ Message psA st st' -> AnyMessage psA
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message psA st st'
msgA' AnyMessage psA -> AnyMessage psA -> Bool
forall a. Eq a => a -> a -> Bool
== Message psA st st' -> AnyMessage psA
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message psA st st'
msgA
prop_codec_binary_compat
:: forall psA psB failure m bytes.
( Monad m
, Eq (AnyMessage psA)
)
=> (forall a. m a -> a)
-> Codec psA failure m bytes
-> Codec psB failure m bytes
-> (forall pr (stA :: psA). PeerHasAgency pr stA -> SamePeerHasAgency pr psB)
-> AnyMessageAndAgency psA
-> Bool
prop_codec_binary_compat :: (forall a. m a -> a)
-> Codec psA failure m bytes
-> Codec psB failure m bytes
-> (forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB)
-> AnyMessageAndAgency psA
-> Bool
prop_codec_binary_compat forall a. m a -> a
runM Codec psA failure m bytes
codecA Codec psB failure m bytes
codecB forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB
stokEq AnyMessageAndAgency psA
msgA =
m Bool -> Bool
forall a. m a -> a
runM (m Bool -> Bool) -> m Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Codec psA failure m bytes
-> Codec psB failure m bytes
-> (forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB)
-> AnyMessageAndAgency psA
-> m Bool
forall psA psB failure (m :: * -> *) bytes.
(Monad m, Eq (AnyMessage psA)) =>
Codec psA failure m bytes
-> Codec psB failure m bytes
-> (forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB)
-> AnyMessageAndAgency psA
-> m Bool
prop_codec_binary_compatM Codec psA failure m bytes
codecA Codec psB failure m bytes
codecB forall (pr :: PeerRole) (stA :: psA).
PeerHasAgency pr stA -> SamePeerHasAgency pr psB
stokEq AnyMessageAndAgency psA
msgA
prop_codecs_compatM
:: forall ps failure m bytes.
( Monad m
, Eq (AnyMessage ps)
, forall a. Monoid a => Monoid (m a)
)
=> Codec ps failure m bytes
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> m Bool
prop_codecs_compatM :: Codec ps failure m bytes
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
prop_codecs_compatM Codec ps failure m bytes
codecA Codec ps failure m bytes
codecB
(AnyMessageAndAgency PeerHasAgency pr st
stok Message ps st st'
msg) =
All -> Bool
getAll (All -> Bool) -> m All -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do Either failure (SomeMessage st)
r <- Codec ps failure m bytes
-> PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode Codec ps failure m bytes
codecB PeerHasAgency pr st
stok m (DecodeStep bytes failure m (SomeMessage st))
-> (DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st)))
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes]
-> DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [Codec ps failure m bytes
-> PeerHasAgency pr st -> Message ps st st' -> bytes
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode Codec ps failure m bytes
codecA PeerHasAgency pr st
stok Message ps st st'
msg]
case Either failure (SomeMessage st)
r of
Right (SomeMessage Message ps st st'
msg') -> All -> m All
forall (m :: * -> *) a. Monad m => a -> m a
return (All -> m All) -> All -> m All
forall a b. (a -> b) -> a -> b
$ Bool -> All
All (Bool -> All) -> Bool -> All
forall a b. (a -> b) -> a -> b
$ Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg' AnyMessage ps -> AnyMessage ps -> Bool
forall a. Eq a => a -> a -> Bool
== Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg
Left failure
_ -> All -> m All
forall (m :: * -> *) a. Monad m => a -> m a
return (All -> m All) -> All -> m All
forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
False
m All -> m All -> m All
forall a. Semigroup a => a -> a -> a
<> do Either failure (SomeMessage st)
r <- Codec ps failure m bytes
-> PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps).
PeerHasAgency pr st
-> m (DecodeStep bytes failure m (SomeMessage st))
decode Codec ps failure m bytes
codecA PeerHasAgency pr st
stok m (DecodeStep bytes failure m (SomeMessage st))
-> (DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st)))
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [bytes]
-> DecodeStep bytes failure m (SomeMessage st)
-> m (Either failure (SomeMessage st))
forall (m :: * -> *) bytes failure a.
Monad m =>
[bytes] -> DecodeStep bytes failure m a -> m (Either failure a)
runDecoder [Codec ps failure m bytes
-> PeerHasAgency pr st -> Message ps st st' -> bytes
forall ps failure (m :: * -> *) bytes.
Codec ps failure m bytes
-> forall (pr :: PeerRole) (st :: ps) (st' :: ps).
PeerHasAgency pr st -> Message ps st st' -> bytes
encode Codec ps failure m bytes
codecB PeerHasAgency pr st
stok Message ps st st'
msg]
case Either failure (SomeMessage st)
r of
Right (SomeMessage Message ps st st'
msg') -> All -> m All
forall (m :: * -> *) a. Monad m => a -> m a
return (All -> m All) -> All -> m All
forall a b. (a -> b) -> a -> b
$ Bool -> All
All (Bool -> All) -> Bool -> All
forall a b. (a -> b) -> a -> b
$ Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg' AnyMessage ps -> AnyMessage ps -> Bool
forall a. Eq a => a -> a -> Bool
== Message ps st st' -> AnyMessage ps
forall ps (st :: ps) (st' :: ps).
Message ps st st' -> AnyMessage ps
AnyMessage Message ps st st'
msg
Left failure
_ -> All -> m All
forall (m :: * -> *) a. Monad m => a -> m a
return (All -> m All) -> All -> m All
forall a b. (a -> b) -> a -> b
$ Bool -> All
All Bool
False
prop_codecs_compat
:: forall ps failure m bytes.
( Monad m
, Eq (AnyMessage ps)
, forall a. Monoid a => Monoid (m a)
)
=> (forall a. m a -> a)
-> Codec ps failure m bytes
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> Bool
prop_codecs_compat :: (forall a. m a -> a)
-> Codec ps failure m bytes
-> Codec ps failure m bytes
-> AnyMessageAndAgency ps
-> Bool
prop_codecs_compat forall a. m a -> a
run Codec ps failure m bytes
codecA Codec ps failure m bytes
codecB AnyMessageAndAgency ps
msg =
m Bool -> Bool
forall a. m a -> a
run (m Bool -> Bool) -> m Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Codec ps failure m bytes
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
forall ps failure (m :: * -> *) bytes.
(Monad m, Eq (AnyMessage ps),
forall a. Monoid a => Monoid (m a)) =>
Codec ps failure m bytes
-> Codec ps failure m bytes -> AnyMessageAndAgency ps -> m Bool
prop_codecs_compatM Codec ps failure m bytes
codecA Codec ps failure m bytes
codecB AnyMessageAndAgency ps
msg