···11-module ConstSymbol: SExpFunc.SYMBOL with type t = string = {
11+module SymbolAtom: SExpFunc.ATOM with type t = string = {
22 type t = string
33 type subst = Map.t<int, string>
44 let unify = (a, b) =>
···2323 let upshift = (t, _, ~from as _=?) => t
2424}
25252626-include SExpFunc.Make(ConstSymbol)
2626+include SExpFunc.Make(SymbolAtom)
+3-3
src/SExp.resi
···11// NOTE: ideally we want something like:
22-// include module type of SExpFunc.Make(ConstSymbol)
22+// include module type of SExpFunc.Make(ConstAtom)
33// this doesn't work because reasons. can come back to revisit
44// but i honestly suspect this is a rescript compiler bug.
5566-module Symbol: SExpFunc.SYMBOL with type t = string
66+module Atom: SExpFunc.ATOM with type t = string
77type rec t =
88- | Symbol(Symbol.t)
88+ | Atom(Atom.t)
99 | Compound({subexps: array<t>})
1010 | Var({idx: int})
1111 | Schematic({schematic: int, allowed: array<int>})
+26-26
src/SExpFunc.res
···11-module type SYMBOL = {
11+module type ATOM = {
22 type t
33 type subst = Map.t<int, t>
44 let unify: (t, t) => Seq.t<subst>
···1919 let cmp = Pervasives.compare
2020})
21212222-module Make = (Symbol: SYMBOL): {
2323- module Symbol: SYMBOL with type t = Symbol.t
2222+module Make = (Atom: ATOM): {
2323+ module Atom: ATOM with type t = Atom.t
24242525 type rec t =
2626- | Symbol(Symbol.t)
2626+ | Atom(Atom.t)
2727 | Compound({subexps: array<t>})
2828 | Var({idx: int})
2929 | Schematic({schematic: int, allowed: array<int>})
···3737 let mapTerms: (t, t => t) => t
3838} => {
3939 type rec t =
4040- | Symbol(Symbol.t)
4040+ | Atom(Atom.t)
4141 | Compound({subexps: array<t>})
4242 | Var({idx: int})
4343 | Schematic({schematic: int, allowed: array<int>})
4444 | Ghost
4545- module Symbol = Symbol
4545+ module Atom = Atom
4646 type meta = string
4747 type schematic = int
4848 type subst = Map.t<schematic, t>
···8181 | None => term
8282 | Some(found) => found
8383 }
8484- | Symbol(name) => {
8484+ | Atom(name) => {
8585 let symbolSubs =
8686 subst
8787 ->Map.entries
8888 ->Iterator.toArray
8989 ->Array.filterMap(((name, v)) =>
9090 switch v {
9191- | Symbol(v) => Some((name, v))
9191+ | Atom(v) => Some((name, v))
9292 | _ => None
9393 }
9494 )
9595 ->Map.fromArray
9696- Symbol(name->Symbol.substitute(symbolSubs))
9696+ Atom(name->Atom.substitute(symbolSubs))
9797 }
9898 | _ => term
9999 }
···122122 }
123123 let rec unifyTerm = (a: t, b: t): Seq.t<subst> =>
124124 switch (a, b) {
125125- | (Symbol(na), Symbol(nb)) =>
126126- Symbol.unify(na, nb)->Seq.map(subst => subst->Util.mapMapValues(v => Symbol(v)))
125125+ | (Atom(na), Atom(nb)) =>
126126+ Atom.unify(na, nb)->Seq.map(subst => subst->Util.mapMapValues(v => Atom(v)))
127127 | (Compound({subexps: xa}), Compound({subexps: xb})) if Array.length(xa) == Array.length(xb) =>
128128 unifyArray(Belt.Array.zip(xa, xb))
129129 | (Var({idx: ia}), Var({idx: ib})) if ia == ib => Seq.once(emptySubst)
···155155 }
156156 let unify = (a: t, b: t, ~gen as _=?) => unifyTerm(a, b)
157157158158- let rec lower = (term: t): Symbol.t =>
158158+ let rec lower = (term: t): Atom.t =>
159159 switch term {
160160- | Symbol(s) => s
161161- | Var({idx}) => Symbol.lowerVar(idx)
162162- | Schematic({schematic, allowed}) => Symbol.lowerSchematic(schematic, allowed)
160160+ | Atom(s) => s
161161+ | Var({idx}) => Atom.lowerVar(idx)
162162+ | Schematic({schematic, allowed}) => Atom.lowerSchematic(schematic, allowed)
163163 | Compound({subexps: [e1]}) => lower(e1)
164164- | _ => Symbol.ghost
164164+ | _ => Atom.ghost
165165 }
166166 let rec substDeBruijn = (term: t, substs: array<t>, ~from: int=0) =>
167167 switch term {
168168- | Symbol(s) => {
168168+ | Atom(s) => {
169169 let symbolSubsts = substs->Array.map(lower)
170170- Symbol(Symbol.substDeBruijn(s, symbolSubsts, ~from))
170170+ Atom(Atom.substDeBruijn(s, symbolSubsts, ~from))
171171 }
172172173173 | Compound({subexps}) =>
···195195 }
196196 let rec upshift = (term: t, amount: int, ~from: int=0) =>
197197 switch term {
198198- | Symbol(s) => Symbol(s->Symbol.upshift(amount, ~from))
198198+ | Atom(s) => Atom(s->Atom.upshift(amount, ~from))
199199 | Compound({subexps}) => Compound({subexps: Array.map(subexps, x => upshift(x, amount, ~from))})
200200 | Var({idx}) =>
201201 Var({
···246246 }
247247 let rec prettyPrint = (it: t, ~scope: array<string>) =>
248248 switch it {
249249- | Symbol(name) => Symbol.prettyPrint(name, ~scope)
249249+ | Atom(name) => Atom.prettyPrint(name, ~scope)
250250 | Var({idx}) => prettyPrintVar(idx, scope)
251251 | Schematic({schematic, allowed}) =>
252252 "?"
···266266 let symbolRegexpString = `^([^\\s()\\[\\]]+)`
267267 let varRegexpString = "^\\\\([0-9]+)$"
268268 let schematicRegexpString = "^\\?([0-9]+)$"
269269- type lexeme = LParen | RParen | VarT(int) | SymbolT(Symbol.t) | SchematicT(int)
269269+ type lexeme = LParen | RParen | VarT(int) | AtomT(Atom.t) | SchematicT(int)
270270 let nameRES = "^([^\\s.\\[\\]()]+)\\."
271271 let prettyPrintMeta = (str: string) => {
272272 String.concat(str, ".")
···322322 let regularSymb = () => {
323323 // FIX: not ideal to throw away symbol error message
324324 Console.log(("current", cur.contents))
325325- Symbol.parse(cur.contents, ~scope)
325325+ Atom.parse(cur.contents, ~scope)
326326 ->Util.Result.ok
327327 ->Option.map(((s, rest)) => {
328328 cur := rest
329329 Console.log(("parsed", s, cur.contents))
330330- SymbolT(s)
330330+ AtomT(s)
331331 })
332332 }
333333 switch checkVariable(symb) {
···362362 let rec parseExp = () => {
363363 let tok = peek()
364364 switch tok {
365365- | Some(SymbolT(s)) => {
365365+ | Some(AtomT(s)) => {
366366 let _ = lex()
367367- Some(Symbol(s))
367367+ Some(Atom(s))
368368 }
369369 | Some(VarT(idx)) => {
370370 let _ = lex()
···431431 let rec unifiesWithAnything = t =>
432432 switch t {
433433 | Schematic(_) => true
434434- | Symbol(s) => Symbol.unifiesWithAnything(s)
434434+ | Atom(s) => Atom.unifiesWithAnything(s)
435435 | Compound({subexps}) => subexps->Array.every(unifiesWithAnything)
436436 | _ => false
437437 }
+3-3
src/SExpView.res
···11-module ConstSymbol = SExp.Symbol
22-module ConstSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := SExp.Symbol = {
11+module ConstAtom = SExp.Atom
22+module ConstAtomView: SExpViewFunc.ATOM_VIEW with module Atom := SExp.Atom = {
33 type props = {name: string, scope: array<string>}
44 let make = (props: props) => React.string(props.name)
55}
6677-include SExpViewFunc.Make(ConstSymbol, ConstSymbolView, SExp)
77+include SExpViewFunc.Make(ConstAtom, ConstAtomView, SExp)
+1-1
src/SExpView.resi
···11-module ConstSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := SExp.Symbol
11+module ConstAtomView: SExpViewFunc.ATOM_VIEW with module Atom := SExp.Atom
2233include Signatures.TERM_VIEW with module Term := SExp
+8-8
src/SExpViewFunc.res
···11-module type SYMBOL_VIEW = {
22- module Symbol: SExpFunc.SYMBOL
33- type props = {name: Symbol.t, scope: array<string>}
11+module type ATOM_VIEW = {
22+ module Atom: SExpFunc.ATOM
33+ type props = {name: Atom.t, scope: array<string>}
44 let make: props => React.element
55}
6677module Make = (
88- Symbol: SExpFunc.SYMBOL,
99- SymbolView: SYMBOL_VIEW with module Symbol := Symbol,
88+ Atom: SExpFunc.ATOM,
99+ AtomView: ATOM_VIEW with module Atom := Atom,
1010 SExp: {
1111 type rec t =
1212- | Symbol(Symbol.t)
1212+ | Atom(Atom.t)
1313 | Compound({subexps: array<t>})
1414 | Var({idx: int})
1515 | Schematic({schematic: int, allowed: array<int>})
···7272 ->React.array}
7373 </span>
7474 | Var({idx}) => viewVar({idx, scope})
7575- | Symbol(name) =>
7575+ | Atom(name) =>
7676 <span className="term-const">
7777- <SymbolView name scope />
7777+ <AtomView name scope />
7878 </span>
7979 | Schematic({schematic: s, allowed: vs}) =>
8080 <span className="term-schematic">
···11-type stringSymbol = StringS(StringTerm.t) | ConstS(SExp.Symbol.t)
22-module StringSymbol: SExpFunc.SYMBOL with type t = stringSymbol
11+type stringAtom = StringS(StringTerm.t) | ConstS(SExp.Atom.t)
22+module StringAtom: SExpFunc.ATOM with type t = stringAtom
3344type rec t =
55- | Symbol(StringSymbol.t)
55+ | Atom(StringAtom.t)
66 | Compound({subexps: array<t>})
77 | Var({idx: int})
88 | Schematic({schematic: int, allowed: array<int>})
···1414 and type schematic = int
1515 and type subst = Map.t<int, t>
16161717-module Symbol: SExpFunc.SYMBOL with type t := StringSymbol.t
1717+module Atom: SExpFunc.ATOM with type t := StringAtom.t
1818let mapTerms: (t, t => t) => t
+4-4
src/StringTermJView.res
···11-module StringSymbolView: SExpViewFunc.SYMBOL_VIEW with module Symbol := StringSExp.StringSymbol = {
22- type props = {name: StringSExp.StringSymbol.t, scope: array<string>}
11+module StringAtomView: SExpViewFunc.ATOM_VIEW with module Atom := StringSExp.StringAtom = {
22+ type props = {name: StringSExp.StringAtom.t, scope: array<string>}
33 let make = ({name, scope}: props) =>
44 switch name {
55 | StringSExp.StringS(term) => <StringTermView term scope />
66- | StringSExp.ConstS(name) => <SExpView.ConstSymbolView name scope />
66+ | StringSExp.ConstS(name) => <SExpView.ConstAtomView name scope />
77 }
88}
991010-module View = SExpViewFunc.Make(StringSExp.StringSymbol, StringSymbolView, StringSExp)
1010+module View = SExpViewFunc.Make(StringSExp.StringAtom, StringAtomView, StringSExp)
11111212module TermView = View
1313type props = {