[Haskell-cafe] ANN: HLint 1.2

Henning Thielemann lemming at henning-thielemann.de
Sat Feb 7 19:25:31 EST 2009


On Mon, 12 Jan 2009, Duncan Coutts wrote:

> On Mon, 2009-01-12 at 15:06 +0100, Henning Thielemann wrote:
>
>
>>> It has to be manually transformed into a version that is not recursive
>>> at the top level:
>>>
>>> map :: (a -> b) -> [a] -> [b]
>>> map f = go
>>>  where
>>>    go []     = []
>>>    go (x:xs) = f x : go xs
>>>
>>> Then the map can be inlined at the call site and the 'f' inlined into
>>> the body of 'go'.
>>
>> Maybe HLint can make such suggestions ...
>
> I think HLint's philosophy prefers elegant code to performance hacks.

I encountered just another instance of 'jumping into the wrong loop' when 
experimenting with a function using top-level recursion. Thus I summarized 
the stylistic reasons pro local recursion:
  http://www.haskell.org/haskellwiki/Top-level_vs._local_recursion


More information about the Haskell-Cafe mailing list