import * as T from "../../../../Effect";
import * as O from "../../../../Option";
import * as CH from "../../Channel";
import * as C from "../core";

function unfoldChunksLoop(s, f) {
  return CH.unwrap(T.map_(f(s), O.fold(() => CH.unit, ({
    tuple: [as, s]
  }) => CH.chain_(CH.write(as), () => unfoldChunksLoop(s, f)))));
}
/**
 * Creates a stream by effectfully peeling off the "layers" of a value of type `S`
 */


export function unfoldChunksEffect(s, f) {
  return new C.Stream(unfoldChunksLoop(s, f));
}
//# sourceMappingURL=unfoldChunksEffect.js.map