···1818module type COERCIBLE_ATOM = {
1919 include ATOM
2020 let coerce: hValue => option<t>
2121+ let wrap: t => hValue
2122}
22232324type loweredSExp = Var({idx: int}) | Schematic({schematic: int, allowed: array<int>})
···5152 | Right(s) => rightBranch(s)
5253 | Foreign(_) => throw(MatchCombineAtomForeign)
5354 }
5454- let wrapLeft = left => HValue(Left.Tag, left)
5555- let wrapRight = right => HValue(Right.Tag, right)
5555+ let wrap = t =>
5656+ switch t {
5757+ | Left(s) => Left.wrap(s)
5858+ | Right(s) => Right.wrap(s)
5959+ | Foreign(val) => val
6060+ }
5661 let parse = (s, ~scope, ~gen: option<gen>=?) => {
5762 Left.parse(s, ~scope, ~gen?)
5863 ->Result.map(((r, rest)) => (Left(r), rest))
···7378 let coerceToLeft = (t): option<Left.t> =>
7479 switch t {
7580 | Left(s) => Some(s)
7676- | Right(s) => s->wrapRight->Left.coerce
8181+ | Right(s) => Right.wrap(s)->Left.coerce
7782 | Foreign(v) => Left.coerce(v)
7883 }
7984 let coerceToRight = (t): option<Right.t> =>
8085 switch t {
8186 | Right(s) => Some(s)
8282- | Left(s) => s->wrapLeft->Right.coerce
8787+ | Left(s) => Left.wrap(s)->Right.coerce
8388 | Foreign(v) => Right.coerce(v)
8489 }
8590 let substitute = (s, subst: subst) => {
+2
src/Coercible.res
···1414 ])
1515 | _ => None
1616 }
1717+ let wrap = a => HValue(StringA.Atom.Tag, a)
1718}
18191920module Symbolic: COERCIBLE_ATOM with type t = Symbolic.Atom.t = {
2021 include Symbolic.Atom
2122 let coerce = _ => None
2323+ let wrap = a => HValue(Symbolic.Atom.Tag, a)
2224}