Skip to content

Instantly share code, notes, and snippets.

@yuchiki
Created July 31, 2018 07:50
Show Gist options
  • Save yuchiki/a7a5bdcf70e06165f373aeefec794950 to your computer and use it in GitHub Desktop.
Save yuchiki/a7a5bdcf70e06165f373aeefec794950 to your computer and use it in GitHub Desktop.
using System;
static class Program {
static void Main() {
Zero().Succ().Succ().Pred().Succ().Pred().Succ().Succ().Show();
var three = Zero().Succ().Succ().Succ();
var four = Zero().Succ().Succ().Succ().Succ();
// How to write??????
// Plus(three, four).Show();
// Twice(three).Show();
// Mult(three, four).Show()l
}
static Z Zero() => new Z();
static S<N> Succ<N>(this N n) where N : Nat => new S<N>();
static N Pred<N>(this S<N> n) where N : Nat, new() => new N();
}
abstract class Nat {
public void Show() => Console.WriteLine(this);
}
class Z : Nat {}
class S<T> : Nat where T : Nat {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment