
aah .. Thanks a lot Brandon, you were right .. I was getting a Int and was
destructuring for tuple.. Thanks again
Sunil.
On Thu, Aug 11, 2011 at 5:33 PM, Brandon Allbery
On Thu, Aug 11, 2011 at 07:43, Sunil S Nandihalli < sunil.nandihalli@gmail.com> wrote:
Hello everybody, when I compile the file
https://github.com/sunilnandihalli/is2/blob/master/main.hs
I get main.hs:28:64: Could not deduce (Enum (a, t0)) arising from the arithmetic sequence `0 .. ' from the context (Integral a) bound by the type signature for plotAsString :: Integral a => [(a, a)] -> (a, a) -> String at main.hs:(26,1)-(38,41) Possible fix: add (Enum (a, t0)) to the context of the type signature for plotAsString :: Integral a => [(a, a)] -> (a, a) -> String or add an instance declaration for (Enum (a, t0)) In the second argument of `zip', namely `[0 .. ]' In the first argument of `M.fromList', namely `(zip locs [0 .. ])' In the expression: M.fromList (zip locs [0 .. ])
The weird error is because Haskell is defined to promote integer literals to instances of Integral, then applying further an instance of Enum; but the actual type it's expecting is a tuple because you're using (Just (id,_)) on line 34 as the result of (M.lookup). Were you perhaps expecting (M.lookup) to return a tuple of the key and value?
(Also, in light of your previous message, you'll find things compile more easily if you learn the correct types and behaviors of standard Haskell functions instead of making assumptions possibly based on the behavior of some other language.)
-- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms