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

Comments

Projects
None yet
8 participants
@tiffany352

tiffany352 commented Sep 2, 2013

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

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Nov 12, 2013

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.

Contributor

nikomatsakis commented Nov 12, 2013

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

This comment has been minimized.

Show comment
Hide comment
@thehydroimpulse

thehydroimpulse Mar 27, 2014

Contributor

/cc me

Contributor

thehydroimpulse commented Mar 27, 2014

/cc me

@rizo

This comment has been minimized.

Show comment
Hide comment
@rizo

rizo Jul 4, 2014

Any updates on this?

rizo commented Jul 4, 2014

Any updates on this?

@erickt

This comment has been minimized.

Show comment
Hide comment
@erickt

erickt Jul 7, 2014

Contributor

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(())
        }
    }
}
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

This comment has been minimized.

Show comment
Hide comment
@bjadamson

bjadamson Sep 20, 2014

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.

Contributor

bjadamson commented Sep 20, 2014

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

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Sep 23, 2014

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.

Contributor

nikomatsakis commented Sep 23, 2014

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

This comment has been minimized.

Show comment
Hide comment
@thehydroimpulse

thehydroimpulse Sep 25, 2014

Contributor

Should this be moved to the rfc issue tracker?

Contributor

thehydroimpulse commented Sep 25, 2014

Should this be moved to the rfc issue tracker?

@aturon

This comment has been minimized.

Show comment
Hide comment
@aturon

aturon Sep 25, 2014

Member

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

Member

aturon commented Sep 25, 2014

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

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Sep 25, 2014

Collaborator

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

Collaborator

rust-highfive commented Sep 25, 2014

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