File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,9 @@ If we had a `CharTrie a`, then `cata lookupAlg myTree "hello"` would look up
3535
3636The buildup co-algebra is an interesting one. We will convert a ` Map String a `
3737into a ` CharTrie a ` , _ but_ , every time we reach the end of the string, we
38- "restart" the building from the start. So, we'll take a ` Set String ` as well,
39- which we will trigger when we hit the end of a pattern.
38+ "restart" the building from the start, while merging all of the resulting
39+ leaves monoidally. So, we'll take a ` Set String ` as well, which we will trigger
40+ when we hit the end of a pattern.
4041
4142``` haskell
4243fromMapCoalg ::
@@ -74,3 +75,8 @@ part1 pats = length . mapMaybe (buildable () pats)
7475part2 :: Set String -> [String ] -> Int
7576part2 pats = getSum . foldMap (fold . buildable (Sum 1 ) pats)
7677```
78+
79+ However, this may be a case where the hylomorphism is slower than doing the
80+ unfold and fold separately, because the full ` CharTrie ` is actually going to be
81+ re-used multiple times for each design. However, there's something a little
82+ more satisfying about just re-building and tearing down every time.
You can’t perform that action at this time.
0 commit comments