Ejemplo n.º 1
0
 /*
  * 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)
         )
 {
 }
Ejemplo n.º 2
0
 /*
  * 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)
         )
 {
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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'!");
     }
 }