Skip to content

Commit 5d52eac

Browse files
remove the graph from the solver plan
1 parent 45559e0 commit 5d52eac

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/Constrained/Generation.hs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ prepareLinearization p = do
228228
]
229229
)
230230
$ linearize preds graph
231-
pure $ backPropagation $ SolverPlan plan graph
231+
pure $ backPropagation $ SolverPlan plan
232232

233233
-- | Flatten nested `Let`, `Exists`, and `And` in a `Pred fn`. `Let` and
234234
-- `Exists` bound variables become free in the result.
@@ -845,11 +845,11 @@ mergeSolverStage (SolverStage x ps spec) plan =
845845
]
846846

847847
isEmptyPlan :: SolverPlan -> Bool
848-
isEmptyPlan (SolverPlan plan _) = null plan
848+
isEmptyPlan (SolverPlan plan) = null plan
849849

850850
stepPlan :: MonadGenError m => Env -> SolverPlan -> GenT m (Env, SolverPlan)
851-
stepPlan env plan@(SolverPlan [] _) = pure (env, plan)
852-
stepPlan env (SolverPlan (SolverStage (x :: Var a) ps spec : pl) gr) = do
851+
stepPlan env plan@(SolverPlan []) = pure (env, plan)
852+
stepPlan env (SolverPlan (SolverStage (x :: Var a) ps spec : pl)) = do
853853
(spec', specs) <- runGE
854854
$ explain
855855
( show
@@ -884,14 +884,13 @@ stepPlan env (SolverPlan (SolverStage (x :: Var a) ps spec : pl) gr) = do
884884
(spec <> spec')
885885
)
886886
let env1 = Env.extend x val env
887-
pure (env1, backPropagation $ SolverPlan (substStage env1 <$> pl) (deleteNode (Name x) gr))
887+
pure (env1, backPropagation $ SolverPlan (substStage env1 <$> pl) )
888888

889889
-- | Generate a satisfying `Env` for a `p : Pred fn`. The `Env` contains values for
890890
-- all the free variables in `flattenPred p`.
891891
genFromPreds :: forall m. MonadGenError m => Env -> Pred -> GenT m Env
892892
-- TODO: remove this once optimisePred does a proper fixpoint computation
893-
genFromPreds env0 (optimisePred . optimisePred -> preds) =
894-
{- explain1 (show $ "genFromPreds fails\nPreds are:" /> pretty preds) -} do
893+
genFromPreds env0 (optimisePred . optimisePred -> preds) = do
895894
-- NOTE: this is just lazy enough that the work of flattening,
896895
-- computing dependencies, and linearizing is memoized in
897896
-- properties that use `genFromPreds`.
@@ -909,8 +908,7 @@ genFromPreds env0 (optimisePred . optimisePred -> preds) =
909908

910909
-- | Push as much information we can backwards through the plan.
911910
backPropagation :: SolverPlan -> SolverPlan
912-
-- backPropagation (SolverPlan _plan _graph) =
913-
backPropagation (SolverPlan initplan graph) = SolverPlan (go [] (reverse initplan)) graph
911+
backPropagation (SolverPlan initplan) = SolverPlan (go [] (reverse initplan))
914912
where
915913
go :: [SolverStage] -> [SolverStage] -> [SolverStage]
916914
go acc [] = acc
@@ -1325,17 +1323,13 @@ instance Pretty SolverStage where
13251323
++ map pretty stagePreds
13261324
)
13271325

1328-
data SolverPlan = SolverPlan
1329-
{ solverPlan :: [SolverStage]
1330-
, solverDependencies :: Graph Name
1331-
}
1326+
newtype SolverPlan = SolverPlan { solverPlan :: [SolverStage] }
13321327

13331328
instance Pretty SolverPlan where
13341329
pretty SolverPlan {..} =
13351330
"\nSolverPlan"
13361331
/> vsep'
1337-
[ -- "\nDependencies:" /> pretty solverDependencies, -- Might be usefull someday
1338-
"\nLinearization:" /> prettyLinear solverPlan
1332+
[ "\nLinearization:" /> prettyLinear solverPlan
13391333
]
13401334

13411335
isTrueSpec :: Specification a -> Bool

0 commit comments

Comments
 (0)