public class DefaultEither : Either { private A theA; private B theB; public DefaultEither(A _theA, B _theB){ theA = _theA; theB = _theB; } public static DefaultEither newA(A _theA) { return new DefaultEither(_theA,default(B)); } public static DefaultEither newB(B _theB) { return new DefaultEither(default(A),_theB); } public A a() { return theA; } public bool isA() { return theA != null; } public B b() { return theB; } public bool isB() { return theB != null; } public Either fmap(System.Func f) { if (isA ()) { return this; } return newB(f(b())); } public Either bind (System.Func> f) { if (isA ()) { return this; } return f (b ()); } }