Safe Haskell | None |
---|---|
Language | Haskell2010 |
Kind-polymorphic syntactic (first-order) unification.
Synopsis
- module Data.ZipMatchK.Mappings
- class ZipMatchK (f :: k) where
- 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)
- zipMatchViaEq :: forall {k} a (as :: LoT k) (bs :: LoT k) (cs :: LoT k). Eq a => 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
- zipMatchWith1 :: (Traversable f, ZipMatchK f) => (a -> a' -> Maybe a'') -> f a -> f a' -> Maybe (f a'')
- zipMatch1 :: (Traversable f, ZipMatchK f) => f a -> f a' -> Maybe (f (a, a'))
- zipMatchWith2 :: (Bitraversable f, ZipMatchK f) => (a -> a' -> Maybe a'') -> (b -> b' -> Maybe b'') -> f a b -> f a' b' -> Maybe (f a'' b'')
- zipMatch2 :: (Bitraversable f, ZipMatchK f) => f a b -> f a' b' -> Maybe (f (a, a') (b, b'))
Documentation
module Data.ZipMatchK.Mappings
class ZipMatchK (f :: k) where Source #
Kind-polymorphic syntactic (first-order) unification of two values.
Note: f
is expected to be a traversable n-functor,
but at the moment we lack a TraversableK
constraint.
Nothing
zipMatchWithK :: forall (as :: LoT k) (bs :: LoT k) (cs :: LoT k). Mappings as bs cs -> (f :@@: as) -> (f :@@: bs) -> Maybe (f :@@: cs) Source #
Perform one level of equality testing:
Instances
ZipMatchK Either Source # | |
ZipMatchK (,) Source # | |
ZipMatchK NonEmpty Source # | |
ZipMatchK Maybe Source # | |
ZipMatchK [] Source # | |
ZipMatchK a => ZipMatchK (Either a :: Type -> Type) Source # | |
ZipMatchK a => ZipMatchK ((,) a :: Type -> Type) Source # | |
(Traversable f, Traversable g, ZipMatchK f, ZipMatchK g) => ZipMatchK (Product f g :: Type -> Type) Source # | Note: instance is limited to |
(Traversable f, Traversable g, ZipMatchK f, ZipMatchK g) => ZipMatchK (Sum f g :: Type -> Type) Source # | Note: instance is limited to |
(Bitraversable f, Bitraversable g, ZipMatchK f, ZipMatchK g) => ZipMatchK (Product f g :: Type -> Type -> Type) Source # | Note: instance is limited to |
(Bitraversable f, Bitraversable g, ZipMatchK f, ZipMatchK g) => ZipMatchK (Sum f g :: Type -> Type -> Type) Source # | Note: instance is limited to |
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) Source #
Perform one level of equality testing for two values and pair up components using (,)
:
zipMatchK = zipMatchWithK (\x y -> Just (,) :^: M0)
Specializations
Unification of plain Type
s
zipMatchViaEq :: forall {k} a (as :: LoT k) (bs :: LoT k) (cs :: LoT k). Eq a => Mappings as bs cs -> a -> a -> Maybe a Source #
Unify values via Eq
.
Can be used as an implementation of zipMatchWithK
when k =
.Type
zipMatchViaChooseLeft :: forall {k} (as :: LoT k) (bs :: LoT k) (cs :: LoT k) a. Mappings as bs cs -> a -> a -> Maybe a Source #
Always successfully unify any two values of type a
by preferring the left value.
Can be used as an implementation of zipMatchWithK
when k =
.Type
Unification of Functor
s
zipMatchWith1 :: (Traversable f, ZipMatchK f) => (a -> a' -> Maybe a'') -> f a -> f a' -> Maybe (f a'') Source #
zipMatchWithK
specialised to functors.
Note: Traversable
is a morally correct constraint here.
zipMatch1 :: (Traversable f, ZipMatchK f) => f a -> f a' -> Maybe (f (a, a')) Source #
zipMatchK
specialised to functors.
Note: Traversable
is a morally correct constraint here.
Unification of Bifunctor
s
zipMatchWith2 :: (Bitraversable f, ZipMatchK f) => (a -> a' -> Maybe a'') -> (b -> b' -> Maybe b'') -> f a b -> f a' b' -> Maybe (f a'' b'') Source #
zipMatchWithK
specialised to bifunctors.
Note: Bitraversable
is a morally correct constraint here.
zipMatch2 :: (Bitraversable f, ZipMatchK f) => f a b -> f a' b' -> Maybe (f (a, a') (b, b')) Source #
zipMatchK
specialised to bifunctors.
Note: Bitraversable
is a morally correct constraint here.