MCPcopy Index your code
hub / github.com/Effect-TS/effect / foldMapSafe

Function foldMapSafe

packages/printer/src/internal/docStream.ts:381–409  ·  view source on GitHub ↗
(
  self: DocStream.DocStream<A>,
  M: monoid.Monoid<M>,
  f: (a: A) => M
)

Source from the content-addressed store, hash-verified

379>(3, (self, M, f) => Effect.runSync(foldMapSafe(self, M, f)))
380
381const foldMapSafe = <A, M>(
382 self: DocStream.DocStream<A>,
383 M: monoid.Monoid<M>,
384 f: (a: A) => M
385): Effect.Effect<M> => {
386 switch (self._tag) {
387 case "CharStream": {
388 return Effect.suspend(() => foldMapSafe(self.stream, M, f))
389 }
390 case "TextStream": {
391 return Effect.suspend(() => foldMapSafe(self.stream, M, f))
392 }
393 case "LineStream": {
394 return Effect.suspend(() => foldMapSafe(self.stream, M, f))
395 }
396 case "PushAnnotationStream": {
397 return Effect.map(
398 Effect.suspend(() => foldMapSafe(self.stream, M, f)),
399 (that) => M.combine(f(self.annotation), that)
400 )
401 }
402 case "PopAnnotationStream": {
403 return Effect.suspend(() => foldMapSafe(self.stream, M, f))
404 }
405 default: {
406 return Effect.succeed(M.empty)
407 }
408 }
409}
410
411/** @internal */
412export const match = dual<

Callers 1

docStream.tsFile · 0.70

Calls 3

mapMethod · 0.65
combineMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected