@@ -8,7 +8,10 @@ import Control.Comonad (class Comonad, extract)
88import Control.Comonad.Trans.Class (class ComonadTrans )
99import Control.Extend (class Extend , (<<=))
1010
11+ import Data.FoldableWithIndex (class FoldableWithIndex , foldrWithIndex , foldlWithIndex , foldMapWithIndex )
12+ import Data.FunctorWithIndex (class FunctorWithIndex , mapWithIndex )
1113import Data.Traversable (class Traversable , class Foldable , foldl , foldr , foldMap , traverse , sequence )
14+ import Data.TraversableWithIndex (class TraversableWithIndex , traverseWithIndex )
1215import Data.Tuple (Tuple (..))
1316import Data.Newtype (class Newtype )
1417
@@ -55,3 +58,14 @@ instance foldableEnvT :: Foldable f => Foldable (EnvT e f) where
5558instance traversableEnvT :: Traversable f => Traversable (EnvT e f ) where
5659 sequence (EnvT (Tuple a x)) = EnvT <$> Tuple a <$> sequence x
5760 traverse f (EnvT (Tuple a x)) = EnvT <$> Tuple a <$> traverse f x
61+
62+ instance functorWithIndexEnvT :: FunctorWithIndex i w => FunctorWithIndex i (EnvT e w ) where
63+ mapWithIndex f (EnvT (Tuple e x)) = EnvT $ Tuple e (mapWithIndex f x)
64+
65+ instance foldableWithIndexEnvT :: FoldableWithIndex i w => FoldableWithIndex i (EnvT e w ) where
66+ foldlWithIndex f a (EnvT (Tuple _ x)) = foldlWithIndex f a x
67+ foldrWithIndex f a (EnvT (Tuple _ x)) = foldrWithIndex f a x
68+ foldMapWithIndex f (EnvT (Tuple _ x)) = foldMapWithIndex f x
69+
70+ instance traversableWithIndexEnvT :: TraversableWithIndex i w => TraversableWithIndex i (EnvT e w ) where
71+ traverseWithIndex f (EnvT (Tuple e x)) = EnvT <$> Tuple e <$> traverseWithIndex f x
0 commit comments