Hacker News new | ask | show | jobs
by shangaslammi 4139 days ago
Yeah, the online REPL is definitely not very useful or intuitive yet.

As it says, you can evaluate a single line Haskell "expression" and top-level declarations (like the sieve example) are not expressions. In addition, the sieve example declares an infinite list so there's no sensible way to print it.

You can fix all the above by using a let-expression on single line and only evaluating a finite part of the list using the 'take' function.

    let { primes = sieve [2..]; sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0] } in take 10 primes