[Haskell-beginners] Good style on "." and "$" pipeline?

Chaddaï Fouché chaddai.fouche at gmail.com
Wed Aug 22 12:36:39 CEST 2012

On Wed, Aug 22, 2012 at 3:41 AM, Felipe Almeida Lessa
<felipe.lessa at gmail.com> wrote:
> On Tue, Aug 21, 2012 at 10:34 PM, koomi <koomi at hackerspace-bamberg.de> wrote:
>> On 21.08.2012 22:43, Brent Yorgey wrote:
>>> Having more than one $, like (f1 $ f2 $ fn $ arg), is frowned upon.
>> Care to explain why this is considered bad? I don't see anything wrong
>> with this.
> It's just a matter of taste.  Personally, I usually prefer using many
> ($)s rather than combining (.)s and ($)s on the same "phrase".

It is a bit more than a matter of taste : the (.)s then one ($) style
allows easier and clearer refactoring because each part of the
function pipeline can be just copy pasted somewhere else, for instance
you can get from :

> bigFunc = f1 . f2 . f3 . f4 $ arg


> bigFunc = f1 . meaningfulFunc . f4 $ arg
> meaningfulFunc = f2 . f3

without rewriting a bit of your pipeline to change $ to . or add a
point to meaningfulFunc (note that I ignore the monomorphism
restriction here, I would give those function signatures anyway since
they're top-level).

I find this style makes it easier to reason about in a purely
"pipelinesque" way (focused on functions and their combinations).


More information about the Beginners mailing list