I have a function that I use quite frequently, which allows me to write my code in a way which seems more natural to me.
infixl 6 $:
($:) :: a -> (a -> b) -> b
a $: f = f a
This lets me do something like
let x = getData
$: sort
$: group
$: aggregate
instead of
let x = aggregate
$ group
$ sort
$ getData
I recently learned that Clojure has something like this built in (I don't know much Clojure, but I think it would be written (-> getData sort group aggregate)
?) which makes me wonder if Haskell has it built in as well. Hoogle doesn't have any results though.
Are there any standard libs with something similar included? It probably makes my code hard for others to read if I have such a common part is idiosyncratic.
#
as per OOHaskell, since it is fundamentally the same operation as method selection on objects and the#
is the operator used for this in OCaml. Alternatively, copying F# we could use|>
flip ($)
to Data.Function, but it was dropped because no consensus could be reached on whether such a thing would be useful (opposed to confusing to beginners etc.) to have. Here's the discussion: markmail.org/message/vsplpb7aajp7goqo?q=python&
operator is by now pretty widely used (presumably, mostly thanks to the highly influentiallens
library, which includes it in its standard coding style).