make RingMap an instance of Traversable
- some examples tested out by hand, but not thorough test case or even QuickCheck coverage
This commit is contained in:
		
							parent
							
								
									048a6ce391
								
							
						
					
					
						commit
						6aebd982f8
					
				
					 1 changed files with 7 additions and 0 deletions
				
			
		|  | @ -47,6 +47,13 @@ instance (Bounded k, Ord k) => Foldable (RingMap k) where | ||||||
|           traversingFL acc (ProxyEntry _ Nothing) = acc |           traversingFL acc (ProxyEntry _ Nothing) = acc | ||||||
|           traversingFL acc (ProxyEntry _ (Just entry)) = traversingFL acc entry |           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 | -- | entry of a 'RingMap' that holds a value and can also | ||||||
| -- wrap around the lookup direction at the edges of the name space. | -- wrap around the lookup direction at the edges of the name space. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue