0 | module Data.SortedSet.Lens
 1 |
 2 | import Data.SortedSet
 3 | import public Control.Lens
 4 |
 5 | %default total
 6 |
 7 |
 8 | public export
 9 | each : Fold (SortedSet k) k
10 | each = folding SortedSet.toList
11 |
12 |
13 | public export
14 | Ixed k () (SortedSet k) where
15 |   ix k = optional' (ignore . guard . contains k) const
16 |
17 | public export
18 | At k () (SortedSet k) where
19 |   at k = lens (ignore . guard . contains k) (flip $ \case
20 |     Nothing => delete k
21 |     Just _ => insert k)
22 |