NLinker icon

SK combinators in Rust

NLinker | PRO | 09/21/20 10:29:13 AM UTC | 0 ⭐ | 8782 👁️ | Never ⏰ | []
Rust |

660 B

|

None

|

0 👍

/

0 👎

// by Hirrolot
 
use std::marker::PhantomData;
 
struct S<X, Y>(PhantomData<X>, PhantomData<Y>);
struct K<X>(PhantomData<X>);
struct Var<X>(PhantomData<X>);
 
struct Appl<M, N>(PhantomData<M>, PhantomData<N>);
 
trait Reduce {
    type Result;
}
 
impl<X, Y, Z> Reduce for Appl<S<X, Y>, Z> where {
    type Result = Appl<Appl<X, Y>, Appl<Z, Y>>;
}
 
impl<X, Y> Reduce for Appl<K<X>, Y> {
    type Result = X;
}
 
impl<N, X> Reduce for Appl<Var<X>, N> {
    type Result = Self;
}
 
struct MyVar0;
struct MyVar1;
struct MyVar2;
 
fn main() {
    let _0: <Appl<Var<MyVar0>, Appl<K<MyVar1>, MyVar2>> as Reduce>::Result = todo!();
  //  let () = _0;
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎