1 #![feature(generic_associated_types)]
2
3 trait Monad {
4 type Unwrapped;
5 type Wrapped<B>;
6
bind<B, F>(self, f: F) -> Self::Wrapped<B>7 fn bind<B, F>(self, f: F) -> Self::Wrapped<B> {
8 todo!()
9 }
10 }
11
join<MOuter, MInner, A>(outer: MOuter) -> MOuter::Wrapped<A> where MOuter: Monad<Unwrapped = MInner>, MInner: Monad<Unwrapped = A, Wrapped = MOuter::Wrapped<A>>,12 fn join<MOuter, MInner, A>(outer: MOuter) -> MOuter::Wrapped<A>
13 where
14 MOuter: Monad<Unwrapped = MInner>,
15 MInner: Monad<Unwrapped = A, Wrapped = MOuter::Wrapped<A>>,
16 //~^ ERROR: missing generics for associated type `Monad::Wrapped`
17 {
18 outer.bind(|inner| inner)
19 }
20
main()21 fn main() {
22 assert_eq!(join(Some(Some(true))), Some(true));
23 }
24