I would like to create a procedure class that supports connecting to another procedure like so: a|b|c|d (this should result a procedure takes a's input type, and give d's output type)
class Procedure<I,O>
{
public Func<I,O> func;
public Procedure(Func<I, O> func)
{ this.func = func; }
public static Procedure<I, O> operator| (Procedure<I, M> proc1, Procedure<M, O> proc2)
{ return new Procedure<I,O>((x) => proc2.Process(proc1.Process(x))); }
public O Process(I input)
{ return func.Invoke(input); }
}
The compiler complains it can't find M. Normally I would add after the method name, however in this case it gets recognized as part of the operator name. What do?
Just a side note, I'm trying to move my Scala lib into C# here.