I have a complex example but I reduced the case using simple obejcts.
Given 2 functions:
let add (a:int) b = a + b
let aee (a:int[]) b = a.[0] + b
them can be used in this way:
let c = add 1 5
let a = [|1; 2|]
let d = aee a 5
So, why this is valid:
let c = 1 |> add 5
and this is not ?
let d = [|1;2|] |> aee 5 // Type mismatch, expecting int[] -> `a but given int -> int
My real scenario, in case it matters, is the following:
open FSUnit
type Tick (symbol:string, ask:decimal, bid:decimal) =
member __.Symbol = symbol
member __.Ask = ask
member __.Bid = bid
let containSymbol (ticks:Tick[]) symbol =
( ticks |> Array.tryFind (fun t -> t.Symbol = symbol) ).IsSome
let ticks = [| Tick("aaa", 1m, 2m) |]
// I'm able to do these
should be True <| containSymbol ticks "aaa"
containSymbol ticks "aaa" |> should be True
// but not this
ticks |> containSymbol CurrencyPair.XRP_BTC |> should be True // does not work as described in the small example
// or (desiderable) this
ticks |> should contain (fun t -> t.symbol = "aaa") // don't know how to create/pass a ContainwsConstraint with a function
Yes, the final goal is to be able to use ticks |> should contain (fun t -> t.symbol = "aaa") but I'm going with the first little step...