lambdaski/
lib.rs

1use std::marker::PhantomData;
2
3pub struct S;
4pub struct K;
5pub struct I;
6pub struct S1<X>(pub PhantomData<X>);
7pub struct S2<X, Y>(pub PhantomData<(X, Y)>);
8pub struct K1<X>(pub PhantomData<X>);
9
10pub trait A<In> {
11	type O;
12}
13impl<T> A<T> for S {
14	type O = S1<T>;
15}
16impl<X, T> A<T> for S1<X> {
17	type O = S2<X, T>;
18}
19impl<X, Y, T> A<T> for S2<X, Y>
20	where X: A<T>, Y: A<T>, <X as A<T>>::O: A<<Y as A<T>>::O>
21{
22	type O = <<X as A<T>>::O as A<<Y as A<T>>::O>>::O;
23}
24
25impl<T> A<T> for K {
26	type O = K1<T>;
27}
28impl<X, T> A<T> for K1<X> {
29	type O = X;
30}
31
32impl<T> A<T> for I {
33	type O = T;
34}
35
36#[cfg(test)]
37mod tests {
38	use super::*;
39	#[test]
40	fn it_works() {
41		//let _: <<S as A<I>>::O as A<I>>::O;
42		//let _: <<<S as A<I>>::O as A<I>>::O as A<<<S as A<I>>::O as A<I>>::O>>::O;
43		let _: <<<S as A<K>>::O as A<I>>::O as A<K>>::O;
44		assert!(false);
45	}
46}