// tracing: off
import * as Tp from "../../Collections/Immutable/Tuple"
import * as T from "../_internal/effect"
import { concat_ } from "./concat"
import { fromIterable } from "./fromIterable"
import { mapAccumM_ } from "./mapAccumM"
/**
 * Statefully and effectfully maps over the elements of this stream to produce all
 * intermediate results of type `S` given an initial S.
 */

export function scanM(s) {
  return (f) => (self) =>
    concat_(
      fromIterable([s]),
      mapAccumM_(self, s, (s, a) => T.map_(f(s, a), (s) => Tp.tuple(s, s)))
    )
}
//# sourceMappingURL=scanM.js.map
