Re:Simple Ways of Reducing the Cognitive Load in Code
by emillon on Tuesday June 28, 2016 @10:09AM
(#11993889)
It's more like the pipe operator in ocaml (http://blog.shaynefletcher.org/2013/12/pipelining-with-opera...). The lisp version has the extra advantage that you don't have to repeat it between all the intermediate functions. ((->> 2 (* 100) str count) vs 2 |> (* 100) |> str |> count).
Re:Simple Ways of Reducing the Cognitive Load in Code
by greggyb on Tuesday June 28, 2016 @02:52PM
(#11996427)
I understand how a lisp implementation would work here to require only the single operator (I'm assuming a fairly simple macro).
Would it not be possible to do something similar in another functional language to take a <pipe function> and apply it sequentially to a list of function calls?
Re:Simple Ways of Reducing the Cognitive Load in Code
by emillon on Thursday June 30, 2016 @03:38AM
(#12007112)
There are no semantic problems with this, but typing will get in the way: you can express it fairly easily if all the functions have the same type (such as Int -> Int): actually it's just 'foldr ($)'. But it is difficult to type a list of functions such as each member's return value has the same type as the next one's parameter (symbolically, [an-1 -> an, ..., a1 -> a2, a0 -> a1]). It's easier to refer to the composition of such functions, which is why you would see it as 'h . g . f'.
Re:Simple Ways of Reducing the Cognitive Load in Code
by kilotaras on Tuesday June 28, 2016 @11:28AM
(#11994518)
|> from scalaz. API is not that usable though. F# have List.map, List.filter functions for example, which are not present in scala.
Re:Simple Ways of Reducing the Cognitive Load in Code
by premium-concern on Tuesday June 28, 2016 @08:41PM
(#11998720)
It doesn't seem to have worked out for F# as they have recently adopted what Scala has been doing for years.
[1]: http://lambda.jstolarek.com/2012/03/function-composition-and...