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?
<br><br>In particular for a function -- n, m, etc or x, y, etc? What about for f&#39; 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&#39; y&#39; are more appropriate, or x1, y1?
<br><br>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&#39;m just trying to nail the Haskell idiom as closely as possible.
<br><br>I&#39;ve already found myself falling into namespace traps though, playing around with math functions &amp; 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&#39;m thinking maybe another convention would come to the rescue here, like camelCase or hyphen-ated for global and all lowers for local?
<br><br>--S.<br><br><div><span class="gmail_quote">On 8/31/07, <b class="gmail_sendername">Paul Hudak</b> &lt;<a href="mailto:paul.hudak@yale.edu">paul.hudak@yale.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
ok wrote:<br>&gt; What is so bad about<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; f x = g x&#39;&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where x&#39;&#39; = x&#39; + transform<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&#39;&nbsp;&nbsp;= x&nbsp;&nbsp;* scale<br>&gt;<br>&gt; (if you really hate inventing temporary names, that is).
<br>There&#39;s nothing at all wrong with this, assuming it&#39;s what you meant to<br>type :-), and it might even correspond perfectly to the mathematical<br>notation used in some textbook.&nbsp;&nbsp;But I would argue that this example is
<br>pretty simple, and that if there were a lot of xs and x&#39;s and x&#39;&#39;s then<br>the chance of making a typing mistake is greater, I believe, than if you<br>had used x, xscaled, and xtransformed.&nbsp;&nbsp;(On the other hand this is all
<br>pretty subjective... :-)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;-Paul<br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">
http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>