add special renderer for church booleans.
This commit is contained in:
parent
7979eb2f15
commit
1a6b0b9672
|
@ -0,0 +1,16 @@
|
|||
import { is_same } from "../serialize.mjs";
|
||||
|
||||
const T = [0, [0, 2]];
|
||||
const F = [0, [0, 1]];
|
||||
|
||||
export default {
|
||||
check: expr => {
|
||||
if (is_same(expr, T)) return true;
|
||||
if (is_same(expr, F)) return true;
|
||||
return false;
|
||||
},
|
||||
render: (expr, prettify) => {
|
||||
if (is_same(expr, T)) return "true";
|
||||
if (is_same(expr, F)) return "false";
|
||||
},
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
import { add_special_renderer } from "../prettify.mjs";
|
||||
import church_boolean from "./church_boolean.mjs";
|
||||
|
||||
add_special_renderer(church_boolean);
|
|
@ -7,6 +7,7 @@ import { transpile } from "./transpile.mjs";
|
|||
import { reduce } from "./reduce.mjs";
|
||||
|
||||
import { prettify } from "./prettify.mjs";
|
||||
import "./renderers/main.mjs";
|
||||
|
||||
import readline from "node:readline";
|
||||
|
||||
|
|
|
@ -3,3 +3,7 @@ export function serialize (expr) {
|
|||
? "(" + expr.map(serialize).join(",") + ")"
|
||||
: expr;
|
||||
}
|
||||
|
||||
export function is_same (a, b) {
|
||||
return serialize(a) === serialize(b);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue