<commit_before>import m from "mithril";
import Stream from "mithril/stream";
import { assoc, prop, tap } from "ramda";
import { run } from "stags";

import { createApp, App } from "./app";
import { router } from "./router";

// Only for using Meiosis Tracer in development.
import meiosisTracer from "meiosis-tracer";

const app = createApp(router.initialRoute);

const states = Stream();
const update = Stream();

// Only for using Meiosis Tracer in development.
meiosisTracer({
  selector: "#tracer",
  rows: 30,
  streams: [{ stream: states, label: "states" }]
});

const services = [app.validate, app.onRouteChange];
const service = context =>
  services.reduce(
    (result, service) => ({
      state: run(result.state, service(result)),
      previousState: context.previousState
    }),
    context
  );

const fn = context => run(context, service, prop("state"), tap(states));

let state = fn({ state: app.initial, previousState: {} });

// update
update.map(patch =>
  run(fn({ previousState: state, state: patch(state) }), updatedState => {
    state = updatedState;
  })
);

const actions = app.Actions(update);
m.mount(document.getElementById("app"), { view: () => m(App, { state: states(), actions }) });
<commit_msg>Experimenting with superouter and stags<commit_after>import m from "mithril";
import Stream from "mithril/stream";
import { assoc } from "ramda";
import { run } from "stags";

import { createApp, App } from "./app";
import { router } from "./router";

// Only for using Meiosis Tracer in development.
import meiosisTracer from "meiosis-tracer";

const app = createApp(router.initialRoute);

const update = Stream();

const services = [app.validate, app.onRouteChange];
const service = context =>
  services.reduce(
    (result, service) => ({
      state: run(result.state, service(result)),
      previousState: context.previousState
    }),
    context
  ).state;

const states = Stream.scan(
  (state, patch) => service({ previousState: state, state: patch(state) }),
  service({ state: app.initial, previousState: {} }),
  update
);

// Only for using Meiosis Tracer in development.
meiosisTracer({
  selector: "#tracer",
  rows: 30,
  streams: [{ stream: states, label: "states" }]
});

const actions = app.Actions(update);
m.mount(document.getElementById("app"), { view: () => m(App, { state: states(), actions }) });

{'fraction_non_alphanumeric': 0.1583864118895966, 'fraction_numerical': 0.0016985138004246285, 'mean_word_length': 4.318284424379232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '525246', 'n_tokens_mistral': 724, 'n_tokens_neox': 710, 'n_words': 216}