2012-07-11 15:00:40 -07:00
|
|
|
trait vec_monad<A> {
|
|
|
|
fn bind<B>(f: fn(A) -> ~[B]);
|
|
|
|
}
|
|
|
|
|
2012-08-07 18:10:06 -07:00
|
|
|
impl<A> ~[A]: vec_monad<A> {
|
2012-06-29 16:26:56 -07:00
|
|
|
fn bind<B>(f: fn(A) -> ~[B]) {
|
2012-04-07 17:11:33 -07:00
|
|
|
let mut r = fail;
|
2012-06-30 16:19:07 -07:00
|
|
|
for self.each |elt| { r += f(elt); }
|
2012-06-30 12:23:59 +01:00
|
|
|
//~^ WARNING unreachable expression
|
|
|
|
//~^^ ERROR the type of this value must be known
|
2012-04-07 17:11:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fn main() {
|
2012-06-26 13:55:56 -07:00
|
|
|
["hi"].bind({|x| [x] });
|
2012-07-11 15:00:40 -07:00
|
|
|
}
|