File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ module Data.Bitraversable
22 ( class Bitraversable , bitraverse , bisequence
33 , bitraverseDefault
44 , bisequenceDefault
5+ , ltraverse
6+ , rtraverse
57 , bifor
8+ , lfor
9+ , rfor
610 , module Data.Bifoldable
711 ) where
812
@@ -26,6 +30,22 @@ class (Bifunctor t, Bifoldable t) <= Bitraversable t where
2630 bitraverse :: forall f a b c d . Applicative f => (a -> f c ) -> (b -> f d ) -> t a b -> f (t c d )
2731 bisequence :: forall f a b . Applicative f => t (f a ) (f b ) -> f (t a b )
2832
33+ ltraverse
34+ :: forall t b c a f
35+ . (Bitraversable t , Applicative f )
36+ => (a -> f c )
37+ -> t a b
38+ -> f (t c b )
39+ ltraverse f = bitraverse f pure
40+
41+ rtraverse
42+ :: forall t b c a f
43+ . (Bitraversable t , Applicative f )
44+ => (b -> f c )
45+ -> t a b
46+ -> f (t a c )
47+ rtraverse = bitraverse pure
48+
2949-- | A default implementation of `bitraverse` using `bisequence` and `bimap`.
3050bitraverseDefault
3151 :: forall t f a b c d
5373 -> (b -> f d )
5474 -> f (t c d )
5575bifor t f g = bitraverse f g t
76+
77+ lfor
78+ :: forall t b c a f
79+ . (Bitraversable t , Applicative f )
80+ => t a b
81+ -> (a -> f c )
82+ -> f (t c b )
83+ lfor t f = bitraverse f pure t
84+
85+ rfor
86+ :: forall t b c a f
87+ . (Bitraversable t , Applicative f )
88+ => t a b
89+ -> (b -> f c )
90+ -> f (t a c )
91+ rfor t f = bitraverse pure f t
You can’t perform that action at this time.
0 commit comments