<commit_before>var _user$project$Native_Canvas = function () {

  function LOG(msg) {
    // console.log(msg);
  }

  function canvasPatch(domNode, data) {
    return drawCanvas(domNode, data.model);
  }

  function listToJSArray(list) {
    var output = [];

    while (list.ctor == "::") {
      output.push(list._0);
      list = list._1;
    }

    return output;
  }

  function canvas(factList, width, height, data) {

    var model = {
      width: width,
      height: height,
      data: listToJSArray(data)
    };

    return _elm_lang$virtual_dom$Native_VirtualDom.custom(factList, model, implementation);
  }

  var implementation = {
    render: renderCanvas,
    diff: diff,
  };

  function drawCanvas(canvas, model) {

    canvas.width        = model.width;
    canvas.height       = model.height;
    canvas.style.width  = model.width;
    canvas.style.height = model.height

    var ctx = canvas.getContext('2d');
    var imageData = ctx.getImageData(0, 0, model.width, model.height);

    for (var i = 0; i < imageData.data.length; i++) {
      imageData.data[i] = model.data[i];
    }

    ctx.putImageData(imageData, 0, 0);

    return canvas;
  }

  function renderCanvas(model) {

    LOG('Render canvas');

    return drawCanvas(document.createElement('canvas'), model);
  }

  function diff(oldModel, newModel) {

    var oldString = oldModel.model.data
      .map(function(datum) { return String(datum); })
      .reduce(function(memo, item) {
        return memo + item;
      })

    var newString = newModel.model.data
      .map(function(datum) { return String(datum); })
      .reduce(function(memo, item) {
        return memo + item;
      })

    var patch;

    if (newString !== oldString) {
      patch = canvasPatch;
    } else {
      patch = function(a) { return a }
    }

    newModel.model.cache = oldModel.model.cache;
    return {
      applyPatch: patch,
      data: newModel
    };
  }

  return {
    canvas: F4(canvas),
  };

}();
<commit_msg>Reformatted canvas a bit, in a way that I think it more readable<commit_after>var _user$project$Native_Canvas = function () {

  function LOG(msg) {
    // console.log(msg);
  }

  function canvasPatch(domNode, data) {
    return drawCanvas(domNode, data.model);
  }

  function listToJSArray(list) {
    var output = [];

    while (list.ctor == "::") {
      output.push(list._0);
      list = list._1;
    }

    return output;
  }

  function canvas(factList, width, height, data) {

    var model = {
      width:  width,
      height: height,
      data:   listToJSArray(data)
    };

    return _elm_lang$virtual_dom$Native_VirtualDom.custom(factList, model, implementation);
  }

  var implementation = {
    render: renderCanvas,
    diff:   diff,
  };

  function drawCanvas(canvas, model) {

    canvas.width        = model.width;
    canvas.height       = model.height;
    canvas.style.width  = model.width;
    canvas.style.height = model.height

    var ctx       = canvas.getContext('2d');
    var imageData = ctx.getImageData(0, 0, model.width, model.height);

    for (var i = 0; i < imageData.data.length; i++) {
      imageData.data[i] = model.data[i];
    }

    ctx.putImageData(imageData, 0, 0);

    return canvas;
  }

  function renderCanvas(model) {

    LOG('Render canvas');

    return drawCanvas(document.createElement('canvas'), model);
  }

  function dataToString(data) {
    return data.map(String).reduce(function(memo, item) {
      return memo + item;
    });
  }

  function diff(oldModel, newModel) {

    var oldString = dataToString(oldModel.model.data);
    var newString = dataToString(newModel.model.data);

    var patch;

    if (newString !== oldString) {
      patch = canvasPatch;
    } else {
      patch = function(a) { return a }
    }

    newModel.model.cache = oldModel.model.cache;

    return {
      applyPatch: patch,
      data: newModel
    };
  }

  return {
    canvas: F4(canvas),
  };

}();

{'fraction_non_alphanumeric': 0.1309192200557103, 'fraction_numerical': 0.004558115978728792, 'mean_word_length': 2.5778985507246377, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, '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': '3710009', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1258, 'n_words': 272}