**Issue with `Effect.forEach` and `Effect.Tag` in TypeScript**

Hey there!
I found a sneaky issue mixing Effect.forEach and Effect.Tag. This code (see this playground)
import { Effect, Layer, pipe } from "effect"

class Foo extends Effect.Tag('Foo')<Foo, {foo: () => Effect.Effect<string>}>(){
  static layer = Layer.succeed(this, {
    foo() {
      return Effect.succeed('Foo');
    },
  })
}

pipe(
  [1, 2],
  Effect.forEach(Foo.foo),
  Effect.provide(Foo.layer),
  Effect.runSync,
)

throws this error:
TypeError: ab is not a function
    at pipe (file:///home/r24e23sdiw9w1oqo1ljpo851jbidnw-h5th/playground-1725433020586/node_modules/.pnpm/effect@3.7.0/node_modules/effect/dist/cjs/Function.js#cjs:352:20)
    at Object.eval (file:///home/r24e23sdiw9w1oqo1ljpo851jbidnw-h5th/playground-1725433020586/dist/main.js#cjs:11:19)
    at Object._0x2f55b1 (https://r24e23sdiw9w1oqo1ljpo851jbidnw-h5th.w-corp-staticblitz.com/blitz.c4712070.js:40:804038)
    at Module._compile (https://r24e23sdiw9w1oqo1ljpo851jbidnw-h5th.w-corp-staticblitz.com/builtins.ddb8d84d.js:144:14246)
    at Module._extensions..js (https://r24e23sdiw9w1oqo1ljpo851jbidnw-h5th.w-corp-staticblitz.com/builtins.ddb8d84d.js:144:14855)
    at Module.load (https://r24e23sdiw9w1oqo1ljpo851jbidnw-h5th.w-corp-staticblitz.com/builtins.ddb8d84d.js:144:12820)
    at Module._load (https://r24e23sdiw9w1oqo1ljpo851jbidnw-h5th.w-corp-staticblitz.com/builtins.ddb8d84d.js:144:10273)
    ...

Changing Effect.forEach(Foo.foo), to Effect.forEach(() => Foo.foo()), fixes the issue.
From what I've looked, it looks like Foo.foo is an Iterable so it messes with the api parameters detection when using dual in the fiberRuntime.forEach : (args) => Predicate.isIterable(args[0])
Any thoughs on this? Anyway we could improve the parameters detection to address this kind of things?
Was this page helpful?