diff --git a/src/Hash2Pub/RingMap.hs b/src/Hash2Pub/RingMap.hs index 36f95ec..d26835c 100644 --- a/src/Hash2Pub/RingMap.hs +++ b/src/Hash2Pub/RingMap.hs @@ -47,6 +47,13 @@ instance (Bounded k, Ord k) => Foldable (RingMap k) where traversingFL acc (ProxyEntry _ Nothing) = acc traversingFL acc (ProxyEntry _ (Just entry)) = traversingFL acc entry +instance (Bounded k, Ord k) => Traversable (RingMap k) where + traverse f = fmap RingMap . traverse traversingF . getRingMap + where + traversingF (KeyEntry entry) = KeyEntry <$> f entry + traversingF (ProxyEntry to Nothing) = pure $ ProxyEntry to Nothing + traversingF (ProxyEntry to (Just entry)) = ProxyEntry to . Just <$> traversingF entry + -- | entry of a 'RingMap' that holds a value and can also -- wrap around the lookup direction at the edges of the name space.