Skip to content

Instantly share code, notes, and snippets.

@Kimundi
Forked from DylanLukes/caters
Created January 10, 2014 15:27
Show Gist options
  • Save Kimundi/8356354 to your computer and use it in GitHub Desktop.
Save Kimundi/8356354 to your computer and use it in GitHub Desktop.
trait Category<S, T> {
fn id<A, AA: Category<A, A>>() -> AA;
fn compose<A, B, C, AB: Category<A, B>, BC: Category<B, C>, AC: Category<A, C>>(BC, AB) -> AC;
}
impl<'a, S, T> Category<S, T> for ('a |S| -> T) {
fn id<A, |A| -> A>() -> ('a |A| -> A) {
|a: A| -> A { a }
}
fn compose<A, B, C, |A| -> B, |B| -> C, |A| -> C>(f: |B| -> C, g: |A| -> B) -> ('a |A| -> C) {
|a: A| -> A { f(g(a))}
}
}
% rustc peg.rs !3563
peg.rs:7:14: 7:15 error: expected ident, found `|`
peg.rs:7 fn id<A, |A| -> A>() -> ('a |A| -> A) {
^
task 'rustc' failed at 'explicit failure', /private/tmp/rust-R5p2/rust-0.9/src/libsyntax/diagnostic.rs:41
task '<main>' failed at 'explicit failure', /private/tmp/rust-R5p2/rust-0.9/src/librustc/lib.rs:453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment