[Haskell-cafe] let and fixed point operator
s.clover at gmail.com
Fri Aug 31 16:01:14 EDT 2007
On this topic, I'm just now teaching myself Haskell and am running into a
whole range of stylistic questions like this. My big bad Java habits tend
towards long camelCase function names, which I'm trying to wean myself off.
But the variable conventions are the real issue. As far as I can tell, if
you're writing type descriptors you just use [a,b,c...]. But what are the
other general patterns for metasyntactic variable use?
In particular for a function -- n, m, etc or x, y, etc? What about for f'
defined in a let block of f? If I use x y at the top level I need to use
another set below -- is that where x' y' are more appropriate, or x1, y1?
For tuples I tend to pattern match with (a,b), and for lists I tend to use
(h:r) for head and rest. Are there other, more universal standards for these
sorts of things? Another related question is whether using these short sweet
variable names makes sense, or whether I should try to use more descriptive
ones. Obviously these are pretty small points of style, but I'm just trying
to nail the Haskell idiom as closely as possible.
I've already found myself falling into namespace traps though, playing
around with math functions & etc. where an adequately descriptive name for
one context in maybe a let block steps on something which deserves the name
equally well in the global namespace. I try to keep the global namespace
pretty clean, but things keep popping up -- I'm thinking maybe another
convention would come to the rescue here, like camelCase or hyphen-ated for
global and all lowers for local?
On 8/31/07, Paul Hudak <paul.hudak at yale.edu> wrote:
> ok wrote:
> > What is so bad about
> > f x = g x''
> > where x'' = x' + transform
> > x' = x * scale
> > (if you really hate inventing temporary names, that is).
> There's nothing at all wrong with this, assuming it's what you meant to
> type :-), and it might even correspond perfectly to the mathematical
> notation used in some textbook. But I would argue that this example is
> pretty simple, and that if there were a lot of xs and x's and x''s then
> the chance of making a typing mistake is greater, I believe, than if you
> had used x, xscaled, and xtransformed. (On the other hand this is all
> pretty subjective... :-)
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe