
16 Apr
2009
16 Apr
'09
10:16 p.m.
G'day all.
Quoting Eugene Kirpichov
I'd suggest also
primesFrom :: Integer -> [Integer]
This: primes :: [Integer] isn't as useful as you might think for a library, because it must, by definition, leak an uncontrolled amount of memory. This: primesUpTo :: Integer -> [Integer] is a better interface in that respect. For the number theory library, I went overboard with a bunch of type classes. I don't have the code handy, but this was the sort of thing: class TestableProperty s a | s -> a where is :: s -> a -> Bool data Prime = Prime class TestableProperty Prime Integer where is Prime n = {- ... -} Then you could add instances for Fibonacci or whatever you wanted. Cheers, Andrew Bromage