hypertypes-0.2.2: Typed ASTs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hyper.Class.ZipMatch

Description

A class to match term structures

Synopsis

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

default zipMatch :: (Generic1 h, ZipMatch (Rep1 h)) => (h # p) -> (h # q) -> Maybe (h # (p :*: q)) Source #

Instances

Instances details
ZipMatch Prune Source # 
Instance details

Defined in Hyper.Type.Prune

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Prune # p) -> (Prune # q) -> Maybe (Prune # (p :*: q)) Source #

ZipMatch Pure Source # 
Instance details

Defined in Hyper.Class.ZipMatch

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Pure # p) -> (Pure # q) -> Maybe (Pure # (p :*: q)) Source #

ZipMatch (App expr) Source # 
Instance details

Defined in Hyper.Syntax.App

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (App expr # p) -> (App expr # q) -> Maybe (App expr # (p :*: q)) Source #

ZipMatch (FuncType typ) Source # 
Instance details

Defined in Hyper.Syntax.FuncType

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (FuncType typ # p) -> (FuncType typ # q) -> Maybe (FuncType typ # (p :*: q)) Source #

Eq a => ZipMatch (Const a :: AHyperType -> Type) Source # 
Instance details

Defined in Hyper.Class.ZipMatch

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Const a # p) -> (Const a # q) -> Maybe (Const a # (p :*: q)) Source #

ZipMatch h => ZipMatch (Rec1 h) Source # 
Instance details

Defined in Hyper.Class.ZipMatch

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Rec1 h # p) -> (Rec1 h # q) -> Maybe (Rec1 h # (p :*: q)) Source #

(ZipMatch h0, ZipMatch h1, HTraversable h0, HFunctor h1) => ZipMatch (HCompose h0 h1) Source # 
Instance details

Defined in Hyper.Combinator.Compose

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (HCompose h0 h1 # p) -> (HCompose h0 h1 # q) -> Maybe (HCompose h0 h1 # (p :*: q)) Source #

Eq v => ZipMatch (Lam v expr) Source # 
Instance details

Defined in Hyper.Syntax.Lam

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Lam v expr # p) -> (Lam v expr # q) -> Maybe (Lam v expr # (p :*: q)) Source #

Eq v => ZipMatch (Let v expr) Source # 
Instance details

Defined in Hyper.Syntax.Let

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Let v expr # p) -> (Let v expr # q) -> Maybe (Let v expr # (p :*: q)) Source #

Eq h => ZipMatch (TermMap h expr) Source # 
Instance details

Defined in Hyper.Syntax.Map

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (TermMap h expr # p) -> (TermMap h expr # q) -> Maybe (TermMap h expr # (p :*: q)) Source #

Eq nomId => ZipMatch (FromNom nomId term) Source # 
Instance details

Defined in Hyper.Syntax.Nominal

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (FromNom nomId term # p) -> (FromNom nomId term # q) -> Maybe (FromNom nomId term # (p :*: q)) Source #

(Eq nomId, ZipMatch varTypes, HTraversable varTypes, HNodesConstraint varTypes ZipMatch, HNodesConstraint varTypes OrdQVar) => ZipMatch (NominalInst nomId varTypes) Source # 
Instance details

Defined in Hyper.Syntax.Nominal

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (NominalInst nomId varTypes # p) -> (NominalInst nomId varTypes # q) -> Maybe (NominalInst nomId varTypes # (p :*: q)) Source #

Eq nomId => ZipMatch (ToNom nomId term) Source # 
Instance details

Defined in Hyper.Syntax.Nominal

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (ToNom nomId term # p) -> (ToNom nomId term # q) -> Maybe (ToNom nomId term # (p :*: q)) Source #

Eq v => ZipMatch (Var v expr) Source # 
Instance details

Defined in Hyper.Syntax.Var

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (Var v expr # p) -> (Var v expr # q) -> Maybe (Var v expr # (p :*: q)) Source #

(ZipMatch a, ZipMatch b) => ZipMatch (a :*: b) Source # 
Instance details

Defined in Hyper.Class.ZipMatch

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). ((a :*: b) # p) -> ((a :*: b) # q) -> Maybe ((a :*: b) # (p :*: q)) Source #

(ZipMatch a, ZipMatch b) => ZipMatch (a :+: b) Source # 
Instance details

Defined in Hyper.Class.ZipMatch

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). ((a :+: b) # p) -> ((a :+: b) # q) -> Maybe ((a :+: b) # (p :*: q)) Source #

Eq key => ZipMatch (RowExtend key val rest) Source # 
Instance details

Defined in Hyper.Syntax.Row

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (RowExtend key val rest # p) -> (RowExtend key val rest # q) -> Maybe (RowExtend key val rest # (p :*: q)) Source #

Eq var => ZipMatch (TypedLam var typ expr) Source # 
Instance details

Defined in Hyper.Syntax.TypedLam

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (TypedLam var typ expr # p) -> (TypedLam var typ expr # q) -> Maybe (TypedLam var typ expr # (p :*: q)) Source #

ZipMatch h => ZipMatch (M1 i m h) Source # 
Instance details

Defined in Hyper.Class.ZipMatch

Methods

zipMatch :: forall (p :: HyperType) (q :: HyperType). (M1 i m h # p) -> (M1 i m h # q) -> Maybe (M1 i m h # (p :*: q)) Source #

zipMatch2 :: (ZipMatch h, HFunctor h) => (forall n. HWitness h n -> (p # n) -> (q # n) -> r # n) -> (h # p) -> (h # q) -> Maybe (h # r) Source #

ZipMatch variant of liftA2

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 #

A variant of zipMatch_ for HyperTypes with a single node type (avoids using RankNTypes)