public void BindToProperty () { var tc = new TestClass(); var ts = new TestStruct(); var f = new Future<int>(); f.Bind(() => tc.Property); try { f.Bind(() => ts.Property); Assert.Fail("Did not throw InvalidOperationException"); } catch (InvalidOperationException) { } f.Complete(5); Assert.AreEqual(5, tc.Property); Assert.AreNotEqual(5, ts.Property); }
public void CanBindFutureToOtherFuture () { var a = new Future<object>(); var b = new Future<object>(); b.Bind(a); a.Complete(5); Assert.AreEqual(5, b.Result); }
public static Future <C> SelectMany <A, B, C>(this Future <A> m, Func <A, Future <B> > k, Func <A, B, C> f) { return(m.Bind(a => k(a).Bind <B, C>(b => f(a, b).PureFuture()))); }
public static Future <T> Join <T>(this Future <Future <T> > future) { return(future.Bind(a => a)); }
public static Future <B> SelectMany <A, B>(this Future <A> m, Func <A, Future <B> > k) { return(m.Bind(k)); }