ghc fails to find the right instance
Joachim Breitner
mail at joachim-breitner.de
Tue Apr 1 13:12:49 EDT 2008
Hi,
Am Dienstag, den 01.04.2008, 17:53 +0100 schrieb Claus Reinke:
> 'Integer -> a' is more concrete, less general than 'i -> a',
> so it matches fewer types.
>
> '1 :: Num a => a' is more general than 'Integer'.
>
> | No instance for (More (t -> Integer))
> | arising from a use of `addd' at test.hs:19:17-22
>
> if nothing forces the parameter (!) to be Integer, the
> more concrete instance won't match. try type-annotating
> the numeric literals.
Indeed,
printI $ addd (1::Int) (2::Int) (3::Int)
does work.
But I can’t follow your explanation completely. When I use the variant
with Integer, ghc will not use the instance because (1::Num a => a) is
too general.
But why does it use the Integral i-Instance in the working variant?
(1::Num a=> a) is also more general than (1::Integral i => i), isn’t it?
Thanks,
Joachim
--
Joachim "nomeata" Breitner
mail: mail at joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
JID: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20080401/f963edeb/attachment-0001.bin
More information about the Glasgow-haskell-users
mailing list