open Signatures open! Util type style = Gentzen | Linear | Hybrid module Make = ( Term: TERM, Judgment: JUDGMENT with module Term := Term, JudgmentView: JUDGMENT_VIEW with module Term := Term and module Judgment := Judgment, ) => { module Rule = Rule.Make(Term, Judgment) module ScopeView = ScopeView.Make(Term, JudgmentView.TermView) type props = { rule: Rule.t, style: style, scope?: array, children: React.element, } module type RULE_COMPONENT = { let make: React.component } module Inline: RULE_COMPONENT = { @react.componentWithProps let rec make = (props: props) => { let {vars, premises, conclusion} = props.rule let scope = vars->Array.concat(props.scope->Option.getOr([])) {props.children} {React.array( premises ->Array.mapWithIndex((p, i) => {React.createElement( React.component(make), withKey({rule: p, scope, children: React.string(""), style: props.style}, i), )} ) ->Array.flatMapWithIndex((e, i) => if i == 0 { [e] } else { [ {React.string(",")} , e, ] } ), )} {if premises->Array.length > 0 { {React.string("⊢")} } else { React.string("") }} } } module Hypothetical = (Premise: RULE_COMPONENT) => { @react.componentWithProps let make = (props: props) => if Array.length(props.rule.premises) == 0 { } else { let {vars, premises, conclusion} = props.rule let scope = vars->Array.concat(props.scope->Option.getOr([])) {React.array( premises->Array.mapWithIndex((p, i) => ), )}
{React.string("")} {props.children}
Array.length + 1} className="rule-cell"> {React.string("⋮")}
Array.length + 1} className="rule-cell rule-hypothetical-conclusion" >
} } module TopLevel = (Premise: RULE_COMPONENT) => { @react.componentWithProps let make = (props: props) => { let {vars, premises, conclusion} = props.rule let scope = vars->Array.concat(props.scope->Option.getOr([]))
{React.array( premises->Array.mapWithIndex((p, i) => ), )}
{React.string("")} {props.children}
Array.length + 1} className="rule-cell rule-conclusion">
} } module Gentzen = TopLevel(Hypothetical(Inline)) module Hybrid = TopLevel(Inline) @react.componentWithProps let make = props => { switch props.style { | Hybrid => | Gentzen => | Linear => } } }