···1717let strip: t => (t, array<t>)
1818let app: (t, array<t>) => t
1919let mkvars: int => array<t>
2020+let mapTerms: (t, t => t) => t
2021// exposed for testing purposes
2122exception UnifyFail(string)
2223let substAdd: (subst, schematic, t) => subst
+1-3
src/HOTermJView.resi
···11-include Signatures.JUDGMENT_VIEW
22- with module Term := HOTerm
33- and module Judgment := TermAsJudgment.HOTermJ
11+include Signatures.JUDGMENT_VIEW with module Term := HOTerm and module Judgment := HOTerm
+13-17
src/HOTermMethod.res
···22open Method
3344module MakeRewriteHOTerm = (
55- Judgment: JUDGMENT with module Term := HOTerm and type subst = HOTerm.subst and type t = HOTerm.t,
55+ Judgment: JUDGMENT with module Term := HOTerm and type t = HOTerm.t,
66 Config: {
77 let keyword: string
88 let reversed: bool
···43434444 type t<'a> = {
4545 equalityName: string,
4646- instantiation: array<Judgment.substCodom>,
4646+ instantiation: array<Term.t>,
4747 subgoal: 'a,
4848 }
4949···5757 }
5858 }
59596060- let substitute = (it: t<'a>, subst: Judgment.subst) => {
6060+ let substitute = (it: t<'a>, subst: Term.subst) => {
6161 {
6262 equalityName: it.equalityName,
6363- instantiation: it.instantiation->Array.map(t => t->Judgment.substituteSubstCodom(subst)),
6363+ instantiation: it.instantiation->Array.map(t => t->Judgment.substitute(subst)),
6464 subgoal: it.subgoal,
6565 }
6666 }
···7272 ~subprinter: ('a, ~scope: array<HOTerm.meta>, ~indentation: int=?) => string,
7373 ) => {
7474 let ind = String.repeat(" ", indentation)
7575- let args = it.instantiation->Array.map(t => Judgment.prettyPrintSubstCodom(t, ~scope))
7575+ let args = it.instantiation->Array.map(t => Term.prettyPrint(t, ~scope))
7676 let argsStr = if Array.length(args) > 0 {
7777 " " ++ Array.join(args, " ")
7878 } else {
···9898 let instantiation = []
9999 let it = ref(Error(""))
100100 while {
101101- it := Judgment.parseSubstCodom(cur.contents, ~scope, ~gen)
101101+ it := Term.parse(cur.contents, ~scope, ~gen)
102102 it.contents->Result.isOk
103103 } {
104104 let (val, rest) = it.contents->Result.getExn
···157157 }
158158159159 let apply = (ctx: Context.t, j: Judgment.t, gen: HOTerm.gen, f: Rule.t => 'a) => {
160160- let ret: Dict.t<(t<'a>, Judgment.subst)> = Dict.make()
160160+ let ret: Dict.t<(t<'a>, Term.subst)> = Dict.make()
161161162162 ctx
163163 ->Context.facts
···246246}
247247248248module Rewrite = (
249249- Judgment: JUDGMENT with module Term := HOTerm and type subst = HOTerm.subst and type t = HOTerm.t,
249249+ Judgment: JUDGMENT with module Term := HOTerm and type t = HOTerm.t,
250250) => MakeRewriteHOTerm(
251251 Judgment,
252252 {
···256256)
257257258258module RewriteReverse = (
259259- Judgment: JUDGMENT with module Term := HOTerm and type subst = HOTerm.subst and type t = HOTerm.t,
259259+ Judgment: JUDGMENT with module Term := HOTerm and type t = HOTerm.t,
260260) => MakeRewriteHOTerm(
261261 Judgment,
262262 {
···265265 },
266266)
267267268268-module ConstructorNeq = (
269269- Judgment: JUDGMENT with module Term := HOTerm and type subst = HOTerm.subst and type t = HOTerm.t,
270270-) => {
268268+module ConstructorNeq = (Judgment: JUDGMENT with module Term := HOTerm and type t = HOTerm.t) => {
271269 module Term = HOTerm
272270 module Rule = Rule.Make(HOTerm, Judgment)
273271 module Context = Context(HOTerm, Judgment)
···321319322320 let map = (it: t<'a>, _f: 'a => 'b): t<'b> => it
323321324324- let substitute = (it: t<'a>, _subst: Judgment.subst) => it
322322+ let substitute = (it: t<'a>, _subst: Term.subst) => it
325323326324 let prettyPrint = (_it: t<'a>, ~scope as _, ~indentation=0, ~subprinter as _) =>
327325 String.repeat(" ", indentation)->String.concat("constructor_neq")
···353351 }
354352}
355353356356-module ConstructorInj = (
357357- Judgment: JUDGMENT with module Term := HOTerm and type subst = HOTerm.subst and type t = HOTerm.t,
358358-) => {
354354+module ConstructorInj = (Judgment: JUDGMENT with module Term := HOTerm and type t = HOTerm.t) => {
359355 module Rule = Rule.Make(HOTerm, Judgment)
360356 module Context = Context(HOTerm, Judgment)
361357···370366371367 let map = (it: t<'a>, _f: 'a => 'b): t<'b> => it
372368373373- let substitute = (it: t<'a>, _subst: Judgment.subst) => it
369369+ let substitute = (it: t<'a>, _subst: HOTerm.subst) => it
374370375371 let prettyPrint = (it: t<'a>, ~scope as _, ~indentation=0, ~subprinter as _) =>
376372 String.repeat(" ", indentation)->String.concat(
···2222}
23232424include SExpFunc.Make(ConstSymbol)
2525-let pSymbol = s => s->ConstSymbol.parse(~scope=[])->Result.getExn->Pair.first
2626-let symbol = s => s->pSymbol->Symbol
2727-let getSymbol = s => s->ConstSymbol.prettyPrint(~scope=[])
+18-7
src/SExp.resi
···11-// TODO: i only added the with type t = string later.
22-// may remove need for helpers down bottom
33-module ConstSymbol: SExpFunc.SYMBOL with type t = string
11+// NOTE: ideally we want something like:
22+// include module type of SExpFunc.Make(ConstSymbol)
33+// this doesn't work because reasons. can come back to revisit
44+// but i honestly suspect this is a rescript compiler bug.
55+66+module Symbol: SExpFunc.SYMBOL with type t = string
77+type rec t =
88+ | Symbol(Symbol.t)
99+ | Compound({subexps: array<t>})
1010+ | Var({idx: int})
1111+ | Schematic({schematic: int, allowed: array<int>})
1212+ | Ghost
41355-include module type of SExpFunc.Make(ConstSymbol)
66-let symbol: string => t
77-let pSymbol: string => ConstSymbol.t
88-let getSymbol: ConstSymbol.t => string
1414+include Signatures.TERM
1515+ with type t := t
1616+ and type meta = string
1717+ and type schematic = int
1818+ and type subst = Map.t<int, t>
1919+let mapTerms: (t, t => t) => t
+5-1
src/SExpFunc.res
···1818})
19192020module Make = (Symbol: SYMBOL): {
2121+ module Symbol: SYMBOL with type t = Symbol.t
2222+2123 type rec t =
2224 | Symbol(Symbol.t)
2325 | Compound({subexps: array<t>})
2426 | Var({idx: int})
2527 | Schematic({schematic: int, allowed: array<int>})
2628 | Ghost
2727- module Symbol: SYMBOL with type t := Symbol.t
2929+2830 include Signatures.TERM
2931 with type t := t
3032 and type meta = string
3133 and type schematic = int
3234 and type subst = Map.t<int, t>
3535+ let mapTerms: (t, t => t) => t
3336} => {
3437 type rec t =
3538 | Symbol(Symbol.t)
···423426 }
424427425428 let ghostTerm = Ghost
429429+ let mapTerms = (t, f) => f(t)
426430}
+1-3
src/SExpJView.resi
···11-include Signatures.JUDGMENT_VIEW
22- with module Term := SExp
33- and module Judgment := TermAsJudgment.SExpJ
11+include Signatures.JUDGMENT_VIEW with module Term := SExp and module Judgment := SExp
+3-3
src/SExpView.res
···11-module ConstSymbol = SExp.ConstSymbol
22-module ConstSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := SExp.ConstSymbol = {
33- type props = {name: ConstSymbol.t, scope: array<string>}
11+module ConstSymbol = SExp.Symbol
22+module ConstSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := SExp.Symbol = {
33+ type props = {name: string, scope: array<string>}
44 let make = (props: props) => React.string(props.name)
55}
66
+1-1
src/SExpView.resi
···11-module ConstSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := SExp.ConstSymbol
11+module ConstSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := SExp.Symbol
2233include Signatures.TERM_VIEW with module Term := SExp
+14-1
src/SExpViewFunc.res
···77module Make = (
88 Symbol: SExpFunc.SYMBOL,
99 SymbolView: SYMBOL_VIEW with module Symbol := Symbol,
1010- SExp: module type of SExpFunc.Make(Symbol),
1010+ SExp: {
1111+ type rec t =
1212+ | Symbol(Symbol.t)
1313+ | Compound({subexps: array<t>})
1414+ | Var({idx: int})
1515+ | Schematic({schematic: int, allowed: array<int>})
1616+ | Ghost
1717+ include Signatures.TERM
1818+ with type t := t
1919+ and type meta = string
2020+ and type schematic = int
2121+ and type subst = Map.t<int, t>
2222+ let mapTerms: (t, t => t) => t
2323+ },
1124): {
1225 include Signatures.TERM_VIEW with module Term := SExp
1326} => {
···3030module type JUDGMENT = {
3131 module Term: TERM
3232 type t
3333- type subst
3434- type substCodom
3535- type schematic = Term.schematic
3636- type meta = Term.meta
3737- let mapSubst: (subst, substCodom => substCodom) => subst
3838- let mergeSubsts: (subst, subst) => subst
3939- let substitute: (t, subst) => t
4040- let substituteSubstCodom: (substCodom, subst) => substCodom
3333+ let substitute: (t, Term.subst) => t
4134 let equivalent: (t, t) => bool
4242- let unify: (t, t, ~gen: Term.gen=?) => Seq.t<subst>
4343- let substDeBruijn: (t, array<substCodom>, ~from: int=?) => t
3535+ let unify: (t, t, ~gen: Term.gen=?) => Seq.t<Term.subst>
3636+ let substDeBruijn: (t, array<Term.t>, ~from: int=?) => t
4437 let reduce: t => t
4538 let upshift: (t, int, ~from: int=?) => t
4646- let upshiftSubstCodom: (substCodom, int, ~from: int=?) => substCodom
4747- let placeSubstCodom: (schematic, ~scope: array<meta>) => substCodom
4839 // Map a function over all terms in the judgment
4040+ // NOTE(josh): we should return to whether this is necessary.
4941 let mapTerms: (t, Term.t => Term.t) => t
5042 let parse: (string, ~scope: array<Term.meta>, ~gen: Term.gen=?) => result<(t, string), string>
5151- let parseSubstCodom: (
5252- string,
5353- ~scope: array<Term.meta>,
5454- ~gen: Term.gen=?,
5555- ) => result<(substCodom, string), string>
5643 let prettyPrint: (t, ~scope: array<Term.meta>) => string
5757- let prettyPrintSubstCodom: (substCodom, ~scope: array<Term.meta>) => string
5858- let ghostJudgment: t
4444+ let ghostTerm: t
5945}
60466147module type TERM_VIEW = {
···11-type stringSymbol = StringS(StringTerm.t) | ConstS(SExp.ConstSymbol.t)
11+type stringSymbol = StringS(StringTerm.t) | ConstS(SExp.Symbol.t)
22module StringSymbol: SExpFunc.SYMBOL with type t = stringSymbol
3344-include module type of SExpFunc.Make(StringSymbol)
44+type rec t =
55+ | Symbol(StringSymbol.t)
66+ | Compound({subexps: array<t>})
77+ | Var({idx: int})
88+ | Schematic({schematic: int, allowed: array<int>})
99+ | Ghost
1010+1111+include Signatures.TERM
1212+ with type t := t
1313+ and type meta = string
1414+ and type schematic = int
1515+ and type subst = Map.t<int, t>
1616+1717+module Symbol: SExpFunc.SYMBOL with type t := StringSymbol.t
1818+let mapTerms: (t, t => t) => t
+1-3
src/StringTermJView.resi
···11-include Signatures.JUDGMENT_VIEW
22- with module Term := StringSExp
33- and module Judgment := TermAsJudgment.StringSExpJ
11+include Signatures.JUDGMENT_VIEW with module Term := StringSExp and module Judgment := StringSExp
-19
src/TermAsJudgment.res
···11-open Signatures
22-33-module Make = (Term: TERM): (
44- JUDGMENT with module Term := Term and type t = Term.t and type subst = Term.subst
55-) => {
66- include Term
77- type substCodom = Term.t
88- let prettyPrintSubstCodom = Term.prettyPrint
99- let parseSubstCodom = Term.parse
1010- let placeSubstCodom = Term.place
1111- let upshiftSubstCodom = Term.upshift
1212- let substituteSubstCodom = Term.substitute
1313- let mapTerms = (t: Term.t, f: Term.t => Term.t): Term.t => f(t)
1414- let ghostJudgment = Term.ghostTerm
1515-}
1616-1717-module SExpJ = Make(SExp)
1818-module HOTermJ = Make(HOTerm)
1919-module StringSExpJ = Make(StringSExp)
+5-5
tests/SExpTest.res
···44module Util = TestUtil.MakeTerm(SExp)
5566zoraBlock("parse symbol", t => {
77- t->block("single char", t => t->Util.testParse("x", symbol("x")))
88- t->block("multi char", t => t->Util.testParse("xyz", symbol("xyz")))
99- t->block("judgement terminal", t => t->Util.testParse("a]", symbol("a"), ~expectRemaining="]"))
77+ t->block("single char", t => t->Util.testParse("x", Symbol("x")))
88+ t->block("multi char", t => t->Util.testParse("xyz", Symbol("xyz")))
99+ t->block("judgement terminal", t => t->Util.testParse("a]", Symbol("a"), ~expectRemaining="]"))
1010})
11111212zoraBlock("parse var", t => {
···27272828zoraBlock("parse compound", t => {
2929 t->block("unit", t => t->Util.testParse("()", Compound({subexps: []})))
3030- t->block("single", t => t->Util.testParse("(a)", Compound({subexps: [symbol("a")]})))
3030+ t->block("single", t => t->Util.testParse("(a)", Compound({subexps: [Symbol("a")]})))
3131 t->block("multiple", t => {
3232 t->Util.testParse(
3333 "(a \\1 ?1())",
3434 Compound({
3535- subexps: [symbol("a"), Var({idx: 1}), Schematic({schematic: 1, allowed: []})],
3535+ subexps: [Symbol("a"), Var({idx: 1}), Schematic({schematic: 1, allowed: []})],
3636 }),
3737 )
3838 })