Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It indeeds looks a bit magical, like the infamous fibonacci example that uses lazy lists.

I don't think that list comprehensions are very idiomatic in Haskell, one would probably use Data.List.partition instead:

    qsort [] = []
    qsort (p:xs) = low ++ [p] ++ high
        where (low, high) = partition (< p) xs


I think you are missing the recursive calls ;).


Indeed!

Hey, who said that static typing caught all bugs ? :)


Sure it does, you just need Quickcheck property based testing:

    forall $ \xs -> sorted (qsort xs :: [Int])


That's not static.


Or typing


No, it's not, but Haskell's type system is what allows quickcheck to work as well as it does. The implementations in other languages mostly lack a lot of the power provided by the type system.




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

Search: