I am trying to write Y combinator as C# delegate so I can understand the types but I am failing. I appreciate any help or hint.
Rec<T> Y<T>(ToRec<T> f)
{
Rec<T> nested(Rec<T> x)
{
return f(x(x));
}
return nested(nested);
}
Y<string>(Y); // This line doesn't type check
delegate Rec<T> ToRec<T>(T x);
delegate T Rec<T>(Rec<T> x);