I have a method that can locate an item in the database and retrieve a TaskOption
:
find: (key: SchemaInfo) => TO.TaskOption<Schema>
and another method to store it:
register: (schema: Schema) => TE.TaskEither<Error, void>
Within my register
function, I want to verify if the Schema
being saved already exists or not (using find
), but I'm unsure how to convert a TaskOption
to a TaskEither
. My attempt was:
pipe(
findSchema(schema.info),
TE.fromTaskOption,
TE.swap
)
However, the result from TE.fromTaskOption
is not the expected TaskEither
. I also tried TE.fromTaskOptionK
, but it returned a strange function instead.
In my scenario, if the TaskOption
is none
, I proceed with saving (indicating the schema is not yet registered); otherwise, I return an error (as the schema is already registered). How can I resolve this issue?