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

Darren Grant therealkludgy at gmail.com
Tue Aug 21 22:43:37 CEST 2012


I am very new to Haskell, but what I've discovered so far is that the
application operator $ is used to improve code readability. It can
sometimes be used eliminate the need for parentheses that break
natural left-to-right reading.

Hoogle covers an example:
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:-36-


Cheers!



On Tue, Aug 21, 2012 at 1:34 PM, Carlos J. G. Duarte
<carlos.j.g.duarte at gmail.com> wrote:
> Hi. Often I see the following pattern to build function "pipelines":
>
> x = f1 . f2 $ fn arg
>
> They use the "$" just before the last function call. I never got much into
> it: when to use the "." or the "$"? I think today I figured it out:
> => "." is a function composition operator: used to "merge" functions;
> => "$" is a function application operator: used to apply a function to its
> arguments.
>
> If this reasoning is correct, I think the following should be a more
> adequate pattern:
>
> x = f1 . f2 . fn $ arg
>
> To merge/compose all functions first and apply the composed function to its
> parameter(s).
> Am I correct on this? Thx
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>



More information about the Beginners mailing list