{-# LANGUAGE DeriveFoldable             #-}
{-# LANGUAGE DeriveFunctor              #-}
{-# LANGUAGE DeriveTraversable          #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MonoLocalBinds             #-}
{-# LANGUAGE Rank2Types                 #-}
{-# LANGUAGE StandaloneDeriving         #-}
{-# LANGUAGE UndecidableInstances       #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Test.StateMachine.Types
-- Copyright   :  (C) 2017, ATS Advanced Telematic Systems GmbH
-- License     :  BSD-style (see the file LICENSE)
--
-- Maintainer  :  Stevan Andjelkovic <stevan.andjelkovic@strath.ac.uk>
-- Stability   :  provisional
-- Portability :  non-portable (GHC extensions)
--
-----------------------------------------------------------------------------

module Test.StateMachine.Types
  ( StateMachine(..)
  , Command(..)
  , getCommand
  , Commands(..)
  , NParallelCommands
  , lengthCommands
  , ParallelCommandsF(..)
  , ParallelCommands
  , Pair(..)
  , fromPair
  , toPair
  , fromPair'
  , toPairUnsafe'
  , Reason(..)
  , isOK
  , noCleanup
  , module Test.StateMachine.Types.Environment
  , module Test.StateMachine.Types.GenSym
  , module Test.StateMachine.Types.History
  , module Test.StateMachine.Types.References
  ) where

import           Data.Functor.Classes
                   (Ord1, Show1)
import           Data.Semigroup
import           Prelude
import           Test.QuickCheck
                   (Gen)

import           Test.StateMachine.Logic
import           Test.StateMachine.Types.Environment
import           Test.StateMachine.Types.GenSym
import           Test.StateMachine.Types.History
import           Test.StateMachine.Types.References

------------------------------------------------------------------------

data StateMachine model cmd m resp = StateMachine
  { StateMachine model cmd m resp -> forall (r :: * -> *). model r
initModel      :: forall r. model r
  , StateMachine model cmd m resp
-> forall (r :: * -> *).
   (Show1 r, Ord1 r) =>
   model r -> cmd r -> resp r -> model r
transition     :: forall r. (Show1 r, Ord1 r) => model r -> cmd r -> resp r -> model r
  , StateMachine model cmd m resp
-> model Symbolic -> cmd Symbolic -> Logic
precondition   :: model Symbolic -> cmd Symbolic -> Logic
  , StateMachine model cmd m resp
-> model Concrete -> cmd Concrete -> resp Concrete -> Logic
postcondition  :: model Concrete -> cmd Concrete -> resp Concrete -> Logic
  , StateMachine model cmd m resp -> Maybe (model Concrete -> Logic)
invariant      :: Maybe (model Concrete -> Logic)
  , StateMachine model cmd m resp
-> model Symbolic -> Maybe (Gen (cmd Symbolic))
generator      :: model Symbolic -> Maybe (Gen (cmd Symbolic))
  , StateMachine model cmd m resp
-> model Symbolic -> cmd Symbolic -> [cmd Symbolic]
shrinker       :: model Symbolic -> cmd Symbolic -> [cmd Symbolic]
  , StateMachine model cmd m resp -> cmd Concrete -> m (resp Concrete)
semantics      :: cmd Concrete -> m (resp Concrete)
  , StateMachine model cmd m resp
-> model Symbolic -> cmd Symbolic -> GenSym (resp Symbolic)
mock           :: model Symbolic -> cmd Symbolic -> GenSym (resp Symbolic)
  , StateMachine model cmd m resp -> model Concrete -> m ()
cleanup        :: model Concrete -> m ()
  }

noCleanup :: Monad m => model Concrete -> m ()
noCleanup :: model Concrete -> m ()
noCleanup model Concrete
_ = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

-- | Previously symbolically executed command
--
-- Invariant: the variables must be the variables in the response.
data Command cmd resp = Command !(cmd Symbolic) !(resp Symbolic) ![Var]

getCommand :: Command cmd resp -> cmd Symbolic
getCommand :: Command cmd resp -> cmd Symbolic
getCommand (Command cmd Symbolic
cmd resp Symbolic
_resp [Var]
_vars) = cmd Symbolic
cmd

deriving
  stock
  instance (Show (cmd Symbolic), Show (resp Symbolic)) => Show (Command cmd resp)

deriving
  stock
  instance (Read (cmd Symbolic), Read (resp Symbolic)) => Read (Command cmd resp)

deriving
  stock
  instance ((Eq (cmd Symbolic)), (Eq (resp Symbolic))) => Eq (Command cmd resp)

newtype Commands cmd resp = Commands
  { Commands cmd resp -> [Command cmd resp]
unCommands :: [Command cmd resp] }
  deriving newtype (b -> Commands cmd resp -> Commands cmd resp
NonEmpty (Commands cmd resp) -> Commands cmd resp
Commands cmd resp -> Commands cmd resp -> Commands cmd resp
(Commands cmd resp -> Commands cmd resp -> Commands cmd resp)
-> (NonEmpty (Commands cmd resp) -> Commands cmd resp)
-> (forall b.
    Integral b =>
    b -> Commands cmd resp -> Commands cmd resp)
-> Semigroup (Commands cmd resp)
forall b. Integral b => b -> Commands cmd resp -> Commands cmd resp
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
NonEmpty (Commands cmd resp) -> Commands cmd resp
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp -> Commands cmd resp -> Commands cmd resp
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *) b.
Integral b =>
b -> Commands cmd resp -> Commands cmd resp
stimes :: b -> Commands cmd resp -> Commands cmd resp
$cstimes :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *) b.
Integral b =>
b -> Commands cmd resp -> Commands cmd resp
sconcat :: NonEmpty (Commands cmd resp) -> Commands cmd resp
$csconcat :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
NonEmpty (Commands cmd resp) -> Commands cmd resp
<> :: Commands cmd resp -> Commands cmd resp -> Commands cmd resp
$c<> :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp -> Commands cmd resp -> Commands cmd resp
Semigroup, Semigroup (Commands cmd resp)
Commands cmd resp
Semigroup (Commands cmd resp)
-> Commands cmd resp
-> (Commands cmd resp -> Commands cmd resp -> Commands cmd resp)
-> ([Commands cmd resp] -> Commands cmd resp)
-> Monoid (Commands cmd resp)
[Commands cmd resp] -> Commands cmd resp
Commands cmd resp -> Commands cmd resp -> Commands cmd resp
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Semigroup (Commands cmd resp)
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
[Commands cmd resp] -> Commands cmd resp
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp -> Commands cmd resp -> Commands cmd resp
mconcat :: [Commands cmd resp] -> Commands cmd resp
$cmconcat :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
[Commands cmd resp] -> Commands cmd resp
mappend :: Commands cmd resp -> Commands cmd resp -> Commands cmd resp
$cmappend :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp -> Commands cmd resp -> Commands cmd resp
mempty :: Commands cmd resp
$cmempty :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp
$cp1Monoid :: forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Semigroup (Commands cmd resp)
Monoid)

deriving
  stock
  instance (Show (cmd Symbolic), Show (resp Symbolic)) => Show (Commands cmd resp)

deriving
  stock
  instance (Read (cmd Symbolic), Read (resp Symbolic)) => Read (Commands cmd resp)

deriving
  stock
  instance ((Eq (cmd Symbolic)), (Eq (resp Symbolic))) => Eq (Commands cmd resp)

lengthCommands :: Commands cmd resp -> Int
lengthCommands :: Commands cmd resp -> Int
lengthCommands = [Command cmd resp] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([Command cmd resp] -> Int)
-> (Commands cmd resp -> [Command cmd resp])
-> Commands cmd resp
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Commands cmd resp -> [Command cmd resp]
forall (cmd :: (* -> *) -> *) (resp :: (* -> *) -> *).
Commands cmd resp -> [Command cmd resp]
unCommands

data Reason
  = Ok
  | PreconditionFailed String
  | PostconditionFailed String
  | InvariantBroken String
  | ExceptionThrown String
  | MockSemanticsMismatch
  deriving stock (Reason -> Reason -> Bool
(Reason -> Reason -> Bool)
-> (Reason -> Reason -> Bool) -> Eq Reason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Reason -> Reason -> Bool
$c/= :: Reason -> Reason -> Bool
== :: Reason -> Reason -> Bool
$c== :: Reason -> Reason -> Bool
Eq, Int -> Reason -> ShowS
[Reason] -> ShowS
Reason -> String
(Int -> Reason -> ShowS)
-> (Reason -> String) -> ([Reason] -> ShowS) -> Show Reason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Reason] -> ShowS
$cshowList :: [Reason] -> ShowS
show :: Reason -> String
$cshow :: Reason -> String
showsPrec :: Int -> Reason -> ShowS
$cshowsPrec :: Int -> Reason -> ShowS
Show)

isOK :: Reason -> Bool
isOK :: Reason -> Bool
isOK Reason
Ok = Bool
True
isOK Reason
_  = Bool
False

data ParallelCommandsF t cmd resp = ParallelCommands
  { ParallelCommandsF t cmd resp -> Commands cmd resp
prefix   :: !(Commands cmd resp)
  , ParallelCommandsF t cmd resp -> [t (Commands cmd resp)]
suffixes :: [t (Commands cmd resp)]
  }

deriving
  stock
  instance (Eq (cmd Symbolic), Eq (resp Symbolic), Eq (t (Commands cmd resp)))
  => Eq (ParallelCommandsF t cmd resp)

deriving
  stock
  instance (Show (cmd Symbolic), Show (resp Symbolic), Show (t (Commands cmd resp)))
  => Show (ParallelCommandsF t cmd resp)

data Pair a = Pair
  { Pair a -> a
proj1 :: !a
  , Pair a -> a
proj2 :: !a
  }
  deriving stock (Pair a -> Pair a -> Bool
(Pair a -> Pair a -> Bool)
-> (Pair a -> Pair a -> Bool) -> Eq (Pair a)
forall a. Eq a => Pair a -> Pair a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pair a -> Pair a -> Bool
$c/= :: forall a. Eq a => Pair a -> Pair a -> Bool
== :: Pair a -> Pair a -> Bool
$c== :: forall a. Eq a => Pair a -> Pair a -> Bool
Eq, Eq (Pair a)
Eq (Pair a)
-> (Pair a -> Pair a -> Ordering)
-> (Pair a -> Pair a -> Bool)
-> (Pair a -> Pair a -> Bool)
-> (Pair a -> Pair a -> Bool)
-> (Pair a -> Pair a -> Bool)
-> (Pair a -> Pair a -> Pair a)
-> (Pair a -> Pair a -> Pair a)
-> Ord (Pair a)
Pair a -> Pair a -> Bool
Pair a -> Pair a -> Ordering
Pair a -> Pair a -> Pair a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Pair a)
forall a. Ord a => Pair a -> Pair a -> Bool
forall a. Ord a => Pair a -> Pair a -> Ordering
forall a. Ord a => Pair a -> Pair a -> Pair a
min :: Pair a -> Pair a -> Pair a
$cmin :: forall a. Ord a => Pair a -> Pair a -> Pair a
max :: Pair a -> Pair a -> Pair a
$cmax :: forall a. Ord a => Pair a -> Pair a -> Pair a
>= :: Pair a -> Pair a -> Bool
$c>= :: forall a. Ord a => Pair a -> Pair a -> Bool
> :: Pair a -> Pair a -> Bool
$c> :: forall a. Ord a => Pair a -> Pair a -> Bool
<= :: Pair a -> Pair a -> Bool
$c<= :: forall a. Ord a => Pair a -> Pair a -> Bool
< :: Pair a -> Pair a -> Bool
$c< :: forall a. Ord a => Pair a -> Pair a -> Bool
compare :: Pair a -> Pair a -> Ordering
$ccompare :: forall a. Ord a => Pair a -> Pair a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Pair a)
Ord, Int -> Pair a -> ShowS
[Pair a] -> ShowS
Pair a -> String
(Int -> Pair a -> ShowS)
-> (Pair a -> String) -> ([Pair a] -> ShowS) -> Show (Pair a)
forall a. Show a => Int -> Pair a -> ShowS
forall a. Show a => [Pair a] -> ShowS
forall a. Show a => Pair a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Pair a] -> ShowS
$cshowList :: forall a. Show a => [Pair a] -> ShowS
show :: Pair a -> String
$cshow :: forall a. Show a => Pair a -> String
showsPrec :: Int -> Pair a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Pair a -> ShowS
Show, a -> Pair b -> Pair a
(a -> b) -> Pair a -> Pair b
(forall a b. (a -> b) -> Pair a -> Pair b)
-> (forall a b. a -> Pair b -> Pair a) -> Functor Pair
forall a b. a -> Pair b -> Pair a
forall a b. (a -> b) -> Pair a -> Pair b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> Pair b -> Pair a
$c<$ :: forall a b. a -> Pair b -> Pair a
fmap :: (a -> b) -> Pair a -> Pair b
$cfmap :: forall a b. (a -> b) -> Pair a -> Pair b
Functor, Pair a -> Bool
(a -> m) -> Pair a -> m
(a -> b -> b) -> b -> Pair a -> b
(forall m. Monoid m => Pair m -> m)
-> (forall m a. Monoid m => (a -> m) -> Pair a -> m)
-> (forall m a. Monoid m => (a -> m) -> Pair a -> m)
-> (forall a b. (a -> b -> b) -> b -> Pair a -> b)
-> (forall a b. (a -> b -> b) -> b -> Pair a -> b)
-> (forall b a. (b -> a -> b) -> b -> Pair a -> b)
-> (forall b a. (b -> a -> b) -> b -> Pair a -> b)
-> (forall a. (a -> a -> a) -> Pair a -> a)
-> (forall a. (a -> a -> a) -> Pair a -> a)
-> (forall a. Pair a -> [a])
-> (forall a. Pair a -> Bool)
-> (forall a. Pair a -> Int)
-> (forall a. Eq a => a -> Pair a -> Bool)
-> (forall a. Ord a => Pair a -> a)
-> (forall a. Ord a => Pair a -> a)
-> (forall a. Num a => Pair a -> a)
-> (forall a. Num a => Pair a -> a)
-> Foldable Pair
forall a. Eq a => a -> Pair a -> Bool
forall a. Num a => Pair a -> a
forall a. Ord a => Pair a -> a
forall m. Monoid m => Pair m -> m
forall a. Pair a -> Bool
forall a. Pair a -> Int
forall a. Pair a -> [a]
forall a. (a -> a -> a) -> Pair a -> a
forall m a. Monoid m => (a -> m) -> Pair a -> m
forall b a. (b -> a -> b) -> b -> Pair a -> b
forall a b. (a -> b -> b) -> b -> Pair a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: Pair a -> a
$cproduct :: forall a. Num a => Pair a -> a
sum :: Pair a -> a
$csum :: forall a. Num a => Pair a -> a
minimum :: Pair a -> a
$cminimum :: forall a. Ord a => Pair a -> a
maximum :: Pair a -> a
$cmaximum :: forall a. Ord a => Pair a -> a
elem :: a -> Pair a -> Bool
$celem :: forall a. Eq a => a -> Pair a -> Bool
length :: Pair a -> Int
$clength :: forall a. Pair a -> Int
null :: Pair a -> Bool
$cnull :: forall a. Pair a -> Bool
toList :: Pair a -> [a]
$ctoList :: forall a. Pair a -> [a]
foldl1 :: (a -> a -> a) -> Pair a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Pair a -> a
foldr1 :: (a -> a -> a) -> Pair a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Pair a -> a
foldl' :: (b -> a -> b) -> b -> Pair a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Pair a -> b
foldl :: (b -> a -> b) -> b -> Pair a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Pair a -> b
foldr' :: (a -> b -> b) -> b -> Pair a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Pair a -> b
foldr :: (a -> b -> b) -> b -> Pair a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Pair a -> b
foldMap' :: (a -> m) -> Pair a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Pair a -> m
foldMap :: (a -> m) -> Pair a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Pair a -> m
fold :: Pair m -> m
$cfold :: forall m. Monoid m => Pair m -> m
Foldable, Functor Pair
Foldable Pair
Functor Pair
-> Foldable Pair
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> Pair a -> f (Pair b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Pair (f a) -> f (Pair a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Pair a -> m (Pair b))
-> (forall (m :: * -> *) a. Monad m => Pair (m a) -> m (Pair a))
-> Traversable Pair
(a -> f b) -> Pair a -> f (Pair b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Pair (m a) -> m (Pair a)
forall (f :: * -> *) a. Applicative f => Pair (f a) -> f (Pair a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Pair a -> m (Pair b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Pair a -> f (Pair b)
sequence :: Pair (m a) -> m (Pair a)
$csequence :: forall (m :: * -> *) a. Monad m => Pair (m a) -> m (Pair a)
mapM :: (a -> m b) -> Pair a -> m (Pair b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Pair a -> m (Pair b)
sequenceA :: Pair (f a) -> f (Pair a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => Pair (f a) -> f (Pair a)
traverse :: (a -> f b) -> Pair a -> f (Pair b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Pair a -> f (Pair b)
$cp2Traversable :: Foldable Pair
$cp1Traversable :: Functor Pair
Traversable)

fromPair :: Pair a -> (a, a)
fromPair :: Pair a -> (a, a)
fromPair (Pair a
x a
y) = (a
x, a
y)

toPair :: (a, a) -> Pair a
toPair :: (a, a) -> Pair a
toPair (a
x, a
y) = a -> a -> Pair a
forall a. a -> a -> Pair a
Pair a
x a
y

type ParallelCommands = ParallelCommandsF Pair

type NParallelCommands = ParallelCommandsF []

fromPair' :: ParallelCommandsF Pair cmd resp -> ParallelCommandsF [] cmd resp
fromPair' :: ParallelCommandsF Pair cmd resp -> ParallelCommandsF [] cmd resp
fromPair' ParallelCommandsF Pair cmd resp
p = ParallelCommandsF Pair cmd resp
p { suffixes :: [[Commands cmd resp]]
suffixes = (\(Pair Commands cmd resp
l Commands cmd resp
r) -> [Commands cmd resp
l, Commands cmd resp
r]) (Pair (Commands cmd resp) -> [Commands cmd resp])
-> [Pair (Commands cmd resp)] -> [[Commands cmd resp]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParallelCommandsF Pair cmd resp -> [Pair (Commands cmd resp)]
forall (t :: * -> *) (cmd :: (* -> *) -> *)
       (resp :: (* -> *) -> *).
ParallelCommandsF t cmd resp -> [t (Commands cmd resp)]
suffixes ParallelCommandsF Pair cmd resp
p}

toPairUnsafe' :: ParallelCommandsF [] cmd resp -> ParallelCommandsF Pair cmd resp
toPairUnsafe' :: ParallelCommandsF [] cmd resp -> ParallelCommandsF Pair cmd resp
toPairUnsafe' ParallelCommandsF [] cmd resp
p = ParallelCommandsF [] cmd resp
p { suffixes :: [Pair (Commands cmd resp)]
suffixes = [Commands cmd resp] -> Pair (Commands cmd resp)
forall a. [a] -> Pair a
unsafePair ([Commands cmd resp] -> Pair (Commands cmd resp))
-> [[Commands cmd resp]] -> [Pair (Commands cmd resp)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParallelCommandsF [] cmd resp -> [[Commands cmd resp]]
forall (t :: * -> *) (cmd :: (* -> *) -> *)
       (resp :: (* -> *) -> *).
ParallelCommandsF t cmd resp -> [t (Commands cmd resp)]
suffixes ParallelCommandsF [] cmd resp
p}
    where
      unsafePair :: [a] -> Pair a
unsafePair [a
a,a
b] = a -> a -> Pair a
forall a. a -> a -> Pair a
Pair a
a a
b
      unsafePair [a]
_ = String -> Pair a
forall a. HasCallStack => String -> a
error String
"invariant violation! Shrunk list should always have 2 elements."