···11-type t = StringS(StringA.Atom.t) | ConstS(string)
22-33-module Atom: SExpFunc.ATOM with type t = t = {
44- type t = t
55- type subst = Map.t<int, t>
66- type gen = ref<int>
77- let parse = (s, ~scope, ~gen: option<gen>=?) => {
88- StringA.Atom.parse(s, ~scope, ~gen?)
99- ->Result.map(((r, rest)) => (StringS(r), rest))
1010- ->Util.Result.or(() =>
1111- Symbolic.Atom.parse(s, ~scope, ~gen?)->Result.map(((r, rest)) => (ConstS(r), rest))
1212- )
1313- }
1414- let prettyPrint = (s, ~scope) =>
1515- switch s {
1616- | StringS(s) => StringA.Atom.prettyPrint(s, ~scope)
1717- | ConstS(s) => Symbolic.Atom.prettyPrint(s, ~scope)
1818- }
1919- let unify = (s1, s2, ~gen=?) =>
2020- switch (s1, s2) {
2121- | (StringS(s1), StringS(s2)) =>
2222- StringA.Atom.unify(s1, s2, ~gen?)->Seq.map(subst => subst->Util.mapMapValues(v => StringS(v)))
2323- | (ConstS(s1), ConstS(s2)) =>
2424- Symbolic.Atom.unify(s1, s2, ~gen?)->Seq.map(subst => subst->Util.mapMapValues(v => ConstS(v)))
2525- | (_, _) => Seq.empty
2626- }
2727- let substitute = (s, subst: subst) =>
2828- switch s {
2929- | StringS(s) => {
3030- let stringSubs =
3131- subst
3232- ->Map.entries
3333- ->Iterator.toArrayWithMapper(((i, v)) =>
3434- switch v {
3535- | StringS(s) => Some((i, s))
3636- | _ => None
3737- }
3838- )
3939- ->Array.keepSome
4040- ->Map.fromArray
4141- StringS(StringA.Atom.substitute(s, stringSubs))
4242- }
4343- | ConstS(s) => ConstS(s)
4444- }
4545- let upshift = (s, amount: int, ~from=?) =>
4646- switch s {
4747- | StringS(s) => StringS(s->StringA.Atom.upshift(amount, ~from?))
4848- | ConstS(s) => ConstS(s)
4949- }
5050- let lowerVar = idx => Some(StringS([StringA.Var({idx: idx})]))
5151- let lowerSchematic = (schematic, allowed) => Some(
5252- StringS([StringA.Schematic({schematic, allowed})]),
5353- )
5454- let substDeBruijn = (s, substs: array<option<t>>, ~from=?) =>
5555- switch s {
5656- | StringS(s) => {
5757- let stringSubs = substs->Array.map(s =>
5858- switch s {
5959- | Some(StringS(s)) => Some(s)
6060- | _ => None
6161- }
6262- )
6363- StringS(StringA.Atom.substDeBruijn(s, stringSubs, ~from?))
6464- }
6565- | ConstS(s) => ConstS(s)
6666- }
6767- let concrete = s =>
6868- switch s {
6969- | StringS(s) => StringA.Atom.concrete(s)
7070- | ConstS(_) => false
7171- }
7272-}
7373-7474-module AtomView: SExpViewFunc.ATOM_VIEW with module Atom := Atom = {
7575- type props = {name: Atom.t, scope: array<string>}
7676- let make = ({name, scope}: props) =>
7777- switch name {
7878- | StringS(name) => <StringA.AtomView name scope />
7979- | ConstS(name) => <Symbolic.AtomView name scope />
8080- }
8181-}
-3
src/StringSymbol.resi
···11-type t = StringS(StringA.Atom.t) | ConstS(string)
22-module Atom: SExpFunc.ATOM with type t = t
33-module AtomView: SExpViewFunc.ATOM_VIEW with module Atom := Atom