Choosing Between `pipe`, `compose`/`flow`, and Imperative Style in Effect-TS

Could anyone point me to guidelines on choosing between pipe,
compose
/flow, and imperative style? Also, when should I prefer using JS built-ins such as Array.prototype.map over Effect's Array.map?

More concretely, I have four different implementations of the same logic and I'm having trouble figuring out which one is most idiomatic in Effect-TS (see below).

I personally like Code Block 4 due to the indentation, but I'm worried being impaired by the 10-function limit of flow and performance implications of function composition (as well as being forced to annotate anonymous function arguments due to somehow losing type information).

Code Block 1:
const parsed1 = parse(state.input);
const output1 = parsed1.map((e) => JSON.stringify(e)).join("\n");

Code Block 2:
const parsed2 = parse(state.input);
const lines2 = Array.map(parsed2, (e) => JSON.stringify(e));
const output2 = Array.join(lines2, "\n");

Code Block 3:
const output3 = pipe(
  state.input,
  parse,
  Array.map((e) => JSON.stringify(e)),
  Array.join("\n"),
);

Code Block 4:
const output4 = pipe(
  state.input,
  Function.flow(
    parse,
    Array.map((e: any) => JSON.stringify(e)),
    Array.join("\n"),
  ),
);
Was this page helpful?