[Haskell-cafe] about Haskell code written to be "too smart"

Jake McArthur jake at pikewerks.com
Tue Mar 24 15:07:04 EDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Manlio Perillo wrote:
| This is right.
| The problem is that often (IMHO) a function definition can be rewritten
| so that it is much more readable.
|
| As an example, with the takeList function I posted.

I looked at it, found nothing wrong with the original, and absolutely
hated your "fixed" version. I might have written it like this, instead:

~    buildPartitions xs ns = zipWith take ns . init . scanl (flip drop)
xs $ ns

I think this way separates the different "stages" of the function
somewhat better, but it's barely a change. The original was fine.

| In other cases, you can just break long lines, introducing intermediate
| functions that have a descriptive name *and* a type definition.
|
| Doing this is an art, but a coding style for Haskell should try to
| document this.

Agreed.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknJL1gACgkQye5hVyvIUKnF/ACgjbd+gjolHCiS9tWosbiH3gnX
j0EAn2zbeanj9UUQnl1pnQ+GRdPpYiRj
=h5bU
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list