[Haskell-beginners] compilation error..

Brandon Allbery allbery.b at gmail.com
Thu Aug 11 14:03:06 CEST 2011


On Thu, Aug 11, 2011 at 07:43, Sunil S Nandihalli <
sunil.nandihalli at 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 at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110811/f52ec159/attachment-0001.htm>


More information about the Beginners mailing list