{-# OPTIONS_GHC -Wno-redundant-constraints #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
-- | Kind-polymorphic syntactic (first-order) unification.
module Data.ZipMatchK (
  module Data.ZipMatchK.Mappings,
  ZipMatchK(..),
  zipMatchK,
  ZipMatchFoldK(..),
  zipMatchAllK,
  zipMatchAnyK,
  -- * Specializations
  -- ** Unification of plain 'Data.Kind.Type's
  zipMatchViaEq,
  zipMatchViaChooseLeft,
  -- ** Unification of 'Data.Functor.Functor's
  zipMatchWith1,
  zipMatch1,
  zipMatchFold1,
  zipMatchAll1,
  zipMatchAny1,
  -- ** Unification of 'Data.Bifunctor.Bifunctor's
  zipMatchWith2,
  zipMatch2,
  zipMatchFold2,
  zipMatchAll2,
  zipMatchAny2,
) where

import           Data.Coerce (coerce)
import           Data.Monoid (All (..), Any (..))
import           Generics.Kind

import Data.ZipMatchK.Generic
import Data.ZipMatchK.Mappings

-- | Perform one level of equality testing for two values and pair up
-- corresponding components using @(,)@, for every type parameter:
--
-- > zipMatchK = zipMatchWithK pairMappings
--
-- @since 0.2.0
zipMatchK :: forall f as bs. (ZipMatchK f, PairMappings as bs) => f :@@: as -> f :@@: bs -> Maybe (f :@@: ZipLoT as bs)
zipMatchK :: forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
(ZipMatchK f, PairMappings as bs) =>
(f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: ZipLoT as bs)
zipMatchK = forall k (f :: k) (as :: LoT k) (bs :: LoT k) (cs :: LoT k).
ZipMatchK f =>
Mappings as bs cs
-> (f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: cs)
zipMatchWithK @_ @f @as @bs Mappings as bs (ZipLoT as bs)
forall k (as :: LoT k) (bs :: LoT k).
PairMappings as bs =>
Mappings as bs (ZipLoT as bs)
pairMappings

-- | Unify values via 'Eq'.
-- Can be used as an implementation of 'zipMatchWithK' when @k = 'Data.Kind.Type'@.
--
-- @since 0.2.0
zipMatchViaEq :: Eq a => Mappings as bs cs -> a -> a -> Maybe a
zipMatchViaEq :: forall {k} a (as :: LoT k) (bs :: LoT k) (cs :: LoT k).
Eq a =>
Mappings as bs cs -> a -> a -> Maybe a
zipMatchViaEq Mappings as bs cs
_ a
x a
y
  | a
x a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
y = a -> Maybe a
forall a. a -> Maybe a
Just a
x
  | Bool
otherwise = Maybe a
forall a. Maybe a
Nothing

-- | Always successfully unify any two values of type @a@ by preferring the left value.
-- Can be used as an implementation of 'zipMatchWithK' when @k = 'Data.Kind.Type'@.
--
-- @since 0.2.0
zipMatchViaChooseLeft :: Mappings as bs cs -> a -> a -> Maybe a
zipMatchViaChooseLeft :: forall {k} (as :: LoT k) (bs :: LoT k) (cs :: LoT k) a.
Mappings as bs cs -> a -> a -> Maybe a
zipMatchViaChooseLeft Mappings as bs cs
_ a
x a
_ = a -> Maybe a
forall a. a -> Maybe a
Just a
x

-- | 'zipMatchWithK' specialised to functors.
--
-- @since 0.3.0
zipMatchWith1
  :: ZipMatchK f
  => (a -> a' -> Maybe a'')
  -> f a -> f a' -> Maybe (f a'')
zipMatchWith1 :: forall (f :: * -> *) a a' a''.
ZipMatchK f =>
(a -> a' -> Maybe a'') -> f a -> f a' -> Maybe (f a'')
zipMatchWith1 a -> a' -> Maybe a''
f = Mappings (a ':&&: 'LoT0) (a' ':&&: 'LoT0) (a'' ':&&: 'LoT0)
-> (f :@@: (a ':&&: 'LoT0))
-> (f :@@: (a' ':&&: 'LoT0))
-> Maybe (f :@@: (a'' ':&&: 'LoT0))
forall k (f :: k) (as :: LoT k) (bs :: LoT k) (cs :: LoT k).
ZipMatchK f =>
Mappings as bs cs
-> (f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: cs)
forall (as :: LoT (* -> *)) (bs :: LoT (* -> *))
       (cs :: LoT (* -> *)).
Mappings as bs cs
-> (f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: cs)
zipMatchWithK (a -> a' -> Maybe a''
f (a -> a' -> Maybe a'')
-> Mappings 'LoT0 'LoT0 'LoT0
-> Mappings (a ':&&: 'LoT0) (a' ':&&: 'LoT0) (a'' ':&&: 'LoT0)
forall {k1} a b c (as1 :: LoT k1) (bs1 :: LoT k1) (cs1 :: LoT k1).
(a -> b -> Maybe c)
-> Mappings as1 bs1 cs1
-> Mappings (a ':&&: as1) (b ':&&: bs1) (c ':&&: cs1)
:^: Mappings 'LoT0 'LoT0 'LoT0
M0)

-- | 'zipMatchK' specialised to functors.
--
-- @since 0.3.0
zipMatch1 :: ZipMatchK f => f a -> f a' -> Maybe (f (a, a'))
zipMatch1 :: forall (f :: * -> *) a a'.
ZipMatchK f =>
f a -> f a' -> Maybe (f (a, a'))
zipMatch1 = (a -> a' -> Maybe (a, a')) -> f a -> f a' -> Maybe (f (a, a'))
forall (f :: * -> *) a a' a''.
ZipMatchK f =>
(a -> a' -> Maybe a'') -> f a -> f a' -> Maybe (f a'')
zipMatchWith1 a -> a' -> Maybe (a, a')
forall (f :: * -> *) a b. Applicative f => a -> b -> f (a, b)
pairA
-- | 'zipMatchWithK' specialised to bifunctors.
--
-- @since 0.3.0
zipMatchWith2
  :: ZipMatchK f
  => (a -> a' -> Maybe a'')
  -> (b -> b' -> Maybe b'')
  -> f a b -> f a' b' -> Maybe (f a'' b'')
zipMatchWith2 :: forall (f :: * -> * -> *) a a' a'' b b' b''.
ZipMatchK f =>
(a -> a' -> Maybe a'')
-> (b -> b' -> Maybe b'') -> f a b -> f a' b' -> Maybe (f a'' b'')
zipMatchWith2 a -> a' -> Maybe a''
f b -> b' -> Maybe b''
g = Mappings
  (a ':&&: (b ':&&: 'LoT0))
  (a' ':&&: (b' ':&&: 'LoT0))
  (a'' ':&&: (b'' ':&&: 'LoT0))
-> (f :@@: (a ':&&: (b ':&&: 'LoT0)))
-> (f :@@: (a' ':&&: (b' ':&&: 'LoT0)))
-> Maybe (f :@@: (a'' ':&&: (b'' ':&&: 'LoT0)))
forall k (f :: k) (as :: LoT k) (bs :: LoT k) (cs :: LoT k).
ZipMatchK f =>
Mappings as bs cs
-> (f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: cs)
forall (as :: LoT (* -> * -> *)) (bs :: LoT (* -> * -> *))
       (cs :: LoT (* -> * -> *)).
Mappings as bs cs
-> (f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: cs)
zipMatchWithK (a -> a' -> Maybe a''
f (a -> a' -> Maybe a'')
-> Mappings (b ':&&: 'LoT0) (b' ':&&: 'LoT0) (b'' ':&&: 'LoT0)
-> Mappings
     (a ':&&: (b ':&&: 'LoT0))
     (a' ':&&: (b' ':&&: 'LoT0))
     (a'' ':&&: (b'' ':&&: 'LoT0))
forall {k1} a b c (as1 :: LoT k1) (bs1 :: LoT k1) (cs1 :: LoT k1).
(a -> b -> Maybe c)
-> Mappings as1 bs1 cs1
-> Mappings (a ':&&: as1) (b ':&&: bs1) (c ':&&: cs1)
:^: b -> b' -> Maybe b''
g (b -> b' -> Maybe b'')
-> Mappings 'LoT0 'LoT0 'LoT0
-> Mappings (b ':&&: 'LoT0) (b' ':&&: 'LoT0) (b'' ':&&: 'LoT0)
forall {k1} a b c (as1 :: LoT k1) (bs1 :: LoT k1) (cs1 :: LoT k1).
(a -> b -> Maybe c)
-> Mappings as1 bs1 cs1
-> Mappings (a ':&&: as1) (b ':&&: bs1) (c ':&&: cs1)
:^: Mappings 'LoT0 'LoT0 'LoT0
M0)

-- | 'zipMatchK' specialised to bifunctors.
--
-- @since 0.3.0
zipMatch2 :: ZipMatchK f => f a b -> f a' b' -> Maybe (f (a, a') (b, b'))
zipMatch2 :: forall (f :: * -> * -> *) a b a' b'.
ZipMatchK f =>
f a b -> f a' b' -> Maybe (f (a, a') (b, b'))
zipMatch2 = (a -> a' -> Maybe (a, a'))
-> (b -> b' -> Maybe (b, b'))
-> f a b
-> f a' b'
-> Maybe (f (a, a') (b, b'))
forall (f :: * -> * -> *) a a' a'' b b' b''.
ZipMatchK f =>
(a -> a' -> Maybe a'')
-> (b -> b' -> Maybe b'') -> f a b -> f a' b' -> Maybe (f a'' b'')
zipMatchWith2 a -> a' -> Maybe (a, a')
forall (f :: * -> *) a b. Applicative f => a -> b -> f (a, b)
pairA b -> b' -> Maybe (b, b')
forall (f :: * -> *) a b. Applicative f => a -> b -> f (a, b)
pairA

-- | 'zipMatchFoldK' specialised to functors.
--
-- >>> zipMatchFold1 (\x y -> [x + y]) (Just 1) (Just (2 :: Int))
-- Just [3]
-- >>> zipMatchFold1 (\x y -> [x + y]) [1, 2] [10, 20 :: Int]
-- Just [11,22]
-- >>> zipMatchFold1 (\x y -> [x + y]) [1, 2] [10 :: Int]
-- Nothing
--
-- @since 0.6.0
zipMatchFold1
  :: (ZipMatchFoldK f, Monoid m)
  => (a -> a' -> m)
  -> f a -> f a' -> Maybe m
zipMatchFold1 :: forall (f :: * -> *) m a a'.
(ZipMatchFoldK f, Monoid m) =>
(a -> a' -> m) -> f a -> f a' -> Maybe m
zipMatchFold1 a -> a' -> m
f = Folds m (a ':&&: 'LoT0) (a' ':&&: 'LoT0)
-> (f :@@: (a ':&&: 'LoT0)) -> (f :@@: (a' ':&&: 'LoT0)) -> Maybe m
forall k (f :: k) (as :: LoT k) (bs :: LoT k) m.
(ZipMatchFoldK f, Monoid m) =>
Folds m as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe m
forall (as :: LoT (* -> *)) (bs :: LoT (* -> *)) m.
Monoid m =>
Folds m as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe m
zipMatchFoldK (a -> a' -> m
f (a -> a' -> m)
-> Folds m 'LoT0 'LoT0 -> Folds m (a ':&&: 'LoT0) (a' ':&&: 'LoT0)
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: Folds m 'LoT0 'LoT0
forall m. Folds m 'LoT0 'LoT0
F0)

-- | 'zipMatchFoldK' specialised to bifunctors. With 'Data.Monoid.All' it
-- checks that two nodes have the same constructor and that their components
-- satisfy a relation, without building anything for the components:
--
-- >>> import Data.Monoid (All (..))
-- >>> let same = zipMatchFold2 (\x y -> All (x == y)) (\x y -> All (x == y))
-- >>> getAll <$> same (Left 1) (Left (1 :: Int) :: Either Int Int)
-- Just True
-- >>> getAll <$> same (Left 1) (Left (2 :: Int) :: Either Int Int)
-- Just False
-- >>> getAll <$> same (Left 1) (Right (1 :: Int) :: Either Int Int)
-- Nothing
--
-- @since 0.6.0
zipMatchFold2
  :: (ZipMatchFoldK f, Monoid m)
  => (a -> a' -> m)
  -> (b -> b' -> m)
  -> f a b -> f a' b' -> Maybe m
zipMatchFold2 :: forall (f :: * -> * -> *) m a a' b b'.
(ZipMatchFoldK f, Monoid m) =>
(a -> a' -> m) -> (b -> b' -> m) -> f a b -> f a' b' -> Maybe m
zipMatchFold2 a -> a' -> m
f b -> b' -> m
g = Folds m (a ':&&: (b ':&&: 'LoT0)) (a' ':&&: (b' ':&&: 'LoT0))
-> (f :@@: (a ':&&: (b ':&&: 'LoT0)))
-> (f :@@: (a' ':&&: (b' ':&&: 'LoT0)))
-> Maybe m
forall k (f :: k) (as :: LoT k) (bs :: LoT k) m.
(ZipMatchFoldK f, Monoid m) =>
Folds m as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe m
forall (as :: LoT (* -> * -> *)) (bs :: LoT (* -> * -> *)) m.
Monoid m =>
Folds m as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe m
zipMatchFoldK (a -> a' -> m
f (a -> a' -> m)
-> Folds m (b ':&&: 'LoT0) (b' ':&&: 'LoT0)
-> Folds m (a ':&&: (b ':&&: 'LoT0)) (a' ':&&: (b' ':&&: 'LoT0))
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: b -> b' -> m
g (b -> b' -> m)
-> Folds m 'LoT0 'LoT0 -> Folds m (b ':&&: 'LoT0) (b' ':&&: 'LoT0)
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: Folds m 'LoT0 'LoT0
forall m. Folds m 'LoT0 'LoT0
F0)

-- | Check a relation on all paired components: 'Nothing' when the shapes
-- differ, as for 'zipMatchFoldK', and otherwise whether every component
-- satisfies its relation. The components are checked left to right, and the
-- check stops at the first that fails.
--
-- > zipMatchAllK = fmap getAll . zipMatchFoldK (coerce relations)
--
-- @since 0.6.0
zipMatchAllK :: forall f as bs. ZipMatchFoldK f => Folds Bool as bs -> f :@@: as -> f :@@: bs -> Maybe Bool
zipMatchAllK :: forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
ZipMatchFoldK f =>
Folds Bool as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe Bool
zipMatchAllK Folds Bool as bs
relations f :@@: as
x f :@@: bs
y = All -> Bool
getAll (All -> Bool) -> Maybe All -> Maybe Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall k (f :: k) (as :: LoT k) (bs :: LoT k) m.
(ZipMatchFoldK f, Monoid m) =>
Folds m as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe m
zipMatchFoldK @_ @f @as @bs (Folds Bool as bs -> Folds All as bs
forall a b. Coercible a b => a -> b
coerce Folds Bool as bs
relations) f :@@: as
x f :@@: bs
y
{-# INLINE zipMatchAllK #-}

-- | 'zipMatchAllK' specialised to functors.
--
-- >>> zipMatchAll1 (==) (Just 1) (Just (1 :: Int))
-- Just True
-- >>> zipMatchAll1 (==) [1, 2] [1, 3 :: Int]
-- Just False
-- >>> zipMatchAll1 (==) [1, 2] [1 :: Int]
-- Nothing
--
-- @since 0.6.0
zipMatchAll1 :: ZipMatchFoldK f => (a -> a' -> Bool) -> f a -> f a' -> Maybe Bool
zipMatchAll1 :: forall (f :: * -> *) a a'.
ZipMatchFoldK f =>
(a -> a' -> Bool) -> f a -> f a' -> Maybe Bool
zipMatchAll1 a -> a' -> Bool
f = Folds Bool (a ':&&: 'LoT0) (a' ':&&: 'LoT0)
-> (f :@@: (a ':&&: 'LoT0))
-> (f :@@: (a' ':&&: 'LoT0))
-> Maybe Bool
forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
ZipMatchFoldK f =>
Folds Bool as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe Bool
zipMatchAllK (a -> a' -> Bool
f (a -> a' -> Bool)
-> Folds Bool 'LoT0 'LoT0
-> Folds Bool (a ':&&: 'LoT0) (a' ':&&: 'LoT0)
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: Folds Bool 'LoT0 'LoT0
forall m. Folds m 'LoT0 'LoT0
F0)
{-# INLINE zipMatchAll1 #-}

-- | 'zipMatchAllK' specialised to bifunctors.
--
-- >>> zipMatchAll2 (==) (==) (Left 1) (Left (1 :: Int) :: Either Int Int)
-- Just True
-- >>> zipMatchAll2 (==) (==) (Left 1) (Right (1 :: Int) :: Either Int Int)
-- Nothing
--
-- @since 0.6.0
zipMatchAll2
  :: ZipMatchFoldK f
  => (a -> a' -> Bool)
  -> (b -> b' -> Bool)
  -> f a b -> f a' b' -> Maybe Bool
zipMatchAll2 :: forall (f :: * -> * -> *) a a' b b'.
ZipMatchFoldK f =>
(a -> a' -> Bool)
-> (b -> b' -> Bool) -> f a b -> f a' b' -> Maybe Bool
zipMatchAll2 a -> a' -> Bool
f b -> b' -> Bool
g = Folds Bool (a ':&&: (b ':&&: 'LoT0)) (a' ':&&: (b' ':&&: 'LoT0))
-> (f :@@: (a ':&&: (b ':&&: 'LoT0)))
-> (f :@@: (a' ':&&: (b' ':&&: 'LoT0)))
-> Maybe Bool
forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
ZipMatchFoldK f =>
Folds Bool as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe Bool
zipMatchAllK (a -> a' -> Bool
f (a -> a' -> Bool)
-> Folds Bool (b ':&&: 'LoT0) (b' ':&&: 'LoT0)
-> Folds Bool (a ':&&: (b ':&&: 'LoT0)) (a' ':&&: (b' ':&&: 'LoT0))
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: b -> b' -> Bool
g (b -> b' -> Bool)
-> Folds Bool 'LoT0 'LoT0
-> Folds Bool (b ':&&: 'LoT0) (b' ':&&: 'LoT0)
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: Folds Bool 'LoT0 'LoT0
forall m. Folds m 'LoT0 'LoT0
F0)
{-# INLINE zipMatchAll2 #-}

-- | Check a relation on some paired component: 'Nothing' when the shapes
-- differ, as for 'zipMatchFoldK', and otherwise whether some component
-- satisfies its relation. The components are checked left to right, and the
-- check stops at the first that succeeds.
--
-- > zipMatchAnyK = fmap getAny . zipMatchFoldK (coerce relations)
--
-- @since 0.6.0
zipMatchAnyK :: forall f as bs. ZipMatchFoldK f => Folds Bool as bs -> f :@@: as -> f :@@: bs -> Maybe Bool
zipMatchAnyK :: forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
ZipMatchFoldK f =>
Folds Bool as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe Bool
zipMatchAnyK Folds Bool as bs
relations f :@@: as
x f :@@: bs
y = Any -> Bool
getAny (Any -> Bool) -> Maybe Any -> Maybe Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall k (f :: k) (as :: LoT k) (bs :: LoT k) m.
(ZipMatchFoldK f, Monoid m) =>
Folds m as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe m
zipMatchFoldK @_ @f @as @bs (Folds Bool as bs -> Folds Any as bs
forall a b. Coercible a b => a -> b
coerce Folds Bool as bs
relations) f :@@: as
x f :@@: bs
y
{-# INLINE zipMatchAnyK #-}

-- | 'zipMatchAnyK' specialised to functors.
--
-- >>> zipMatchAny1 (==) [1, 2] [3, 2 :: Int]
-- Just True
-- >>> zipMatchAny1 (==) [1, 2] [3, 4 :: Int]
-- Just False
-- >>> zipMatchAny1 (==) [] [1 :: Int]
-- Nothing
--
-- @since 0.6.0
zipMatchAny1 :: ZipMatchFoldK f => (a -> a' -> Bool) -> f a -> f a' -> Maybe Bool
zipMatchAny1 :: forall (f :: * -> *) a a'.
ZipMatchFoldK f =>
(a -> a' -> Bool) -> f a -> f a' -> Maybe Bool
zipMatchAny1 a -> a' -> Bool
f = Folds Bool (a ':&&: 'LoT0) (a' ':&&: 'LoT0)
-> (f :@@: (a ':&&: 'LoT0))
-> (f :@@: (a' ':&&: 'LoT0))
-> Maybe Bool
forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
ZipMatchFoldK f =>
Folds Bool as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe Bool
zipMatchAnyK (a -> a' -> Bool
f (a -> a' -> Bool)
-> Folds Bool 'LoT0 'LoT0
-> Folds Bool (a ':&&: 'LoT0) (a' ':&&: 'LoT0)
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: Folds Bool 'LoT0 'LoT0
forall m. Folds m 'LoT0 'LoT0
F0)
{-# INLINE zipMatchAny1 #-}

-- | 'zipMatchAnyK' specialised to bifunctors.
--
-- >>> zipMatchAny2 (==) (==) (Right 1) (Right (2 :: Int) :: Either Int Int)
-- Just False
--
-- @since 0.6.0
zipMatchAny2
  :: ZipMatchFoldK f
  => (a -> a' -> Bool)
  -> (b -> b' -> Bool)
  -> f a b -> f a' b' -> Maybe Bool
zipMatchAny2 :: forall (f :: * -> * -> *) a a' b b'.
ZipMatchFoldK f =>
(a -> a' -> Bool)
-> (b -> b' -> Bool) -> f a b -> f a' b' -> Maybe Bool
zipMatchAny2 a -> a' -> Bool
f b -> b' -> Bool
g = Folds Bool (a ':&&: (b ':&&: 'LoT0)) (a' ':&&: (b' ':&&: 'LoT0))
-> (f :@@: (a ':&&: (b ':&&: 'LoT0)))
-> (f :@@: (a' ':&&: (b' ':&&: 'LoT0)))
-> Maybe Bool
forall {k} (f :: k) (as :: LoT k) (bs :: LoT k).
ZipMatchFoldK f =>
Folds Bool as bs -> (f :@@: as) -> (f :@@: bs) -> Maybe Bool
zipMatchAnyK (a -> a' -> Bool
f (a -> a' -> Bool)
-> Folds Bool (b ':&&: 'LoT0) (b' ':&&: 'LoT0)
-> Folds Bool (a ':&&: (b ':&&: 'LoT0)) (a' ':&&: (b' ':&&: 'LoT0))
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: b -> b' -> Bool
g (b -> b' -> Bool)
-> Folds Bool 'LoT0 'LoT0
-> Folds Bool (b ':&&: 'LoT0) (b' ':&&: 'LoT0)
forall {k1} a b m (as1 :: LoT k1) (bs1 :: LoT k1).
(a -> b -> m)
-> Folds m as1 bs1 -> Folds m (a ':&&: as1) (b ':&&: bs1)
:%: Folds Bool 'LoT0 'LoT0
forall m. Folds m 'LoT0 'LoT0
F0)
{-# INLINE zipMatchAny2 #-}