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

Higher kinded polymorphism #8922

Closed
tiffany352 opened this issue Sep 2, 2013 · 10 comments
Closed

Higher kinded polymorphism #8922

tiffany352 opened this issue Sep 2, 2013 · 10 comments
Labels
A-typesystem Area: The type system

Comments

@tiffany352
Copy link

Rust doesn't support higher kinded polymorphism, despite being a common feature in many functional programming languages. As far as I know, it is a commonly requested feature from people in the FP crowd.

@nikomatsakis
Copy link
Contributor

cc me. I've been thinking a lot about this and have a vague plan. I think we'll want it going forward to make dealing with user-defined pointer types work out. I'll try to find the time to write up my plans shortly.

@thehydroimpulse
Copy link
Contributor

/cc me

@rizo
Copy link

rizo commented Jul 4, 2014

Any updates on this?

@erickt
Copy link
Contributor

erickt commented Jul 7, 2014

One idea I was toying around with today was that if we did have Higher Order Types, we could design the std::io to optimize away the error branches for Writers that are statically guaranteed to never error, like MemWriter. We could declare the Writer trait to be:

trait Writer<M> {
    fn write(&mut self, buf: &[u8]) -> M<()>;
}

impl Writer<Identity> for MemWriter {
    fn write(&mut self, buf: &[u8]) -> Identity<()> {
        self.buf.push_all(buf);
        Identity(())
    }
} 

impl FdWriter<IoResult> for FileWriter {
    fn write(&mut self, buf: &[u8]) -> IoResult<()> {
        let len = libc::write(self.fd, buf.as_ptr());
        if len == -1 {
           Err(io_error_from_errno())
        } else {
           Ok(())
        }
    }
}

@bjadamson
Copy link
Contributor

Does anyone have a 'collection' on all the different discussions/blog posts about supporting HKT's in rust? Maybe a collection of relevant links that would be useful for implementing this feature? I think it would be really helpful if we started pooling our ideas together on how to implement HKT in rust.

@bjadamson
Copy link
Contributor

@nikomatsakis
Copy link
Contributor

I don't think there have been that many. I know I at least have had a lot of thoughts and discussions but relatively little time to write them out.

@thehydroimpulse
Copy link
Contributor

Should this be moved to the rfc issue tracker?

@aturon
Copy link
Member

aturon commented Sep 25, 2014

@thehydroimpulse Yes -- please ping @nick29581 (nrc on IRC)

@rust-highfive
Copy link
Collaborator

This issue has been moved to the RFCs repo: rust-lang/rfcs#324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

8 participants