GF.Grammar.Macros: add function composPattOp

For Patt, analogous to composOp for Term.
This commit is contained in:
hallgren
2012-10-24 22:40:18 +00:00
parent 9f8c0f86f1
commit 619c341ee9

View File

@@ -483,6 +483,21 @@ composOp co trm =
ImplArg t -> liftM ImplArg (co t)
_ -> return trm -- covers K, Vr, Cn, Sort, EPatt
composPattOp :: Monad m => (Patt -> m Patt) -> Patt -> m Patt
composPattOp op patt =
case patt of
PC c ps -> liftM (PC c) (mapM op ps)
PP qc ps -> liftM (PP qc) (mapM op ps)
PR as -> liftM PR (mapPairsM op as)
PT ty p -> liftM (PT ty) (op p)
PAs x p -> liftM (PAs x) (op p)
PImplArg p -> liftM PImplArg (op p)
PNeg p -> liftM PNeg (op p)
PAlt p1 p2 -> liftM2 PAlt (op p1) (op p2)
PSeq p1 p2 -> liftM2 PSeq (op p1) (op p2)
PRep p -> liftM PRep (op p)
_ -> return patt -- converts cases without subpatterns
getTableType :: TInfo -> Err Type
getTableType i = case i of
TTyped ty -> return ty