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

CNil::absurd() for producing any type #93

Closed
ExpHP opened this issue Mar 21, 2018 · 6 comments
Closed

CNil::absurd() for producing any type #93

ExpHP opened this issue Mar 21, 2018 · 6 comments

Comments

@ExpHP
Copy link
Collaborator

ExpHP commented Mar 21, 2018

Dangit, I'm having too many ideas all at once now!

impl CNil {
    pub fn absurd<T>(self) -> T {
        match self { }
    }
}

Bikeshedding for the name is welcome. The name absurd() comes from proof solvers. Picture it appearing e.g. at the bottom of this example, or as the body of this impl. (random aside: uh... why is that impl #[doc(hidden)]?)

@Centril
Copy link
Collaborator

Centril commented Mar 21, 2018

Hmm; Rather than doing this (and since we introduced some other breaking changes in master), I'd like us to get rid of CNil and simply use ! (assuming we can do it wrt. coherence, which I think we can), this is what the standard library has been doing as of late, and the hope is that ! should be the only uninhabited type in the entire ecosystem.

I'd personally like to have:

#[lang_item = "never"]
impl ! {
    pub fn absurd<T>(self) -> T {
        match self {}
    }
}

in the standard library tho.

@ExpHP
Copy link
Collaborator Author

ExpHP commented Mar 21, 2018

Okay. Do note that this will prevent inherent method wrappers (#90) on empty coproducts. That said, in most cases not having these methods is not a huge loss (most have no implementations for CNil, and who needs to take a subset() of a coproduct that is monomorphically known to be empty?); rather, it's just one of those places where the ergonomic hack will become a leaky abstraction.

(for instance, it could be an issue for code generated by macros)

@Centril
Copy link
Collaborator

Centril commented Mar 21, 2018

Okay. Do note that this will prevent inherent method wrappers (#90) on empty coproducts. That said, in most cases not having these methods is not a huge loss [..]

Yeah sounds fine ^,-

@ExpHP
Copy link
Collaborator Author

ExpHP commented Mar 21, 2018

Do you mean that not having the wrappers on CNil sounds fine? Or that keeping CNil around sounds fine?

@Centril
Copy link
Collaborator

Centril commented Mar 21, 2018

Sorry, I meant the former.

@ExpHP
Copy link
Collaborator Author

ExpHP commented Mar 21, 2018

Okay, I'll close this for now.

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

No branches or pull requests

2 participants