[Haskell-cafe] ANN: HLint 1.2

Henning Thielemann lemming at henning-thielemann.de
Mon Jan 12 09:58:27 EST 2009


On Mon, 12 Jan 2009, Neil Mitchell wrote:

> Hi
>
>>> No because the current definition are recursive and ghc cannot inline
>>> recursive functions.
>>
>>> 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 ...
>
> HLint would probably just suggest you use a supercompiler*, for which
> specialisation such as this is easy
> (http://www.cs.york.ac.uk/~ndm/supero). HLint is about making code
> prettier,

Actually, I find the 'go' variant prettier, because it clearly shows that 
the 'f' is not "altered" in the recursion.


More information about the Haskell-Cafe mailing list