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

Dan Piponi dpiponi at gmail.com
Wed Mar 25 18:11:50 EDT 2009

On Wed, Mar 25, 2009 at 12:44 PM, Thomas Hartman <tphyahoo at gmail.com> wrote:
>> Are you saying there's a problem with this implementation? It's the
> Yes, there is actually a problem with this implementation.

> However, there is something to be said for code that just looks like a
> duck and quacks like a duck. It's less likely to surprise you.

Well the problem here isn't that the code does something surprising.
It's author was making assumptions about the type of input that it's
going to get. I think that's an orthogonal issue.

> So... I insist... Easy for a beginner to read == better!

Not at all. Beginner list processing code can and often does go awry
when presented with infinite lists.

The moral here has nothing to do with readability by beginners. It's:
if the function you're defining could be extended naturally to
infinite lists, and it would be useful to do so, then make it do so.

More information about the Haskell-Cafe mailing list