Last active
November 30, 2020 13:53
-
-
Save masaeedu/1c997bc9586d53947bcf43e667647f67 to your computer and use it in GitHub Desktop.
Variadic experiments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq.Expressions; | |
using VMware.Vim; | |
namespace AgentAutomation.VimExtensions | |
{ | |
class Foo | |
{ | |
static void Main() | |
{ | |
var tup = Tuple.Make(11.5) | |
.And("Hello") | |
.And(DateTime.Now) | |
.And(42); | |
tup.Apply(v1 => v2 => v3 => v4 => Console.WriteLine($"{v1} is an int, {v2} is a date, and {v3} is a string, and {v4} is a double, and all of this is statically verifiable")); | |
} | |
} | |
public interface ISingle<TCurr> | |
{ | |
ITuple<TNext, TCurr, Func<TNext, Action<TCurr>>, ISingle<TCurr>> And<TNext>(TNext val); | |
} | |
public interface ITuple<TCurr, TPrev, in TFunc, out TParent>: ISingle<TCurr> | |
where TParent : ISingle<TPrev> | |
{ | |
new ITuple<TNext, TCurr, Func<TNext, TFunc>, ITuple<TCurr, TPrev, TFunc, TParent>> And<TNext>(TNext val); | |
void Apply(TFunc f); | |
} | |
public static class Tuple | |
{ | |
public static ISingle<TVal> Make<TVal>(TVal val) | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment