@@ -8,7 +8,10 @@ import Control.Comonad (class Comonad, extract)
8
8
import Control.Comonad.Trans.Class (class ComonadTrans )
9
9
import Control.Extend (class Extend , (<<=))
10
10
11
+ import Data.FoldableWithIndex (class FoldableWithIndex , foldrWithIndex , foldlWithIndex , foldMapWithIndex )
12
+ import Data.FunctorWithIndex (class FunctorWithIndex , mapWithIndex )
11
13
import Data.Traversable (class Traversable , class Foldable , foldl , foldr , foldMap , traverse , sequence )
14
+ import Data.TraversableWithIndex (class TraversableWithIndex , traverseWithIndex )
12
15
import Data.Tuple (Tuple (..))
13
16
import Data.Newtype (class Newtype )
14
17
@@ -55,3 +58,14 @@ instance foldableEnvT :: Foldable f => Foldable (EnvT e f) where
55
58
instance traversableEnvT :: Traversable f => Traversable (EnvT e f ) where
56
59
sequence (EnvT (Tuple a x)) = EnvT <$> Tuple a <$> sequence x
57
60
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