@@ -39,15 +39,11 @@ instance Monoid w => MonadWriter w (Silent w) where
3939 listen (Silent x) = Silent (x, mempty)
4040 pass (Silent (x, _)) = Silent x
4141
42−instance MonadState (MemoState ()) (Silent w) where
43− get = Silent $ runIdentity $ runMemo () get
44− put _ = pure ()
45−
4642type ProcessM = StateT (MemoState ()) (ReaderT (Traced (Definitions Schema)) (Writer (P.PathsPrefixTree Behave AnIssue 'SchemaLevel)))
4743
48−type SilentM = ReaderT (Traced (Definitions Schema)) (Silent (P.PathsPrefixTree Behave AnIssue 'SchemaLevel))
44+type SilentM = StateT (MemoState ()) (ReaderT (Traced (Definitions Schema)) (Silent (P.PathsPrefixTree Behave AnIssue 'SchemaLevel)))
4945
50−-- Either SilentM or ProcessM
46+-- Either ProcessM or SilentM
5147type MonadProcess m =
5248 ( MonadReader (Traced (Definitions Schema)) m
5349 , MonadWriter (P.PathsPrefixTree Behave AnIssue 'SchemaLevel) m
@@ -57,11 +53,11 @@ type MonadProcess m =
5753warn :: MonadProcess m => Issue 'SchemaLevel -> m ()
5854warn issue = tell $ P.singleton $ AnItem Root $ anIssue issue
5955
60−-- | Ignore warnings but allow a recursive loop that lazily computes a recursive 'Condition'.
61−silently :: MonadProcess m => SilentM a -> m a
62−silently m = do
56+-- Perform a computation lazily, ignoring the warnings and discarding memoization/loop detection information.
57+lazily :: MonadProcess m => SilentM a -> m a
58+lazily m = do
6359 defs <- R.ask
64− pure . runSilent $ runReaderT m defs
60+ pure $ runSilent $ runReaderT (runMemo () m) defs
6561
6662warnKnot :: MonadProcess m => KnotTier (ForeachType JsonFormula) () m
6763warnKnot =
@@ -243,11 +239,11 @@ processSchema sch@(extract -> Schema {..}) = do
243239 itemsClause <- case tracedItems sch of
244240 Nothing -> pure top
245241 Just (Left rs) -> do
246− f <- silently $ processRefSchema rs
242+ f <- lazily $ processRefSchema rs
247243 pure top {forArray = singletonFormula $ Items f rs}
248244 Just (Right rss) -> do
249245 fsrs <- forM rss $ \rs -> do
250− f <- silently $ processRefSchema rs
246+ f <- lazily $ processRefSchema rs
251247 pure (f, rs)
252248 pure top {forArray = singletonFormula $ TupleItems fsrs}
253249
@@ -273,12 +269,12 @@ processSchema sch@(extract -> Schema {..}) = do
273269 _ -> top
274270
275271 (addProps, addPropSchema) <- case tracedAdditionalProperties sch of
276− Just (Right rs) -> (,Just rs) <$> silently (processRefSchema rs)
272+ Just (Right rs) -> (,Just rs) <$> lazily (processRefSchema rs)
277273 Just (Left False) -> pure (bottom, Nothing)
278274 _ -> pure (top, Just $ traced (ask sch `Snoc` AdditionalPropertiesStep) $ Inline mempty)
279275 propList <- forM (S.toList . S.fromList $ IOHM.keys _schemaProperties <> _schemaRequired) $ \k -> do
280276 (f, psch) <- case IOHM.lookup k $ tracedProperties sch of
281− Just rs -> (,rs) <$> silently (processRefSchema rs)
277+ Just rs -> (,rs) <$> lazily (processRefSchema rs)
282278 Nothing ->
283279 let fakeSchema = traced (ask sch `Snoc` AdditionalPropertiesStep) $ Inline mempty
284280 in -- The mempty here is incorrect, but if addPropSchema was Nothing, then