open Signatures
module Make = (Term: TERM, Judgment : REWRITABLE_JUDGMENT with module Term := Term) => {
module Context = Method.Context(Term, Judgment)
module Method = Rewrite.Make(Term, Judgment)
type props<'a> = {
method: Method.t<'a>,
ctx: Context.t,
ruleStyle: RuleView.style,
grammar: Term.grammar,
gen: Term.gen,
onChange: (Method.t<'a>, Term.subst) => unit,
}
type srProps<'a> = {
"proof": 'a,
"ctx": Context.t,
"ruleStyle": RuleView.style,
"grammar": Term.grammar,
"gen": Term.gen,
"onChange": ('a, Term.subst) => unit,
}
let summary = props =>
{
switch props.method.direction {
| Method.Forward => React.string("→")
| Method.Backward => React.string("←")
}
}
let make = (subRender: srProps<'a> => React.element) =>
props => {
{summary(props)}
{
if props.method.subgoals->Array.length > 0 {
{props.method.subgoals
->Array.mapWithIndex((sg, i) => {
-
{React.createElement(
subRender,
{
"proof": sg,
"ctx": props.ctx,
"ruleStyle": props.ruleStyle,
"grammar": props.grammar,
"gen": props.gen,
"onChange": (newa, subst: Term.subst) =>
props.onChange(props.method->Method.updateAtKey(i, _ => newa), subst),
},
)}
})
->React.array}
} else {
React.string("")
}
}
{React.createElement(subRender,{
"proof": props.method.newGoal,
"ctx": props.ctx,
"ruleStyle": props.ruleStyle,
"grammar": props.grammar,
"gen": props.gen,
"onChange": (newa, subst: Term.subst) =>
props.onChange(props.method->Method.updateGoal(_=>newa), subst),
})}
}
}