import * as T from "../../../../Effect";
import * as O from "../../../../Option";
import * as CH from "../../Channel";
import * as C from "../core";
/**
 * Creates a stream by effectfully peeling off the "layers" of a value of type `S`
 */

export function unfoldChunkEffect(s, f) {
  const loop = s => CH.unwrap(T.map_(f(s), O.fold(() => CH.end(undefined), ({
    tuple: [as, s]
  }) => CH.zipRight_(CH.write(as), loop(s)))));

  return new C.Stream(loop(s));
}
//# sourceMappingURL=unfoldChunkEffect.js.map