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

Jonathan Cast jonathanccast at fastmail.fm
Tue Mar 24 17:44:35 EDT 2009


On Tue, 2009-03-24 at 22:43 +0100, Manlio Perillo wrote:
> Jonathan Cast ha scritto:
> > [...]
> > 
> > I think, in general, the best way to document the purpose of the
> > function is
> > 
> >     -- | Split a function into a sequence of partitions of specified
> > lenth
> >     takeList :: [Int] -> [a] -> [[a]]
> > 
> 
> Note that I was not speaking about the best way to document a function.
> 
> I was speaking about the best way to write a function, so that it may 
> help someone who is learning Haskell.

I've already explicitly rejected the claim that professional Haskell
code should be written to aid beginning users.  Again, that's what
textbooks are for.

And I was explicitly commenting on the claim that it was obvious, from
any version posted thus far, what the function was supposed to do.  Your
suggested code hardly helps make the function's purpose clear; comments
(or, better yet, tests, such as:

    prop_length = \ ns xn -> sum ns <= length xn ==>
        map length (takeList ns xn) == ns

do a much better job of explaining purpose).

jcc




More information about the Haskell-Cafe mailing list