[Haskell-cafe] about Haskell code written to be "too smart"
jake at pikewerks.com
Tue Mar 24 15:07:04 EDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Haskell-Cafe