// Generated by ReScript, PLEASE EDIT WITH CARE


function group(breakOpt, doc) {
  var $$break = breakOpt !== undefined ? breakOpt : /* IfNeed */0;
  return {
          break: $$break,
          doc: doc
        };
}

function fits(_w, _stack) {
  while(true) {
    var stack = _stack;
    var w = _w;
    if (w < 0) {
      return false;
    }
    if (!stack) {
      return true;
    }
    _stack = stack._1;
    _w = w - stack._0.doc.length | 0;
    continue ;
  };
}

function toString(width, stack) {
  if (!stack) {
    return "";
  }
  var stack$1 = stack._1;
  var match = stack._0;
  var doc = match.doc;
  switch (match.break) {
    case /* IfNeed */0 :
        return (
                fits(width, stack$1) ? "fits " : "no "
              ) + toString(width - 1 | 0, stack$1);
    case /* Never */1 :
        return "never " + (doc + toString(width - 1 | 0, stack$1));
    case /* Always */2 :
        return "always " + (doc + toString(width - 1 | 0, stack$1));
    
  }
}

toString(80, /* Empty */0);

var $$break = /* Never */1;

toString(80, /* Cons */{
      _0: {
        break: $$break,
        doc: "abc"
      },
      _1: /* Empty */0
    });

var $$break$1 = /* Always */2;

toString(80, /* Cons */{
      _0: {
        break: $$break$1,
        doc: "d"
      },
      _1: /* Empty */0
    });

export {
  group ,
  fits ,
  toString ,
  
}
/*  Not a pure module */
