Jonathan King writes:

> So, the name of a type is always at least a full word, as are the names of
> specific functions.  But type variables are almost always single
> characters, and distinct from the names of any type.  Conventionally, they
> are also usually "a", "b", and "c", although "m" is for monad.
> Conventionally also, generic function arguments are "f" and "g", the
> conventional predicate is "p". Generic arguments are "x" and "y" (or "xs"
> and "ys" if they are lists); arguments with specified types are usually
> the first letter of their type name (e.g., "c" for Char, "i" for an Int;
> "n" and "m" are indices)... that covers most of it, I think.
> 
> I think most of the Haskell code I've ever seen that *wasn't* written by
> me follow these conventions pretty closely.  But the strange thing is...I
> haven't found a prominent place on, e.g., the Haskell home page where this
> is spelled out. (Please tell me if I'm missing anything obvious.) In a
> way, I guess this is trivial, but I know from hard experience it can often
> take a long time to become completely aware of trivial things.

I think this kind of thing is valuable... Hungarian notation [1] serves the same 
purpose in Windows C / C++ programming.  It *is* valuable having canonical variable 
names for most situations; it reduces the intellectual load on the (human) reader of 
the code... you don't have to check back to the type signature and argument list to 
figure out what a particular variable denotes; it's just obvious from the name.

--KW 8-)


[1] @Article{
   Simonyi*91:Hungarian,
   author="Charles Simonyi and Martin Heller",
   title="The {H}ungarian Revolution",
   journal="{BYTE}",
   year="1991",
   volume="16",
   number="8",
   pages="{131--138}",
   month=aug,
   abstract="For all the attention given to names in the literature and
      magic (for to name a thing is to control it), names in programming
      languages have received curiously little attention.  Although
      today's computer programming languages force a rigid syntax on
      the programmer, they permit the use of more or less arbitrary
      names for variables, functions, and macros.  A reasonable standard
      for variable naming helps the development and maintenance of
      software.",
}


-- 
: Keith Wansbrough, MSc, BSc(Hons) (Auckland) ------------------------:
: PhD Student, Computer Laboratory, University of Cambridge, England. :
:  (and recently of the University of Glasgow, Scotland. [><] )       :
: Native of Antipodean Auckland, New Zealand: 174d47' E, 36d55' S.    :
: http://www.cl.cam.ac.uk/users/kw217/  mailto:[EMAIL PROTECTED]     :
:---------------------------------------------------------------------:




Reply via email to