@@ -39,15 +39,11 @@ instance Monoid w => MonadWriter w (Silent w) where
39 listen (Silent x) = Silent (x, mempty)
39 listen (Silent x) = Silent (x, mempty)
40 pass (Silent (x, _)) = Silent x
40 pass (Silent (x, _)) = Silent x
42−instance MonadState (MemoState ()) (Silent w) where
43− get = Silent $ runIdentity $ runMemo () get
46type ProcessM = StateT (MemoState ()) (ReaderT (Traced (Definitions Schema)) (Writer (P.PathsPrefixTree Behave AnIssue 'SchemaLevel)))
42type ProcessM = StateT (MemoState ()) (ReaderT (Traced (Definitions Schema)) (Writer (P.PathsPrefixTree Behave AnIssue 'SchemaLevel)))
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)))
50−-- Either SilentM or ProcessM
46+-- Either ProcessM or SilentM
51type MonadProcess m =
47type MonadProcess m =
52 ( MonadReader (Traced (Definitions Schema)) m
48 ( MonadReader (Traced (Definitions Schema)) m
53 , MonadWriter (P.PathsPrefixTree Behave AnIssue 'SchemaLevel) m
49 , MonadWriter (P.PathsPrefixTree Behave AnIssue 'SchemaLevel) m
@@ -57,11 +53,11 @@ type MonadProcess m =
57warn :: MonadProcess m => Issue 'SchemaLevel -> m ()
53warn :: MonadProcess m => Issue 'SchemaLevel -> m ()
58warn issue = tell $ P.singleton $ AnItem Root $ anIssue issue
54warn issue = tell $ P.singleton $ AnItem Root $ anIssue issue
60−-- | Ignore warnings but allow a recursive loop that lazily computes a recursive 'Condition'.
56+-- Perform a computation lazily, ignoring the warnings and discarding memoization/loop detection information.
61−silently :: MonadProcess m => SilentM a -> m a
57+lazily :: MonadProcess m => SilentM a -> m a
62−silently m = do
58+lazily m = do
63 defs <- R.ask
59 defs <- R.ask
64− pure . runSilent $ runReaderT m defs
60+ pure $ runSilent $ runReaderT (runMemo () m) defs
66warnKnot :: MonadProcess m => KnotTier (ForeachType JsonFormula) () m
62warnKnot :: MonadProcess m => KnotTier (ForeachType JsonFormula) () m
@@ -243,11 +239,11 @@ processSchema sch@(extract -> Schema {..}) = do
243 itemsClause <- case tracedItems sch of
239 itemsClause <- case tracedItems sch of
244 Nothing -> pure top
240 Nothing -> pure top
245 Just (Left rs) -> do
241 Just (Left rs) -> do
246− f <- silently $ processRefSchema rs
242+ f <- lazily $ processRefSchema rs
247 pure top {forArray = singletonFormula $ Items f rs}
243 pure top {forArray = singletonFormula $ Items f rs}
248 Just (Right rss) -> do
244 Just (Right rss) -> do
249 fsrs <- forM rss $ \rs -> do
245 fsrs <- forM rss $ \rs -> do
250− f <- silently $ processRefSchema rs
246+ f <- lazily $ processRefSchema rs
251 pure (f, rs)
247 pure (f, rs)
252 pure top {forArray = singletonFormula $ TupleItems fsrs}
248 pure top {forArray = singletonFormula $ TupleItems fsrs}
@@ -273,12 +269,12 @@ processSchema sch@(extract -> Schema {..}) = do
275 (addProps, addPropSchema) <- case tracedAdditionalProperties sch of
271 (addProps, addPropSchema) <- case tracedAdditionalProperties sch of
276− Just (Right rs) -> (,Just rs) <$> silently (processRefSchema rs)
272+ Just (Right rs) -> (,Just rs) <$> lazily (processRefSchema rs)
277 Just (Left False) -> pure (bottom, Nothing)
273 Just (Left False) -> pure (bottom, Nothing)
278 _ -> pure (top, Just $ traced (ask sch `Snoc` AdditionalPropertiesStep) $ Inline mempty)
274 _ -> pure (top, Just $ traced (ask sch `Snoc` AdditionalPropertiesStep) $ Inline mempty)
279 propList <- forM (S.toList . S.fromList $ IOHM.keys _schemaProperties <> _schemaRequired) $ \k -> do
275 propList <- forM (S.toList . S.fromList $ IOHM.keys _schemaProperties <> _schemaRequired) $ \k -> do
280 (f, psch) <- case IOHM.lookup k $ tracedProperties sch of
276 (f, psch) <- case IOHM.lookup k $ tracedProperties sch of
281− Just rs -> (,rs) <$> silently (processRefSchema rs)
277+ Just rs -> (,rs) <$> lazily (processRefSchema rs)
282 Nothing ->
278 Nothing ->
283 let fakeSchema = traced (ask sch `Snoc` AdditionalPropertiesStep) $ Inline mempty
279 let fakeSchema = traced (ask sch `Snoc` AdditionalPropertiesStep) $ Inline mempty
284 in -- The mempty here is incorrect, but if addPropSchema was Nothing, then
280 in -- The mempty here is incorrect, but if addPropSchema was Nothing, then