Skip to content

Commit 5a5314b

Browse files
Make isWellTyped more lazy and add missing isEmptyCtx function to
`Variables` module
1 parent 54b4cf8 commit 5a5314b

File tree

1 file changed

+5
-1
lines changed
  • quickcheck-dynamic/src/Test/QuickCheck/StateModel

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Test.QuickCheck.StateModel.Variables (
1515
extendContext,
1616
isWellTyped,
1717
allVariables,
18+
isEmptyCtx,
1819
unsafeCoerceVar,
1920
unsafeNextVarIndex,
2021
) where
@@ -105,8 +106,11 @@ instance Show VarContext where
105106
-- The use of typeRep here is on purpose to avoid printing `Var` unnecessarily.
106107
showBinding (Some v) = show v ++ " :: " ++ show (typeRep v)
107108

109+
isEmptyCtx :: VarContext -> Bool
110+
isEmptyCtx (VarCtx ctx) = null ctx
111+
108112
isWellTyped :: Typeable a => Var a -> VarContext -> Bool
109-
isWellTyped v (VarCtx ctx) = Some v `Set.member` ctx
113+
isWellTyped v (VarCtx ctx) = not (null ctx) && Some v `Set.member` ctx
110114

111115
-- TODO: check the invariant that no variable index is used
112116
-- twice at different types. This is generally not an issue

0 commit comments

Comments
 (0)