48
1
using System;
2
3
public static class Either
4
{
5
public static Either<A> Return<A>(A val)
6
{
7
return new Either<A> { Right = val };
8
}
9
10
public static Either<A> Fail<A>(Exception e)
11
{
12
return new Either<A> { Left = e };
13
}
14
}
15
16
public class Either<A>
17
{
18
public Exception Left;
19
public A Right;
20
21
public Either<B> Bind<B>(Func<A,Either<B>> f)
22
{
23
if (Left != null) return Either.Fail<B>(Left);
24
Cached Result
Test()
Test<T>()
Test<T>()