Deedle
Deedle copied to clipboard
Make $ operator work on frames
I was surprised when i saw this operator in the library. Why is it there? It feels the wrong way around for F#?
thanks don
In case it is not obvious, it is not the same as the Haskell $ operator. It applies a function to a series, which is an extremely common operation. Having something more concise than Series.mapValues f is useful. I would also be happy with "series $> f" or "f <$ series", making it more consistent with existing pipeline operators.
Is this even F# compatible?
s $> f
error FS0035: This construct is deprecated: '$' is not permitted as a character in operator names and is reserved for future use
No, it's not possible to use $>.
So $ is valid but $> is not?
On Fri, Nov 15, 2013 at 12:49 PM, Don Syme [email protected] wrote:
No, it's not possible to use $>.
— Reply to this email directly or view it on GitHubhttps://github.com/BlueMountainCapital/Deedle/issues/68#issuecomment-28588897 .
I always complain when people use custom operators in their F# libraries, so I'm probably the last person who would add operator like this to a library, but - I added this as an experiment when going through some research code at BMC that did heavy mapping over time series and it made the code much nicer.
I mind operators less if they are just an alternative to function:
// You can just use
ts |> Series.map foo
// And when you know the operator, you can use shorter
foo $ ts
I do not think this should be used with lambdas on left hand side - in that case, I'd always go with ordinary pipeline and mapValues
and that's also why I did not add $>
and <$
(and also, these are not above my personal bare for "nice operators" - but if others like them, that's ok..)
I think of it as "point-wise application" and that seems to be fairly reasonable use.
(More generally, this could also work on lists, sequences, etc., assuming that's technically possible)
(The overloading might be doable using this crazy hack)