| |
comp.lang.haskell |
Hello, I wrote this simple function, which purpose is to generate a list of proper_divisors :: Int -> [Int] Saved in a file, when I :load it from GHCI 6.8.2 this is what I get: [1 of 1] Compiling Main ( pd.hs, interpreted ) pd.hs:2:37: pd.hs:2:45: I can imagine that perhaps it has something to do with type conflict Thanks,
I've been studying this fascinating language for a few days so I am
pretty new to all this (especially the error messages from the
interpreter!)
proper divisors of a number:
proper_divisors n = [d | d <- [1 .. (floor . sqrt) n], mod n d == 0]
No instance for (RealFrac Int)
arising from a use of `floor' at pd.hs:2:37-41
Possible fix: add an instance declaration for (RealFrac Int)
In the first argument of `(.)', namely `floor'
In the expression: (floor . sqrt) n
In a list comprehension: d <- [1 .. (floor . sqrt) n]
No instance for (Floating Int)
arising from a use of `sqrt' at pd.hs:2:45-48
Possible fix: add an instance declaration for (Floating Int)
In the second argument of `(.)', namely `sqrt'
In the expression: (floor . sqrt) n
In a list comprehension: d <- [1 .. (floor . sqrt) n]
Failed, modules loaded: none.
but I can't go any further.
Would someone help?
max(ino)