Skip to content

Commit ca10200

Browse files
committed
Add Show requirement on Action results
1 parent 25c621b commit ca10200

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ instance Monad (DL s) where
6060
instance MonadFail (DL s) where
6161
fail = errorDL
6262

63-
action :: (Typeable a, Eq (Action s a), Show (Action s a)) => Action s a -> DL s (Var a)
63+
action :: (Typeable a, Show a, Eq (Action s a), Show (Action s a)) => Action s a -> DL s (Var a)
6464
action cmd = DL $ \_ k -> DL.after cmd k
6565

66-
failingAction :: (Typeable a, Eq (Action s a), Show (Action s a)) => Action s a -> DL s ()
66+
failingAction :: (Typeable a, Show a, Eq (Action s a), Show (Action s a)) => Action s a -> DL s ()
6767
failingAction cmd = DL $ \_ k -> DL.afterNegative cmd (k ())
6868

6969
anyAction :: DL s ()
@@ -96,7 +96,7 @@ getModelStateDL = DL $ \s k -> k (underlyingState s) s
9696
getVarContextDL :: DL s VarContext
9797
getVarContextDL = DL $ \s k -> k (vars s) s
9898

99-
forAllVar :: forall a s. Typeable a => DL s (Var a)
99+
forAllVar :: forall a s. (Typeable a, Show a) => DL s (Var a)
100100
forAllVar = do
101101
xs <- ctxAtType <$> getVarContextDL
102102
forAllQ $ elementsQ xs

quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic/Internal.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ data DynLogic s
3333
Stopping (DynLogic s)
3434
| -- | After a specific action the predicate should hold
3535
forall a.
36-
(Eq (Action s a), Show (Action s a), Typeable a) =>
36+
(Eq (Action s a), Show (Action s a), Typeable a, Show a) =>
3737
After (ActionWithPolarity s a) (Var a -> DynPred s)
3838
| Error String (DynPred s)
3939
| -- | Adjust the probability of picking a branch
@@ -66,7 +66,7 @@ afterAny :: (Annotated s -> DynFormula s) -> DynFormula s
6666
afterAny f = DynFormula $ \n -> AfterAny $ \s -> unDynFormula (f s) n
6767

6868
afterPolar
69-
:: (Typeable a, Eq (Action s a), Show (Action s a))
69+
:: (Typeable a, Show a, Eq (Action s a), Show (Action s a))
7070
=> ActionWithPolarity s a
7171
-> (Var a -> Annotated s -> DynFormula s)
7272
-> DynFormula s
@@ -75,7 +75,7 @@ afterPolar act f = DynFormula $ \n -> After act $ \x s -> unDynFormula (f x s) n
7575
-- | Given `f` must be `True` after /some/ action.
7676
-- `f` is passed the state resulting from executing the `Action`.
7777
after
78-
:: (Typeable a, Eq (Action s a), Show (Action s a))
78+
:: (Typeable a, Show a, Eq (Action s a), Show (Action s a))
7979
=> Action s a
8080
-> (Var a -> Annotated s -> DynFormula s)
8181
-> DynFormula s
@@ -85,7 +85,7 @@ after act f = afterPolar (ActionWithPolarity act PosPolarity) f
8585
-- `f` is passed the state resulting from executing the `Action`
8686
-- as a negative action.
8787
afterNegative
88-
:: (Typeable a, Eq (Action s a), Show (Action s a))
88+
:: (Typeable a, Show a, Eq (Action s a), Show (Action s a))
8989
=> Action s a
9090
-> (Annotated s -> DynFormula s)
9191
-> DynFormula s

quickcheck-dynamic/src/Test/QuickCheck/StateModel.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ deriving instance Eq (Action state a) => Eq (ActionWithPolarity state a)
320320

321321
data Step state where
322322
(:=)
323-
:: (Typeable a, Eq (Action state a), Show (Action state a))
323+
:: (Typeable a, Show a, Eq (Action state a), Show (Action state a))
324324
=> Var a
325325
-> ActionWithPolarity state a
326326
-> Step state
@@ -515,7 +515,7 @@ computePrecondition s (ActionWithPolarity a p) =
515515
&& polarPrecondition
516516

517517
computeNextState
518-
:: (StateModel state, Typeable a)
518+
:: (StateModel state, Typeable a, Show a)
519519
=> Annotated state
520520
-> ActionWithPolarity state a
521521
-> Var a
@@ -750,7 +750,7 @@ genParActions = do
750750
_ -> error "I'm the pope"
751751

752752
data TraceStep state m where
753-
TraceStep :: (Typeable a)
753+
TraceStep :: (Typeable a, Show a)
754754
=> Either (Error state m) a
755755
-> Var a
756756
-> ActionWithPolarity state a

quickcheck-dynamic/src/Test/QuickCheck/StateModel/Variables.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class HasVariables a where
5959
instance HasVariables a => HasVariables (Smart a) where
6060
getAllVariables (Smart _ a) = getAllVariables a
6161

62-
instance Typeable a => HasVariables (Var a) where
62+
instance (Typeable a, Show a) => HasVariables (Var a) where
6363
getAllVariables = Set.singleton . Some
6464

6565
instance (HasVariables k, HasVariables v) => HasVariables (Map k v) where
@@ -88,7 +88,7 @@ deriving via HasNoVariables Word32 instance HasVariables Word32
8888
deriving via HasNoVariables Word64 instance HasVariables Word64
8989

9090
data Any f where
91-
Some :: (Typeable a, Eq (f a)) => f a -> Any f
91+
Some :: (Typeable a, Show a, Eq (f a)) => f a -> Any f
9292

9393
instance Eq (Any f) where
9494
Some (a :: f a) == Some (b :: f b) =
@@ -117,7 +117,7 @@ instance Show VarContext where
117117
isEmptyCtx :: VarContext -> Bool
118118
isEmptyCtx (VarCtx ctx) = null ctx
119119

120-
isWellTyped :: Typeable a => Var a -> VarContext -> Bool
120+
isWellTyped :: (Typeable a, Show a) => Var a -> VarContext -> Bool
121121
isWellTyped v (VarCtx ctx) = not (null ctx) && Some v `Set.member` ctx
122122

123123
wellTypedIn :: HasVariables a => a -> VarContext -> Bool
@@ -129,7 +129,7 @@ wellTypedIn a ctx = all (\(Some v) -> v `isWellTyped` ctx) (getAllVariables a)
129129
-- cause an issue, but it might be good practise to crash
130130
-- if the invariant is violated anyway as it is evidence that
131131
-- something is horribly broken at the use site).
132-
extendContext :: Typeable a => VarContext -> Var a -> VarContext
132+
extendContext :: (Typeable a, Show a) => VarContext -> Var a -> VarContext
133133
extendContext (VarCtx ctx) v = VarCtx $ Set.insert (Some v) ctx
134134

135135
emptyContext :: VarContext

0 commit comments

Comments
 (0)