text: // Generated by ReScript, PLEASE EDIT WITH CARE
  
  import * as $$Map from "bs-platform/lib/es6/map.js";
  import * as Curry from "bs-platform/lib/es6/curry.js";
  import * as Deque from "../src/deque.bs.js";
  import * as Printf from "bs-platform/lib/es6/printf.js";
  import * as $$String from "bs-platform/lib/es6/string.js";
  import * as Caml_array from "bs-platform/lib/es6/caml_array.js";
  import * as Caml_string from "bs-platform/lib/es6/caml_string.js";
  import * as Caml_primitive from "bs-platform/lib/es6/caml_primitive.js";
  import * as Caml_js_exceptions from "bs-platform/lib/es6/caml_js_exceptions.js";
  
  function Ngram_make(N) {
    var empty = Curry._2(Deque.init, N.size, (function (param) {
            return /* '^' */94;
          }));
    var add = function (t, chr) {
      return Curry._1(Deque.tl, Deque.snoc(t, chr));
    };
    var to_string = function (t) {
      var arr = Curry._1(Deque.to_array, t);
      return $$String.init(arr.length, (function (param) {
                    return Caml_array.get(arr, param);
                  }));
    };
    var compare = Curry._1(Deque.compare, Caml_primitive.caml_int_compare);
    return {
            empty: empty,
            add: add,
            to_string: to_string,
            compare: compare
          };
  }
  
  var empty = Curry._2(Deque.init, 12, (function (param) {
          return /* '^' */94;
        }));
  
  function add(t, chr) {
    return Curry._1(Deque.tl, Deque.snoc(t, chr));
  }
  
  function to_string(t) {
    var arr = Curry._1(Deque.to_array, t);
    return $$String.init(arr.length, (function (param) {
                  return Caml_array.get(arr, param);
                }));
  }
  
  var compare = Curry._1(Deque.compare, Caml_primitive.caml_int_compare);
  
  var Ngram = {
    empty: empty,
    add: add,
    to_string: to_string,
    compare: compare
  };
  
  var M = $$Map.Make({
        compare: compare
      });
  
  var empty$1 = M.empty;
  
  function add$1(k, t) {
    var c;
    try {
      c = 1 + Curry._2(M.find, k, t) | 0;
    }
    catch (raw_exn){
      var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
      if (exn.RE_EXN_ID === "Not_found") {
        c = 1;
      } else {
        throw exn;
      }
    }
    return Curry._3(M.add, k, c, t);
  }
  
  function stats(t) {
    return Curry._2(M.iter, (function (k, c) {
                  return Curry._2(Printf.printf(/* Format */{
                                  _0: {
                                    TAG: /* Int */4,
                                    _0: /* Int_i */3,
                                    _1: {
                                      TAG: /* Lit_padding */0,
                                      _0: /* Right */1,
                                      _1: 2
                                    },
                                    _2: /* No_precision */0,
                                    _3: {
                                      TAG: /* String_literal */11,
                                      _0: " : ",
                                      _1: {
                                        TAG: /* Caml_string */3,
                                        _0: /* No_padding */0,
                                        _1: {
                                          TAG: /* Char_literal */12,
                                          _0: /* '\n' */10,
                                          _1: {
                                            TAG: /* Flush */10,
                                            _0: /* End_of_format */0
                                          }
                                        }
                                      }
                                    }
                                  },
                                  _1: "%2i : %S\n%!"
                                }), c, to_string(k));
                }), Curry._2(M.filter, (function (param, c) {
                      return c > 1;
                    }), t));
  }
  
  var Histogram = {
    M: M,
    empty: empty$1,
    add: add$1,
    stats: stats
  };
  
  function histogram(str) {
    var _h = empty$1;
    var _window = empty;
    var _i = 0;
    while(true) {
      var i = _i;
      var $$window = _window;
      var h = _h;
      if (i >= str.length) {
        return h;
      }
      var $$window$1 = Curry._1(Deque.tl, Deque.snoc($$window, Caml_string.get(str, i)));
      var h$1 = add$1($$window$1, h);
      _i = i + 1 | 0;
      _window = $$window$1;
      _h = h$1;
      continue ;
    };
  }
  
  var lorem = "\n  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a mi\n  ultricies, tincidunt ex egestas, vulputate nisl. Aliquam gravida purus\n  sapien, eu aliquet magna pellentesque non. Sed maximus, lectus sed varius\n  mollis, ante odio dictum nisl, non commodo nunc tortor ut dui. Sed eget diam\n  ultrices, mollis metus non, molestie enim. Curabitur dui augue, molestie id\n  mollis luctus, congue eu nunc. Nulla molestie blandit fringilla. Cras\n  ultrices velit ut ex porttitor faucibus. Sed vestibulum mauris nec quam\n  rutrum semper. Aenean ullamcorper, nisi a accumsan lobortis, dui ex sagittis\n  quam, at condimentum nunc ex eu magna. Sed vel neque vel arcu vehicula\n  bibendum. Donec massa massa, consectetur vel ultrices nec, fringilla vel\n  purus. Pellentesque sem metus, volutpat in eros facilisis, volutpat laoreet\n  eros. Integer facilisis, lorem a hendrerit pharetra, tellus nulla tincidunt\n  orci, ut vehicula nisi nibh et elit.  Ut tempor gravida sapien, a luctus enim\n  imperdiet ut.\n";
  
  stats(histogram(lorem));
  
  export {
    Ngram_make ,
    Ngram ,
    Histogram ,
    histogram ,
    lorem ,
    
  }
  /* empty Not a pure module */
  