Effect CommunityEC
Effect Communityβ€’3y agoβ€’
6 replies
kayng84

Converting Either to Effect: Seeking Function

Hi, I use schema to parse the input from user or external api. The parse function return the Either, I want to pipe the Either further with Effect. Do we have any function to convert Either to Effect? I looking for Effect.fromEither but not found. I tried:

const parsed = parseMessage({})

const program = pipe(parsed, (a) => {
return Either.isRight(a) ? Effect.succeed(a.right) : Effect.fail(a.left)
})


But the program now type: Effect<never, never, MySchema> | Effect<never, ParseError, never>

Looks pretty much like Effect<never, ParseError, MySchema> but actually when I pipe further, it have many complaint.

I also can make a function to wrap the convert above but need explicit typing which I don't like.

any ideas?
Was this page helpful?