MCPcopy Create free account
hub / github.com/effect-app/libs / modifyM

Function modifyM

packages/effect-app/src/Pure.ts:210–222  ·  view source on GitHub ↗
(
  mod: (s: S2) => Effect.Effect<readonly [S3, A], E, FixEnv<R, W, S2, S3>>
)

Source from the content-addressed store, hash-verified

208}
209
210export function modifyM<W, R, E, A, S2, S3>(
211 mod: (s: S2) => Effect.Effect<readonly [S3, A], E, FixEnv<R, W, S2, S3>>
212): Effect.Effect<A, E, FixEnv<R, W, S2, S3>> {
213 // return serviceWithEffect(_ => Ref.modifyM_(_.state, mod))
214 return Effect.flatMap(
215 (castTag<W, S3, S2>()).useSync((_) => _),
216 (_: any) =>
217 Effect.map(mod(_.env.state), ([s, a]: any) => {
218 _.env.state = s
219 return a
220 })
221 ) as any
222}
223
224export function updateWith<S2, S3>(upd: (s: S2) => S3) {
225 return modify((_: S2) => {

Callers 1

updateWithEffectFunction · 0.85

Calls 3

castTagFunction · 0.85
useSyncMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…