Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upHigher kinded polymorphism #8922
Comments
nikomatsakis
referenced this issue
Nov 12, 2013
Closed
Allow lifetime parameters on generic types #8973
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
/cc me |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rizo
commented
Jul 4, 2014
|
Any updates on this? |
erickt
referenced this issue
Jul 7, 2014
Closed
Should we track incomplete ideas here instead of in the rust issue tracker? #158
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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(())
}
}
}|
One idea I was toying around with today was that if we did have Higher Order Types, we could design the 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(())
}
}
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Should this be moved to the rfc issue tracker? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@thehydroimpulse Yes -- please ping @nick29581 (nrc on IRC) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rust-highfive
Sep 25, 2014
Collaborator
This issue has been moved to the RFCs repo: rust-lang/rfcs#324
|
This issue has been moved to the RFCs repo: rust-lang/rfcs#324 |
tiffany352 commentedSep 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.