Effect.iterate and Effect.loop: Understanding Effectful Operations in a Directory Search
Hi there, I often use Effect.iterate and Effect.loop and was wondering why only the body is effectful. For instance, I have written a snippet that, starting from the current directory, goes up until it reaches the user's directory or finds a specific file. Ideally, the way I would like to write it is:
where
But this is currently not possible because the while callback expects a boolean, not an Effect<R,E,boolean>.
Of course, I can manage to do like so:
But it adds a lot of complexity for the same result. Do you think there would be a way to add an effectful while callback to Effect.iterate and effectful while and step callbacks to Effect.loop? For simplicity's sake, I skipped the condition relative to reaching the user's directory above.
Or maybe there is another function I could use to achieve this?
where
specificFileNotInDir and goUpOneLevel are effectful functions.But this is currently not possible because the while callback expects a boolean, not an Effect<R,E,boolean>.
Of course, I can manage to do like so:
But it adds a lot of complexity for the same result. Do you think there would be a way to add an effectful while callback to Effect.iterate and effectful while and step callbacks to Effect.loop? For simplicity's sake, I skipped the condition relative to reaching the user's directory above.
Or maybe there is another function I could use to achieve this?
