public NewType <T> SelectMany( Func <T, NewType <T> > bind, Func <T, T, T> project ) { var ures = bind(Value); if (GetType() != ures.GetType()) { throw new Exception("LINQ statement with mismatched NewTypes"); } return((NewType <T>)NewType.Construct(GetType(), project(Value, ures.Value))); }
public NewType <T> Select(Func <T, T> map) => (NewType <T>) NewType.Construct(GetType(), map(Value));
public static S fold <NEWTYPE, T, S, PRED>(NewType <NEWTYPE, T, PRED> value, S state, Func <S, T, S> folder) where PRED : struct, Pred <T> where NEWTYPE : NewType <NEWTYPE, T, PRED> => value.Fold(state, folder);
public static bool forall <NEWTYPE, T, PRED>(NewType <NEWTYPE, T, PRED> value, Func <T, bool> predicate) where PRED : struct, Pred <T> where NEWTYPE : NewType <NEWTYPE, T, PRED> => predicate((T)value);
public static NEWTYPE bind <NEWTYPE, T, PRED>(NewType <NEWTYPE, T, PRED> value, Func <T, NEWTYPE> bind) where PRED : struct, Pred <T> where NEWTYPE : NewType <NEWTYPE, T, PRED> => value.Bind(bind);
public static NewType <T> divide <T>(NewType <T> value, NewType <T> rhs) => value.Divide(rhs);
public static NewType <T> append <T>(NewType <T> value, NewType <T> rhs) => value.Append(rhs);
public static NewType <T> map <T>(NewType <T> value, Func <T, T> map) => value.Map(map);
public static S Fold <T, S>(this NewType <T> self, S state, Func <S, T, S> folder) => folder(state, self.Value);
public NewType <T> Multiply(NewType <T> rhs) => GetType() == rhs.GetType() ? (NewType <T>) NewType.Construct(GetType(), TypeDesc.Multiply(Value, rhs.Value, TypeDesc <T> .Default)) : failwith <NewType <T> >("Mismatched NewTypes in multiply");
public NewType <T> Divide(NewType <T> rhs) => GetType() == rhs.GetType() ? (NewType <T>) NewType.Construct(GetType(), TypeDesc.Divide(Value, rhs.Value, TypeDesc <T> .Default)) : failwith <NewType <T> >("Mismatched NewTypes in divide");
public NewType <T> Subtract(NewType <T> rhs) => GetType() == rhs.GetType() ? (NewType <T>) NewType.Construct(GetType(), TypeDesc.Subtract(Value, rhs.Value, TypeDesc <T> .Default)) : failwith <NewType <T> >("Mismatched NewTypes in subtract");
public NewType <T> Append(NewType <T> rhs) => GetType() == rhs.GetType() ? (NewType <T>) NewType.Construct(GetType(), TypeDesc.Append(Value, rhs.Value, TypeDesc <T> .Default)) : failwith <NewType <T> >("Mismatched NewTypes in append/add");
public static bool exists <T>(NewType <T> value, Func <T, bool> predicate) => predicate(value.Value);
public static int Sum(this NewType <int> self) => self.Value;
public static bool forall <T>(NewType <T> value, Func <T, bool> predicate) => predicate(value.Value);
public int CompareTo(NewType <T> other) => !ReferenceEquals(other, null) && GetType() == other.GetType() ? Comparer <T> .Default.Compare(Value, other.Value) : failwith <int>("Mismatched NewTypes used in comparison");
public static S fold <T, S>(NewType <T> value, S state, Func <S, T, S> folder) => value.Fold(state, folder);
public bool Equals(NewType <T> other) => !ReferenceEquals(other, null) && GetType() == other.GetType() && Value.Equals(other.Value);
public static NewType <T> subtract <T>(NewType <T> value, NewType <T> rhs) => value.Subtract(rhs);
public static NewType <T> bind <T>(NewType <T> value, Func <T, NewType <T> > bind) => value.Bind(bind);
public static NewType <T> multiply <T>(NewType <T> value, NewType <T> rhs) => value.Multiply(rhs);
public static Unit iter <T>(NewType <T> value, Action <T> f) => value.Iter(f);
public static Unit iter <NEWTYPE, T, PRED>(NewType <NEWTYPE, T, PRED> value, Action <T> f) where PRED : struct, Pred <T> where NEWTYPE : NewType <NEWTYPE, T, PRED> => value.Iter(f);
public static int count <T>(NewType <T> value) => 1;
public static NEWTYPE map <NEWTYPE, T, PRED>(NewType <NEWTYPE, T, PRED> value, Func <T, T> map) where PRED : struct, Pred <T> where NEWTYPE : NewType <NEWTYPE, T, PRED> => value.Map(map);
public static int sum(NewType <int> value) => value.Value;
public static bool equals <NEWTYPE, EQ, A, PRED>(NewType <NEWTYPE, A, PRED> x, NewType <NEWTYPE, A, PRED> y) where EQ : struct, Eq <A> where PRED : struct, Pred <A> where NEWTYPE : NewType <NEWTYPE, A, PRED> => !ReferenceEquals(x, y) || ReferenceEquals(x, null) || ReferenceEquals(y, null) ? false : default(EQ).Equals((A)x, (A)y);
public static NEWTYPE append <NEWTYPE, SEMI, A>(NewType <NEWTYPE, A> x, NewType <NEWTYPE, A> y) where NEWTYPE : NewType <NEWTYPE, A> where SEMI : struct, Semigroup <A> => from a in x from b in y select default(SEMI).Append(a, b);