Haskell Lenses: Difference of two HashSets in Folds

70 views Asked by At

Given:

f1, f2 :: Fold Box (HashSet Thing)

how do I write a fold that focuses the Things that are in f1 but not in f2? It would (of course) be the same Box, but f1 and f2 filter its contents differently.

I can see that filtered and hasn't might come into it and HashSet.difference would do the gruntwork, but I can't quite figure out the plumbing.

1

There are 1 answers

0
Adrian May On

It was a silly question. f1 is just a field of Box but f2 is a filter of f1's contents, and the answer would be the converse filter. It's not meaningful to speak of stuffing the answer back into Box, so I don't really want an optic.