How to Use FileSystem.FileSystem for File Operations in Effect Typescript

Hello folks, my script to create an Atom feed:
1. reads an input json file;
2. transforms it into xml;
3. writes it to an output feed.xml file.
In the current version of the script, I use Effect to wrap node:fs for file read and write as follows:
const readFile = (file: string) =>
  Effect.tryPromise(() =>
    fs.readFile(file, { encoding: 'utf8' }));

const writeFile = (file: string) =>
  (feed: string) =>
    Effect.tryPromise(() =>
      fs.writeFile(file, feed))

const main = pipe(
  'index.json',
  readFile,
  Effect.map(JSON.parse),
  Effect.flatMap(decoder),
  Effect.map(makeFeed),
  Effect.map(writeFile('site/feed.xml')),
  Effect.flatten
);

Effect.runPromise(main);

I am looking to replacing node:fs with FileSystem.FileSystem tag to perform the file read and write, but can't wrap my head around it. Here is my attempt:
const program = pipe(
    // read from input file
  Effect.andThen(FileSystem.FileSystem, fs => fs.readFileString("index.json", "utf8")),
  Effect.map(JSON.parse),
  Effect.flatMap(decoder),
  Effect.map(makeFeed),
  // Write to output file
  // TODO: How do I get the FileSystem context back here?
  // Effect.andThen(fs => fs.writeFile("site/feed.xml", "utf8")),
);
NodeRuntime.runMain(program.pipe(Effect.provide(NodeContext.layer)));

Non-platform code looks cleaner to me anyway. But I want to give Platform API a chance. Can anyone help me out?
Was this page helpful?