Skip to content

Carrier trait for ? operator #1718

Closed
Closed
@nrc

Description

@nrc

We accepted an RFC to add the ? operator, that RFC included a Carrier trait to allow applying ? to types other than Result, e.g., Option. However, we accepted a version of the RFC without that in order to get some actual movement and some experience with the ? operator.

The bare ? operator is now on the road to stabilisation. We would like to consider adding a Carrier trait and that will require a new RFC. There is in fact a 'dummy' Carrier trait in libcore and used in the implementation of ?. However, its purpose is to ensure ? is backwards compatible around type inference. It is effectively only implemented for Result and is not intended to be a long-term solution. There are other options for the trait using HKT, variant types, and just existing features. It's unclear what is preferred right now.

One important question is whether we should allow conversion between types (e.g., Result to Option) or whether we should only allow the ? operator to work on one type 'at a time'.

Links:

? operator RFC PR
? operator tracking issue
Niko's thoughts

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions