14 lines
342 B
Rust
14 lines
342 B
Rust
|
iface monad<A> {
|
||
|
fn bind<B>(fn(A) -> self<B>);
|
||
|
}
|
||
|
impl monad<A> of monad<A> for [A] {
|
||
|
fn bind<B>(f: fn(A) -> [B]) {
|
||
|
let mut r = fail;
|
||
|
for self.each {|elt| r += f(elt); }
|
||
|
//!^ WARNING unreachable expression
|
||
|
//!^^ ERROR the type of this value must be known
|
||
|
}
|
||
|
}
|
||
|
fn main() {
|
||
|
["hi"].bind {|x| [x] };
|
||
|
}
|