21 lines
526 B
Haskell
21 lines
526 B
Haskell
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
module Data.Universe.Instances.Reverse.WithIndex
|
|
(
|
|
) where
|
|
|
|
import ClassyPrelude
|
|
|
|
import Data.Universe
|
|
import Control.Lens.Indexed
|
|
|
|
import Data.Universe.Instances.Reverse ()
|
|
|
|
import qualified Data.Map as Map
|
|
|
|
|
|
instance Finite a => FoldableWithIndex a ((->) a) where
|
|
ifoldMap f g = fold [ f x (g x) | x <- universeF ]
|
|
instance (Ord a, Finite a) => TraversableWithIndex a ((->) a) where
|
|
itraverse f g = (Map.!) . Map.fromList <$> sequenceA [ (x, ) <$> f x (g x) | x <- universeF ]
|