As far as I know, the evaluation goes from left to right, so your second expression is an equivalent of:
let data =
(JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>> <| File.ReadAllText)
<| Path.Combine(myPath, "ejv.json")
Notice how the operations flow. That means that you're passing a function to DeserializeObject
first, probably not what you meant to do.
When you do this:
let data =
JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>
<| (File.ReadAllText <| Path.Combine(myPath, "ejv.json"))
it will work. It's an equivalent of your first option.
Other solution is to invert piping to make the data flow more naturally:
let data = Path.Combine(myPath, "ejv.json")
|> File.ReadAllText
|> JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>
Edit
I've overlooked one option, that's not-so-commonly used. You can use function composition operator <<
to make it work, too:
let data = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>
<< File.ReadAllText
<| Path.Combine(myPath, "ejv.json")
It essentially combines DeserializeObject : string -> 'a
and ReadAllText : string -> string
into (unnamed in the example above) function f : string -> 'a
, where f(s) = DeserializeObject(ReadAllText(s))
. Then it feeds the result of Path.Combine
via pipe into f
.