RE: [Haskell-cafe] Point-free style (Was: Things to avoid)

2005-02-16 Thread Bernard Pope
On Mon, 2005-02-14 at 15:56 +, Simon Marlow wrote:
 
 I don't think a general things to avoid section should be advocating
 not naming things... in fact I would advocate the reverse.  Name as many
 things as possible, at least until you have a good feel for how much
 point-freeness is going to result in code that you can read again in 6
 months time.

Another reason to name more things is that it can make debugging easier,
especially in something like buddha where it tells you:

   name args = result

Also, avoiding excessive higher-order code can make debugging easier
too.

Cheers,
Bernie.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Point-free style (Was: Things to avoid)

2005-02-15 Thread Graham Klyne
[I drafted this response some time ago, but didn't send it, so apologies if 
I am re-covering old ground...]

At 09:23 10/02/05 -0500, Jan-Willem Maessen wrote:
If you're trying to avoid obscurity, why advocate point-free style?
Some time ago, I asked an experienced Haskell programmer about the extent 
to which they used point-free style in day-to-day programming, and the 
response I got was to the effect that they use point-full style a fair amount.

The ...er... point, I think, is that it is easier to reason equationally 
with point-free programs, even if the intended computation is often easier 
for mere mortals to see when named values are used.  So point-free style 
helps when trying to apply program transformation techniques, and 
translation to make greater use of point-free idioms may be a useful 
precursor to transforming a program.

Something I have noticed is that, as one gets more used to using higher 
order functions, it is often more elegant to express a computation by 
composition of functions, but in so doing one has to discard preconceived 
notions of what makes an efficient program.

I think it comes down to this: learn to be comfortable with both styles, 
and be prepared to use the one that best expressed the intended solution 
(and is easiest to understand) in any given context.

#g
--
At 09:23 10/02/05 -0500, Jan-Willem Maessen wrote:
If you're trying to avoid obscurity, why advocate point-free style?
I ask this question to be deliberately provocative; I'm not trying to 
single you out in particular.  So, to everybody: What's so great about 
point-free style?

Is it really clear or obvious what
 map . (+)
means?  Contrast this with
 \n - map (+n)
or
 \n xs - map (+n) xs
I submit that, while it is possible to develop a reading knowledge of 
point-free style, non-trivial use of point-free 
computations---compositions of functions with arity greater than 1, as 
above, compositions of sections of composition or application, arrow 
notation without the sugar, and so forth---will always be more difficult 
to read and understand than the direct version.  I submit that this is 
true even if one is familiar with point-free programming and skilled in 
its use.
Even something as simple as eta-reduction (as in the second and third 
functions above) can seriously obscure the meaning of program code by 
concealing the natural arity of a function.

-Jan-Willem Maessen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Graham Klyne
For email:
http://www.ninebynine.org/#Contact
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] Point-free style (Was: Things to avoid)

2005-02-14 Thread Simon Marlow
On 10 February 2005 14:23, Jan-Willem Maessen wrote:

 If you're trying to avoid obscurity, why advocate point-free style?
 
 I ask this question to be deliberately provocative; I'm not trying to
 single you out in particular.  So, to everybody: What's so great about
 point-free style?

I completely agree.  I find myself tending towards pointfull-style these
days, perhaps because I'm getting lazy and find it easier to read code
when lots of things have names.  I use explicit function definitions and
lambda bindings a lot more than I used to - at some point I figured out
that the number of characters in my source code isn't the right target
for optimisation :-)

I don't think a general things to avoid section should be advocating
not naming things... in fact I would advocate the reverse.  Name as many
things as possible, at least until you have a good feel for how much
point-freeness is going to result in code that you can read again in 6
months time.

Cheers,
Simon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Point-free style (Was: Things to avoid)

2005-02-10 Thread Matthew Roberts
I have to agree (although I suspect few others will :))
matt
On 11/02/2005, at 1:23 AM, Jan-Willem Maessen wrote:
On Feb 10, 2005, at 6:50 AM, Henning Thielemann wrote:
On Thu, 10 Feb 2005, [ISO-8859-1] Thomas Jäger wrote:
Altogether, the spirit of the page seems to be use as little
syntactic sugar as possible which maybe appropriate if it is aimed 
at
newbies, who often overuse syntactic sugar (do-notation).
This overuse is what I observed and what I like to reduce. There are 
many
people advocating Haskell just because of the sugar, which let 
interested
people fail to see what's essential for Haskell. When someone says to 
me
that there is a new language which I should know of because it 
supports
definition of infix operators and list comprehension, I shake my head 
and
wonder why he don't simply stick to Perl, Python, C++ or whatever.
If you're trying to avoid obscurity, why advocate point-free style?
I ask this question to be deliberately provocative; I'm not trying to 
single you out in particular.  So, to everybody: What's so great about 
point-free style?

Is it really clear or obvious what
 map . (+)
means?  Contrast this with
 \n - map (+n)
or
 \n xs - map (+n) xs
I submit that, while it is possible to develop a reading knowledge of 
point-free style, non-trivial use of point-free 
computations---compositions of functions with arity greater than 1, as 
above, compositions of sections of composition or application, arrow 
notation without the sugar, and so forth---will always be more 
difficult to read and understand than the direct version.  I submit 
that this is true even if one is familiar with point-free programming 
and skilled in its use.
Even something as simple as eta-reduction (as in the second and third 
functions above) can seriously obscure the meaning of program code by 
concealing the natural arity of a function.

-Jan-Willem Maessen
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe