MCPcopy
hub / github.com/Effect-TS/effect / reAnnotateSafe

Function reAnnotateSafe

packages/printer/src/internal/docStream.ts:297–333  ·  view source on GitHub ↗
(
  self: DocStream.DocStream<A>,
  f: (a: A) => B
)

Source from the content-addressed store, hash-verified

295>(2, (self, f) => Effect.runSync(reAnnotateSafe(self, f)))
296
297const reAnnotateSafe = <A, B>(
298 self: DocStream.DocStream<A>,
299 f: (a: A) => B
300): Effect.Effect<DocStream.DocStream<B>> => {
301 switch (self._tag) {
302 case "CharStream": {
303 return Effect.map(
304 Effect.suspend(() => reAnnotateSafe(self.stream, f)),
305 char(self.char)
306 )
307 }
308 case "TextStream": {
309 return Effect.map(
310 Effect.suspend(() => reAnnotateSafe(self.stream, f)),
311 text(self.text)
312 )
313 }
314 case "LineStream": {
315 return Effect.map(
316 Effect.suspend(() => reAnnotateSafe(self.stream, f)),
317 line(self.indentation)
318 )
319 }
320 case "PushAnnotationStream": {
321 return Effect.map(
322 Effect.suspend(() => reAnnotateSafe(self.stream, f)),
323 pushAnnotation(f(self.annotation))
324 )
325 }
326 case "PopAnnotationStream": {
327 return Effect.suspend(() => reAnnotateSafe(self.stream, f))
328 }
329 default: {
330 return Effect.succeed(self as unknown as DocStream.DocStream<B>)
331 }
332 }
333}
334
335/** @internal */
336export const unAnnotate = <A>(self: DocStream.DocStream<A>): DocStream.DocStream<never> =>

Callers 1

docStream.tsFile · 0.85

Calls 6

pushAnnotationFunction · 0.85
charFunction · 0.70
textFunction · 0.70
lineFunction · 0.70
mapMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected