Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use ! for Never #75

Closed
wants to merge 0 commits into from
Closed

[WIP] Use ! for Never #75

wants to merge 0 commits into from

Conversation

cramertj
Copy link
Member

Part of #32

I gave this a shot now that the never_type feature landed in nightly, and it works. However, after using it in person, I'm not sure this approach is better than the existing solution using PhantomData. For one thing, ! can only coerce at top-level, so converting Never {} to a Future<Item = I, Error = E> requires mapping both the error and the success case, which (I think) will be non-obvious to end-users and cause unnecessary confusion. Fortunately, the pain introduced by requiring map and map_err can be easily handled by the existing never function. Unfortunately, specifying an appropriate return type for that function (at first glance) requires impl Trait, which is yet another nightly (and not soon to be stable) feature.

On the other hand, I believe this approach to be more "correct" from a type-theory perspective and, when also applied to Finished and Failed, would allow users to generalize computations on futures without having to specify a bogus Error type.

@alexcrichton Thoughts?

@alexcrichton
Copy link
Member

Hm yeah the type annotations here are unfortunate, maybe not always necessary though? I'd be fine having this as an off-by-default feature, but we'd probably want to keep the empty name for now so we can phase in the never name slowly over time.

@cramertj
Copy link
Member Author

Okay. I'll finish converting Finished and Failed to use !, and I'll see how many of the type annotations can be removed. Can you clarify your last point about keeping the empty name? Should I add never and just keep around but deprecate empty?

@cramertj
Copy link
Member Author

Addendum: one nice thing about leaving the tests as-is (with the type annotations) is that they all work both on stable and on nightly.

@alexcrichton
Copy link
Member

For now yeah we could have the never feature enable the never function/type. We'd leave empty as-is and then we could one day deprecate it if it pans out.

@cramertj
Copy link
Member Author

Closed to reopen with different organization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants