The following line is accepted by the compiler:
input |> Prop.forAll <| fun (a , b) -> add a b = add b a
However, when I replace the backwards pipline operator with parentheses, I receive an error:
input |> Prop.forAll ( fun (a , b) -> add a b = add b a )
Type mismatch. Expecting a Arbitrary -> 'a but given a ('b -> 'c) -> Property The type 'Arbitrary' does not match the type ''a -> 'b
I'm not quite sure what this error means. Why does the backwards pipeline operator compile but the parentheses doesn't?
Appendix:
module Arithmetic
let add a b =
a + b
open FsCheck
open FsCheck.Xunit
[<Property(MaxTest=1000, QuietOnSuccess=true)>]
let ``'a + 'b equals 'b + 'a`` () =
// Declare generators per type required for function
let intGenerator = Arb.generate<int>
// Map previously declared generators to a composite generator
// to reflect all parameter types for function
let compositeGenerator = (intGenerator , intGenerator) ||> Gen.map2(fun a b -> a , b)
// Pull values from our composite generator
let input = Arb.fromGen compositeGenerator
// Apply values as input to function
input |> Prop.forAll <| fun (a , b) -> add a b = add b a