/* * An arrow form of the Assoc function in Utils - saves the faff of creating one whenever * it's used */ public AssocArrow() : base( (Tuple <Tuple <A, B>, C> x) => TupleOp.Assoc(x) ) { }
/* * An arrow form of the Cossa function in Utils - saves the faff of creating one whenever * it's used */ public CossaArrow() : base( (Tuple <A, Tuple <B, C> > x) => TupleOp.Cossa(x) ) { }
public static bool ArgumentCountsCorrectForArrow(int sourceCount, int destinationCount, IArrow arrow) { /* * Checks the numbers of arguments being provided for the given arrow match the tuple * sizes expected */ Type inputTupleType = arrow.a; Type outputTupleType = arrow.b; return(TupleOp.CountLeaves(inputTupleType) == sourceCount && TupleOp.CountLeaves(outputTupleType) == destinationCount); }
public override dynamic Invoke <T>(T input) { try { if (typeof(T) != typeof(A)) { return(func((A)TupleOp.ConvertType(input, typeof(A)))); } else { return(func((A)Convert.ChangeType(input, typeof(A)))); } } catch (Exception) { throw new Exception("Invalid type supplied to 'Arrow.Invoke'!"); } }