File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import Data.Functor.Compose (Compose (..))
1717import Data.Functor.Const (Const (.. ))
1818import Data.Functor.Identity (Identity (.. ))
1919import Data.Functor.Sum (Sum (.. ))
20+ import Data.Functor.These (These1 (.. ))
2021import Data.Proxy (Proxy (.. ))
2122import Data.Traversable (Traversable (traverse ))
2223import Data.Vector.Generic (Vector )
@@ -107,6 +108,12 @@ instance (Crosswalk f, Crosswalk g) => Crosswalk (Sum f g) where
107108 crosswalk f (InL xs) = InL <$> crosswalk f xs
108109 crosswalk f (InR xs) = InR <$> crosswalk f xs
109110
111+ instance (Crosswalk f , Crosswalk g ) => Crosswalk (These1 f g ) where
112+ crosswalk f (This1 xs) = This1 <$> crosswalk f xs
113+ crosswalk f (That1 ys) = That1 <$> crosswalk f ys
114+ crosswalk f (These1 xs ys) = alignWith go (crosswalk f xs) (crosswalk f ys)
115+ where go = these This1 That1 These1
116+
110117instance (Crosswalk f , Crosswalk g ) => Crosswalk (Compose f g ) where
111118 crosswalk f
112119 = fmap Compose -- can't coerce: maybe the Align-able thing has role nominal
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Data.Functor.Compose (Compose (..))
1212import Data.Functor.Const (Const )
1313import Data.Functor.Identity (Identity (.. ))
1414import Data.Functor.Sum (Sum )
15+ import Data.Functor.These (These1 )
1516import Data.List.NonEmpty (NonEmpty )
1617import Data.Map (Map )
1718import Data.Proxy (Proxy )
@@ -53,6 +54,7 @@ crosswalkProps = testGroup "Crosswalk"
5354 , crosswalkLaws (P :: P Proxy )
5455 , crosswalkLaws (P :: P (Const Int ))
5556 , crosswalkLaws (P :: P (Sum [] [] ))
57+ , crosswalkLaws (P :: P (These1 [] [] ))
5658 , crosswalkLaws (P :: P (Compose [] [] ))
5759 , crosswalkLaws (P :: P (MaybeT [] ))
5860 ]
You can’t perform that action at this time.
0 commit comments