Safe Haskell | None |
---|---|
Language | Haskell2010 |
The project operates as follows:
Given two peers A and B and some communications transport T (utilizing a serialization format S), and a data type Q with some set of operations on that data type Op_Q, the following functions / procedures are assumed:
tAB: the function communicates some data in S from peer A to peer B tBA: the function communicates some data in S from peer B to peer A encode :: Q -> S decode :: S -> Q -- disregarding error handling
And the following property should exist, from peer A's perspective:
forall f in Op_Q, q in Q. f q == decode (tBA (f (tAB (encode q)))
where the left invocation of f occurs in peer A, and the right invocation occurs in peer B.
Synopsis
- class SymbioteOperation a where
- class SymbioteOperation a => Symbiote a s where
- newtype EitherOp a = EitherOp (Either a (Operation a))
- data Topic
- type SymbioteT s m = ReaderT Bool (StateT (Map Topic (SymbioteState s)) m)
- register :: forall a s m. Arbitrary a => Arbitrary (Operation a) => Symbiote a s => Eq a => MonadIO m => Topic -> Int -> Proxy a -> SymbioteT s m ()
- firstPeer :: forall m s. MonadIO m => Show s => (First s -> m ()) -> m (Second s) -> (Topic -> m ()) -> (Failure Second s -> m ()) -> (Topic -> Float -> m ()) -> SymbioteT s m () -> m ()
- secondPeer :: forall s m. MonadIO m => Show s => (Second s -> m ()) -> m (First s) -> (Topic -> m ()) -> (Failure First s -> m ()) -> (Topic -> Float -> m ()) -> SymbioteT s m () -> m ()
- data First s
- = AvailableTopics (Map Topic Int)
- | FirstGenerating { }
- | FirstOperating { }
- data Second s
- = BadTopics (Map Topic Int)
- | Start
- | SecondOperating { }
- | SecondGenerating { }
- data Generating s
- = Generated {
- genValue :: s
- genOperation :: s
- | BadResult s
- | YourTurn
- | ImFinished
- | GeneratingNoParseOperated s
- = Generated {
- data Operating s
- data Failure them s
- = BadTopicsFailure { }
- | OutOfSyncFirst (First s)
- | OutOfSyncSecond (Second s)
- | TopicNonexistent Topic
- | WrongTopic { }
- | CantParseOperated Topic s
- | CantParseGeneratedValue Topic s
- | CantParseGeneratedOperation Topic s
- | CantParseLocalValue Topic s
- | CantParseLocalOperation Topic s
- | BadOperating Topic (Operating s)
- | BadGenerating Topic (Generating s)
- | BadThem Topic (them s)
- | SafeFailure {
- safeFailureTopic :: Topic
- safeFailureExpected :: s
- safeFailureGot :: s
- defaultSuccess :: Topic -> IO ()
- defaultFailure :: Show (them s) => Show s => Failure them s -> IO ()
- defaultProgress :: Topic -> Float -> IO ()
- nullProgress :: Topic -> Float -> IO ()
- simpleTest :: MonadBaseControl IO m => MonadIO m => Show s => SymbioteT s m () -> m ()
Documentation
class SymbioteOperation a where Source #
class SymbioteOperation a => Symbiote a s where Source #
A type and operation set over a serialization format
Instances
(ToJSON a, FromJSON a, ToJSON (Operation a), FromJSON (Operation a), SymbioteOperation a) => Symbiote a Value Source # | |
(Serialize a, Serialize (Operation a), SymbioteOperation a) => Symbiote a ByteString Source # | |
Defined in Test.Serialization.Symbiote.Cereal encode :: a -> ByteString Source # decode :: ByteString -> Maybe a Source # encodeOp :: Operation a -> ByteString Source # | |
(Serialize a, Serialize (Operation a), SymbioteOperation a) => Symbiote a ByteString Source # | |
Defined in Test.Serialization.Symbiote.Cereal.Lazy encode :: a -> ByteString Source # decode :: ByteString -> Maybe a Source # encodeOp :: Operation a -> ByteString Source # | |
SymbioteOperation a => Symbiote a (EitherOp a) Source # | |
The most trivial serialization medium for any a
.
Unique name of a type, for a suite of tests
:: Arbitrary a | |
=> Arbitrary (Operation a) | |
=> Symbiote a s | |
=> Eq a | |
=> MonadIO m | |
=> Topic | |
-> Int | Max size |
-> Proxy a | |
-> SymbioteT s m () |
Register a topic in the test suite
Messages sent by the first peer
AvailableTopics (Map Topic Int) | Mapping of topics to their gen size |
FirstGenerating | |
FirstOperating | |
Messages sent by the second peer
BadTopics (Map Topic Int) | Second's available topics with identical gen sizes |
Start | |
SecondOperating | |
SecondGenerating | |
data Generating s Source #
Messages sent by a peer during their generating phase
Generated | |
| |
BadResult s | Expected value |
YourTurn | |
ImFinished | |
GeneratingNoParseOperated s |
Instances
Eq s => Eq (Generating s) Source # | |
Defined in Test.Serialization.Symbiote (==) :: Generating s -> Generating s -> Bool # (/=) :: Generating s -> Generating s -> Bool # | |
Show s => Show (Generating s) Source # | |
Defined in Test.Serialization.Symbiote showsPrec :: Int -> Generating s -> ShowS # show :: Generating s -> String # showList :: [Generating s] -> ShowS # |
Messages sent by a peer during their operating phase
Operated s | Serialized value after operation |
OperatingNoParseValue s | |
OperatingNoParseOperation s |
defaultSuccess :: Topic -> IO () Source #
Via putStrLn
simpleTest :: MonadBaseControl IO m => MonadIO m => Show s => SymbioteT s m () -> m () Source #
Prints to stdout and uses a local channel for a sanity-check - doesn't serialize.