diff --git a/src/SExp.res b/src/SExp.res index 1b8d1cb..448d635 100644 --- a/src/SExp.res +++ b/src/SExp.res @@ -20,6 +20,7 @@ module ConstSymbol: SExpFunc.SYMBOL with type t = string = { let ghost = "" let substDeBruijn = (name, _, ~from as _) => name let unifiesWithAnything = _ => false + let upshift = (t, _, ~from as _=?) => t } include SExpFunc.Make(ConstSymbol) diff --git a/src/SExpFunc.res b/src/SExpFunc.res index 9d825a3..408b145 100644 --- a/src/SExpFunc.res +++ b/src/SExpFunc.res @@ -5,6 +5,7 @@ module type SYMBOL = { let prettyPrint: (t, ~scope: array) => string let parse: (string, ~scope: array, ~gen: ref=?) => result<(t, string), string> let substitute: (t, subst) => t + let upshift: (t, int, ~from: int=?) => t // used for when trying to substitute a variable of the wrong type let lowerVar: int => t let lowerSchematic: (int, array) => t @@ -194,7 +195,7 @@ module Make = (Symbol: SYMBOL): { } let rec upshift = (term: t, amount: int, ~from: int=0) => switch term { - | Symbol(_) => term + | Symbol(s) => Symbol(s->Symbol.upshift(amount, ~from)) | Compound({subexps}) => Compound({subexps: Array.map(subexps, x => upshift(x, amount, ~from))}) | Var({idx}) => Var({ diff --git a/src/StringSExp.res b/src/StringSExp.res index 73dcaf3..9b30da8 100644 --- a/src/StringSExp.res +++ b/src/StringSExp.res @@ -37,6 +37,11 @@ module StringSymbol: SExpFunc.SYMBOL with type t = stringSymbol = { } | ConstS(s) => ConstS(s) } + let upshift = (s, amount: int, ~from=?) => + switch s { + | StringS(s) => StringS(s->StringTerm.upshift(amount, ~from?)) + | ConstS(s) => ConstS(s) + } let lowerVar = idx => StringS([StringTerm.Var({idx: idx})]) let lowerSchematic = (schematic, allowed) => StringS([StringTerm.Schematic({schematic, allowed})]) let ghost = StringS([StringTerm.Ghost])