Good Haskell Style
Thomas Schilling
nominolo at googlemail.com
Wed Aug 1 12:28:13 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 1 aug 2007, at 16.50, Simon Marlow wrote:
> > * Use the CamelCase variable naming convention
>
> I'm rather attached to the convention I use, which is
>
> - CamelCase for exported identifiers
> - underscores otherwise
>
> (I'm pretty sure I don't use it consistently, so don't bother to
> dig up counter-examples though).
>
> Why do I like this? Ideally we'd have an IDE which would colour my
> exported identifiers differently, but since I don't use such an IDE
> the CamelCase distinction gets some of the benefit. CamelCase for
> exported identifiers is already an established convention (which
> should really be part of a library API style guide), which leaves
> us with underscores for local identifiers.
>
> Yes I'm aware that a single-word identifier is the same in both
> conventions; it's not perfect.
I don't like that convention. It makes the code look really ugly. I
agree, that it'd be a good idea to have a visual indication what is
exported and what is not, but i'd strongly opt for something less
obtrusive. In any case, though, this is something this should be
done consistently or not at all; maybe we need some sort of haskell-
lint?
So, if leading underscores are used already, what about trailing
underscores?
myPublicFunction :: Foo -> Bar -> Baz
myPublicFunction f b = myInternalHelperFn_ (helper_ f b)
versus
yPublicFunction :: Foo -> Bar -> Baz
myPublicFunction f b = my_internal_helper_fn (helper f b)
it's also much easier to fix when actually exporting the identifier.
Just my 2 cents
/ Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iQEVAwUBRrC0nSuNq1ISBIDTAQKHdgf/WmuXYK/Se0PSfUZ4b6g6ZyouHpzCEz47
zEyrCxxEu8zInAsY0JAF8Iyfx0C1XTDNKLvq08pZhHmBGLF3nN2e8f1fRjm24wbx
UCxHK1vh8+aV5UnhS+DNoWi8kS6M5z2rezPohs3VI2H10SJKdsYYTJ3UdI+WPmlq
W3Pjcd6wfAoAF+l5e/AOu1TsQi5bi5yPeMzBncxNLA+UAuyQ+ud0jf4AgtfJ6Xz4
BKjq+YYpzpY+O3/VIFz6JSsV99QRcsP69qLPDTwyhXtfTCEUawSG8XEu4K9gSMvj
scWAopz9ymd8QdDt4OcvZ/qb3cr9/z1vWF38KLMv95u459fM12dvMA==
=XpJV
-----END PGP SIGNATURE-----
More information about the Libraries
mailing list