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.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe