Skip to content

Commit 18b4fd2

Browse files
Remove some dead code
1 parent b24b667 commit 18b4fd2

File tree

5 files changed

+6
-71
lines changed

5 files changed

+6
-71
lines changed

examples/Constrained/Examples/CheatSheet.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ tightFit0 = constrained' $ \x y ->
364364
-- TypeSpec (Cartesian TrueSpec (MemberSpec [0])) []
365365
-- ---
366366
-- assert $ Equal (Fst (ToGeneric v_3)) v_1
367-
-- Env {unEnv = fromList [(v_0,EnvValue 0)]}
367+
-- Env (fromList [(v_0,EnvValue 0)])
368368
-- genFromSpecT ErrorSpec{} with explanation:
369369
-- [1..-1]
370370

src/Constrained/Base.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ import Constrained.GenT
101101
import Constrained.Generic
102102
import Constrained.List hiding (toList)
103103
import Constrained.TypeErrors
104-
import Control.Monad.Writer (
105-
Writer,
106-
tell,
107-
)
108104
import Data.Foldable (
109105
toList,
110106
)
@@ -524,12 +520,6 @@ class
524520
alternateShow :: TypeSpec a -> BinaryShow
525521
alternateShow _ = NonBinary
526522

527-
monadConformsTo :: a -> TypeSpec a -> Writer [String] Bool
528-
monadConformsTo x spec =
529-
if conformsTo @a x spec
530-
then pure True
531-
else tell ["Fails by " ++ show spec] >> pure False
532-
533523
-- | For some types (especially finite ones) there may be much better ways to construct
534524
-- a Specification than the default method of just adding a large 'bad' list to TypSpec. This
535525
-- function allows each HasSpec instance to decide.

src/Constrained/Conformance.hs

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Constrained.Conformance (
1414
conformsToSpec,
1515
conformsToSpecE,
1616
satisfies,
17-
checkPred,
1817
checkPredsE,
1918
) where
2019

@@ -34,59 +33,9 @@ import Data.Semigroup (sconcat)
3433
import Prettyprinter hiding (cat)
3534
import Test.QuickCheck (Property, Testable, property)
3635

37-
-- =========================================================================
38-
39-
-- | Does the Pred evaluate to true under the given Env.
40-
-- If it doesn't, some explanation appears in the failure of the monad 'm'
41-
checkPred :: forall m. MonadGenError m => Env -> Pred -> m Bool
42-
checkPred env = \case
43-
p@(ElemPred bool term xs) -> do
44-
v <- runTerm env term
45-
case (elem v xs, bool) of
46-
(True, True) -> pure True
47-
(True, False) -> fatalErrorNE ("notElemPred reduces to True" :| [show p])
48-
(False, True) -> fatalErrorNE ("elemPred reduces to False" :| [show p])
49-
(False, False) -> pure True
50-
Monitor {} -> pure True
51-
Subst x t p -> checkPred env $ substitutePred x t p
52-
Assert t -> runTerm env t
53-
GenHint {} -> pure True
54-
p@(Reifies t' t f) -> do
55-
val <- runTerm env t
56-
val' <- runTerm env t'
57-
explainNE (NE.fromList ["Reification:", " " ++ show p]) $ pure (f val == val')
58-
ForAll t (x :-> p) -> do
59-
set <- runTerm env t
60-
and
61-
<$> sequence
62-
[ checkPred env' p
63-
| v <- forAllToList set
64-
, let env' = Env.extend x v env
65-
]
66-
Case t bs -> do
67-
v <- runTerm env t
68-
runCaseOn v (mapList thing bs) (\x val ps -> checkPred (Env.extend x val env) ps)
69-
When bt p -> do
70-
b <- runTerm env bt
71-
if b then checkPred env p else pure True
72-
TruePred -> pure True
73-
FalsePred es -> explainNE es $ pure False
74-
DependsOn {} -> pure True
75-
And ps -> checkPreds env ps
76-
Let t (x :-> p) -> do
77-
val <- runTerm env t
78-
checkPred (Env.extend x val env) p
79-
Exists k (x :-> p) -> do
80-
a <- runGE $ k (errorGE . explain "checkPred: Exists" . runTerm env)
81-
checkPred (Env.extend x a env) p
82-
Explain es p -> explainNE es $ checkPred env p
83-
84-
checkPreds :: (MonadGenError m, Traversable t) => Env -> t Pred -> m Bool
85-
checkPreds env ps = and <$> mapM (checkPred env) ps
86-
8736
-- ==========================================================
8837

89-
-- | Like checkPred, But it takes [Pred] rather than a single Pred,
38+
-- | Like checkPredE, But it takes [Pred] rather than a single Pred,
9039
-- and it builds a much more involved explanation if it fails.
9140
-- Does the Pred evaluate to True under the given Env?
9241
-- If it doesn't, an involved explanation appears in the (Just message)
@@ -101,8 +50,9 @@ checkPredsE msgs env ps =
10150
[] -> Nothing
10251
(x : xs) -> Just (NE.nub (sconcat (x NE.:| xs)))
10352

104-
-- | An involved explanation for a single Pred
105-
-- The most important explanations come when an assertion fails.
53+
-- | Does the Pred evaluate to true under the given Env. An involved
54+
-- explanation for a single Pred in case of failure and `Nothing` otherwise.
55+
-- The most important explanations come when an assertion fails.
10656
checkPredE :: Env -> NE.NonEmpty String -> Pred -> Maybe (NE.NonEmpty String)
10757
checkPredE env msgs = \case
10858
p@(ElemPred bool t xs) ->

src/Constrained/Env.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Prettyprinter
2727
import Prelude hiding (lookup)
2828

2929
-- | Typed environments for mapping @t`Var` a@ to @a@
30-
newtype Env = Env {unEnv :: Map EnvKey EnvValue}
30+
newtype Env = Env (Map EnvKey EnvValue)
3131
deriving newtype (Semigroup, Monoid)
3232
deriving stock (Show)
3333

src/Constrained/Syntax.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ module Constrained.Syntax (
5151
computeDependencies,
5252
solvableFrom,
5353
respecting,
54-
dependency,
5554
applyNameHints,
5655
envFromPred,
5756
isLit,
@@ -834,10 +833,6 @@ applyNameHints spec = spec
834833
-- | `Graph` specialized to dependencies for variables
835834
type DependGraph = Graph.Graph Name
836835

837-
-- | A variable depends on a thing witha buch of other variables
838-
dependency :: HasVariables t => Name -> t -> DependGraph
839-
dependency x (freeVarSet -> xs) = Graph.dependency x xs
840-
841836
-- | Everything to the left depends on everything from the right, except themselves
842837
irreflexiveDependencyOn ::
843838
forall t t'. (HasVariables t, HasVariables t') => t -> t' -> DependGraph

0 commit comments

Comments
 (0)