Hacker News new | past | comments | ask | show | jobs | submit login

Well SC's proprietary compiler is probably different, but GHC is self-hosted (the runtime system is C but the compiler is implemented in Haskell) and the map and fold functions in Prelude are recursive. Here's the source code for `map` in Prelude:

    map :: (a -> b) -> [a] -> [b]
    map f []     = []
    map f (x:xs) = f x : map f xs
But it is definitely still true that explicit recursion is discouraged as being too 'low-level' for most Haskell code and it's preferable to use higher-order functions instead.



Yes, Standard Chartered's compiler a bit different from ghc. That's mostly for historical reasons.

Yes, GHC can and does just use the recursive goodness, and compile it away to no-stackframe-adding jumps.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: