Skip to content

Eio.Promise.map #838

@patricoferris

Description

@patricoferris

It would be nice to have a Eio.Promise.map function.

Currently, you can implement something close with:

  let map ~sw f v =
    let p, r = Eio.Promise.create ~label:"map" () in
    Eio.Fiber.fork ~sw (fun () ->
      Eio.Promise.await v |> f |> Eio.Promise.resolve r
    );
    p

But that essentially requires attaching a switch to your promise, and the promise API is switchless, it would be nice to keep it that way for mapping new promises. I don't quite understand the underlying Cell API enough to know if this is possible though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions