| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hyper.Class.ZipMatch
Description
A class to match term structures
Synopsis
- class ZipMatch h where
- zipMatch2 :: (ZipMatch h, HFunctor h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> r # n) -> (h # p) -> (h # q) -> Maybe (h # r)
- zipMatchA :: (Applicative f, ZipMatch h, HTraversable h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> f (r # n)) -> (h # p) -> (h # q) -> Maybe (f (h # r))
- zipMatch_ :: (Applicative f, ZipMatch h, HFoldable h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> f ()) -> (h # p) -> (h # q) -> Maybe (f ())
- zipMatch1_ :: (Applicative f, ZipMatch h, HFoldable h, HNodesConstraint h ((~) n)) => ((p # n) -> (q # n) -> f ()) -> (h # p) -> (h # q) -> Maybe (f ())
Documentation
class ZipMatch h where Source #
A class to match term structures.
Similar to a partial version of Apply but the semantics are different -
when the terms contain plain values, hzip would append them,
but zipMatch would compare them and only produce a result if they match.
The TemplateHaskell generators makeHApply and makeZipMatch
create the instances according to these semantics.
Minimal complete definition
Nothing
Methods
zipMatch :: (h # p) -> (h # q) -> Maybe (h # (p :*: q)) Source #
Compare two structures
>>>zipMatch (NewPerson p0) (NewPerson p1)Just (NewPerson (Pair p0 p1))>>>zipMatch (NewPerson p) (NewCake c)Nothing
Instances
zipMatch2 :: (ZipMatch h, HFunctor h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> r # n) -> (h # p) -> (h # q) -> Maybe (h # r) Source #
zipMatchA :: (Applicative f, ZipMatch h, HTraversable h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> f (r # n)) -> (h # p) -> (h # q) -> Maybe (f (h # r)) Source #
An Applicative variant of zipMatch2
zipMatch_ :: (Applicative f, ZipMatch h, HFoldable h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> f ()) -> (h # p) -> (h # q) -> Maybe (f ()) Source #
A variant of zipMatchA where the Applicative actions do not contain results
zipMatch1_ :: (Applicative f, ZipMatch h, HFoldable h, HNodesConstraint h ((~) n)) => ((p # n) -> (q # n) -> f ()) -> (h # p) -> (h # q) -> Maybe (f ()) Source #