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

Conal Elliott conal at conal.net
Tue Mar 24 16:55:41 EDT 2009


"Recursion is the goto of functional programming".  Also, "Do not confuse
what is natural with what is habitual."  - Conal

On Tue, Mar 24, 2009 at 1:51 PM, Manlio Perillo <manlio_perillo at libero.it>wrote:

> Jake McArthur ha scritto:
>
>> [...]
>> | With my function, instead, you only have to "follow" 1 operation:
>> |
>> | Prelude> (head, tail) = splitAt n xs
>>
>> I think you are way oversimplifying your own code.
>>
>> ~    takeList :: [Int] -> [a] -> [[a]]
>> ~    takeList [] _         =  []
>> ~    takeList _ []         =  []
>> ~    takeList (n : ns) xs  =  head : takeList ns tail
>> ~        where (head, tail) = splitAt n xs
>>
>> In order to understand this, I have to look at three different cases, an
>> uncons, a splitAt, a cons, *and* a recursive call. This is *seven*
>> different things I have to absorb.
>>
>
> These cases are, IMHO, more "natural".
>
> We have a set of equations, pattern matching and recursion.
> These are one of the basic building block of Haskell.
>
> The only "foreign" building block is the splitAt function.
>
> But this may be really a question of personal taste or experience.
> What is more "natural"?
>
> 1) pattern matching
> 2) recursion
> or
> 1) function composition
> 2) high level functions
>
> ?
>
> > [...]
>
>
> Manlio
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090324/4fc8a221/attachment.htm


More information about the Haskell-Cafe mailing list