Effect CommunityEC
Effect Community3y ago
15 replies
Jérôme MARTIN

Using Effect.iterate for Type Narrowing

Good morning. I am using Effect.iterate and was wondering if there was an elegant way to get type narrowing from the while condition into the body part. While thinking about it, I thought maybe an extra signature with of Effect.iterate with a refinement instead of a predicate could help, like
export const iterate: <A, B extends A, R, E>(
  initial: A,
  options: {
    readonly while: Refinement<A, B>
    readonly body: (b: B) => Effect<R, E, B>
  }
) => Effect<R, E, B>

What would be your thoughts about this?
Was this page helpful?