Допис з розмови
Newbie question...
Path: g2news2.google.com!postnews.google.com!y7g2000yqa.googlegroups.com!not-for-mail
From: maxino <max.korob...@gmail.com>
Newsgroups: comp.lang.haskell
Subject: Newbie question...
Date: Sat, 13 Jun 2009 04:36:19 -0700 (PDT)
Organization: http://groups.google.com
Lines: 38
Message-ID: <d6c02a34-b116-44fa-85e3-50bfcd1a2c44@y7g2000yqa.googlegroups.com>
NNTP-Posting-Host: 151.66.129.102
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1244892979 8496 127.0.0.1 (13 Jun 2009 11:36:19 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Sat, 13 Jun 2009 11:36:19 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: y7g2000yqa.googlegroups.com; posting-host=151.66.129.102;
posting-account=bw0rjgoAAACV5G8KAxHRoqA-uNqvwwFa
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11)
Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11,gzip(gfe),gzip(gfe)
Hello,
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!)
I wrote this simple function, which purpose is to generate a list of
proper divisors of a number:
proper_divisors :: Int -> [Int]
proper_divisors n = [d | d <- [1 .. (floor . sqrt) n], mod n d == 0]
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:
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]
pd.hs:2:45:
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.
I can imagine that perhaps it has something to do with type conflict
but I can't go any further.
Would someone help?
Thanks,
max(ino)