MVFM

core/cond

Conditional branching. .t() for then, .f() for else. Either order.

// 1. make an app
const app = mvfm(prelude);

// 2. make a program
const prog = app({ x: "number" }, ($) => {
  const total = $.add($.input.x, 1);
  const big = $.gt(total, 100);
  return $.cond(big)
    .t($.concat("big: ", $.show(total)))
    .f("small");
});

// 3. run
await fold(
  defaults(app),
  injectInput(prog, { x: 250 })
);
Ctrl+Enter