[Haskell-cafe] Function Returning Type?

jrw4 josh.weissbock at gmail.com
Thu May 21 15:11:48 EDT 2009

I wrote this function as I am just learning Haskell.  What it does is it
generates a list of all rational numbers between 0 and 1, but I only have it
show the first 20.

rationals n :: Integer -> String
rationals n = (putStr . unlines . map show) (take n (nub [x % y | y <-
[1..], x <- [1..y], x < y]))

Now my problem is the type declaration, the first line.  I get the error
"Invalid type signature".  I googled this error and I was not able to find
out why it is giving it to me.  I have also tried:

rationals n :: Integer -> [Ratio]

but it gives me the same error.

Please someone point me in the right direction.  Thanks.
View this message in context: http://www.nabble.com/Function-Returning-Type--tp23658819p23658819.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list