Module("annotation-props",[Imports([Import("list"),Import("annotations"),Import("tuple"),Import("conditional")]),Strategies([SDefNoArgs("valid-props-term",AnnoCong(Id,StrategyCurly(CallNoArgs(SVar("valid-props"))))),SDefNoArgs("valid-props",Call(SVar("risky"),[Build(NoAnnoList(Str("\"Not a valid properties annotation: \""))),Seq(CallNoArgs(SVar("is-list")),Call(SVar("map"),[Match(NoAnnoList(Tuple([Wld,Wld])))]))])),SDefNoArgs("get-props",Call(SVar("if-annotation"),[CallNoArgs(SVar("get-annotations")),Build(NoAnnoList(List([])))])),SDef("preserve-props",[DefaultVarDec("s")],Call(SVar("preserve-annotation"),[CallNoArgs(SVar("s"))])),SDef("merge-props",[DefaultVarDec("s")],Call(SVar("if-annotation"),[Call(SVar("Merge-Props"),[CallNoArgs(SVar("s"))]),CallNoArgs(SVar("s"))])),SDef("has-prop",[DefaultVarDec("p")],Where(Call(SVar("get-prop"),[CallNoArgs(SVar("p"))]))),SDef("has-prop",[DefaultVarDec("p"),DefaultVarDec("c")],Where(Seq(Call(SVar("get-prop"),[CallNoArgs(SVar("p"))]),CallNoArgs(SVar("c"))))),SDef("get-prop",[DefaultVarDec("p")],Seq(CallNoArgs(SVar("get-annotations")),BA(CallNoArgs(SVar("lookup")),NoAnnoList(Tuple([App(CallNoArgs(SVar("p")),NoAnnoList(Tuple([]))),RootApp(Id)]))))),SDef("apply-prop",[DefaultVarDec("p"),DefaultVarDec("s")],Call(SVar("if-annotation"),[Call(SVar("apply-prop-existing"),[CallNoArgs(SVar("p")),CallNoArgs(SVar("s"))]),Id])),SDef("replace-prop",[DefaultVarDec("p"),DefaultVarDec("v")],Call(SVar("apply-prop"),[CallNoArgs(SVar("p")),CallNoArgs(SVar("v"))])),SDef("add-prop",[DefaultVarDec("p"),DefaultVarDec("v")],Call(SVar("if-annotation"),[Call(SVar("add-prop-existing"),[CallNoArgs(SVar("p")),CallNoArgs(SVar("v"))]),Call(SVar("add-prop-empty"),[CallNoArgs(SVar("p")),CallNoArgs(SVar("v"))])])),SDef("set-prop",[DefaultVarDec("p"),DefaultVarDec("v")],GuardedLChoice(Call(SVar("has-prop"),[CallNoArgs(SVar("p"))]),Call(SVar("replace-prop"),[CallNoArgs(SVar("p")),CallNoArgs(SVar("v"))]),Call(SVar("add-prop"),[CallNoArgs(SVar("p")),CallNoArgs(SVar("v"))])))]),Strategies([SDefNoArgs("is-same-prop",Match(NoAnnoList(Tuple([NoAnnoList(Tuple([Var("p"),Wld])),NoAnnoList(Tuple([Var("p"),Wld]))])))),SDef("is-prop",[DefaultVarDec("p")],Where(Seq(Build(NoAnnoList(Tuple([RootApp(Seq(Id,CallNoArgs(SVar("Fst")))),App(CallNoArgs(SVar("p")),NoAnnoList(Tuple([])))]))),CallNoArgs(SVar("eq"))))),SDef("apply-prop-existing",[DefaultVarDec("p"),DefaultVarDec("s")],AnnoCong(Id,StrategyCurly(Call(SVar("map"),[Call(SVar("apply-2-prop"),[Call(SVar("is-prop"),[CallNoArgs(SVar("p"))]),CallNoArgs(SVar("s"))])])))),SDef("apply-2-prop",[DefaultVarDec("c"),DefaultVarDec("s")],GuardedLChoice(Where(CallNoArgs(SVar("c"))),TupleCong(Id,[CallNoArgs(SVar("s"))]),Id)),SDef("apply-2-prop",[DefaultVarDec("s")],TupleCong(Id,[CallNoArgs(SVar("s"))])),SDef("add-prop-existing",[DefaultVarDec("p"),DefaultVarDec("v")],AnnoCong(Id,StrategyCurly(Build(NoAnnoList(ListTail([NoAnnoList(Tuple([App(CallNoArgs(SVar("p")),NoAnnoList(Tuple([]))),App(CallNoArgs(SVar("v")),NoAnnoList(Tuple([])))]))],RootApp(Id))))))),SDef("add-prop-empty",[DefaultVarDec("p"),DefaultVarDec("v")],Seq(Match(Var("t")),Build(AnnoList(Var("t"),[NoAnnoList(Tuple([App(CallNoArgs(SVar("p")),NoAnnoList(Tuple([]))),App(CallNoArgs(SVar("v")),NoAnnoList(Tuple([])))]))])))),SDefNoArgs("props-union",Seq(Match(NoAnnoList(Tuple([Var("ps1"),Var("ps2")]))),BA(CallNoArgs(SVar("union")),NoAnnoList(Tuple([Var("ps1"),App(Call(SVar("diff"),[CallNoArgs(SVar("is-same-prop"))]),NoAnnoList(Tuple([Var("ps2"),Var("ps1")])))])))))]),Rules([RDef("Merge-Props",[DefaultVarDec("s")],Rule(AnnoList(Var("t"),[Var(ListVar("p1*"))]),AnnoList(Var("r"),[Var(ListVar("p2*"))]),Seq(AM(BA(CallNoArgs(SVar("s")),Var("t")),Var("r")),AM(BA(CallNoArgs(SVar("props-union")),NoAnnoList(Tuple([App(CallNoArgs(SVar("get-props")),Var("r")),NoAnnoList(List([Var(ListVar("p1*"))]))]))),NoAnnoList(List([Var(ListVar("p2*"))]))))))])])
