Effect CommunityEC
Effect Community9mo ago
5 replies
ynoplanetashka

Do we really need Effect type, instead of () => Promise<Either>?

I believe it's possible to replace all uses of Effect<A, E, R> with (r: R) => Promise<Either<E, A>>, where R should be Record type instead of union type.
It's not hard to implement provide function forDI purposes.
I can see lack of the capability to write sync and async code in the same manner, but I don't consider it as a disadvantage.
Also Effect.gen won't work so nice (there would be a need in wrapping values before yield*), but I don't find it's critical.
There is a point, that Effect represents effectful computation, but I believe in most cases async function itself represent effectful computation.

In my opinion all cons are minor. But switching to () => Promise<Either> allow to add less boilerplate to existing code in order to use Effect api, which is a huge pros.

So my question is "do we really need Effect type, instead of () => Promise<Either>"?
Was this page helpful?