Skip to content

Support request - Example with async/await ? #47

@drupol

Description

@drupol

Hello,

I'm trying to use this library with methods that are async:

In the following example, the method find() is async.

documents = Either.pure(self.database.collection.find())

Things are getting more complex when I try to use methods like fmap later on:

documents.fmap(...)

In this case, this is not going to work because self.database.collection.find() returns something that need to be awaited. Then, to fix the issue, I have to create 2 monads:

documents = await Either.pure(self.database.collection.find()).to_optional()

return Either.pure(documents).fmap(...)

Do you think this is how it is supposed to be used?

So I am opening this issue to have some information and best practices when it comes to mixing a monad with this kind of async way of working. Do you recommend something?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions