From 0eab75c320d9937f00cbbe28842d43e31f4f280e Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 31 Aug 2017 11:33:09 -0400 Subject: [PATCH] foldMap the symbols/choices/atEnd. --- src/Data/Syntax/Assignment.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Syntax/Assignment.hs b/src/Data/Syntax/Assignment.hs index 2f5bb49f5..5a9bf9ce0 100644 --- a/src/Data/Syntax/Assignment.hs +++ b/src/Data/Syntax/Assignment.hs @@ -181,7 +181,7 @@ advance = tracing Advance `Then` return choice :: (Bounded grammar, Ix grammar, HasCallStack) => [Assignment ast grammar a] -> Assignment ast grammar a choice alternatives = tracing (Choose symbols (IntMap.fromList choices) (wrap . tracing . Alt . toList <$> nonEmpty atEnd)) `Then` id - where (symbols, choices, atEnd) = foldr (<>) ([], [], []) (fmap toChoices alternatives) + where (symbols, choices, atEnd) = foldMap toChoices alternatives toChoices :: Assignment ast grammar a -> ([grammar], [(Int, Assignment ast grammar a)], [Assignment ast grammar a]) toChoices rule = case rule of Tracing _ (Choose s c a) `Then` continue -> (s, IntMap.toList (fmap continue c), toList (fmap continue a))