Skip to content

Missing helper (or am I missing something?) #39

@pckilgore

Description

@pckilgore

First thank you for this library, it's been a joy to work with over Js.Promise.

A question: I feel like I'm constantly reaching for functions of signature:

let tryIfOk: (Future.t(Belt.Result.t('c, 'b)), 'c => Belt.Result.t('a, 'b)) => 
  Future.t(Belt.Result.t('a, 'b))

let tryIfErr: (Future.t(Belt.Result.t('b, 'c)), 'c => Belt.Result.t('a, 'b)) => 
  Future.t(Belt.Result.t('a, 'b))

Is there a simple way to compose this out of other functions already provided? It seems like no matter how I go about this in my code I'm doing a lot of ugly manual wrapping (which does work, it just feels extremely inelegant).

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions