[Haskell-beginners] Idiomatic way to avoid type class instance definitions for Int and Integer separately

Ozgur Akgun ozgurakgun at gmail.com
Tue Mar 15 20:40:40 CET 2011

On 15 March 2011 19:21, Amitava Shee <amitava.shee at gmail.com> wrote:

> *Kind> yesno 10
> <interactive>:1:6:
>     Ambiguous type variable `t' in the constraints:
>       `Num t' arising from the literal `10' at <interactive>:1:6-7
>       `Yesno t' arising from a use of `yesno' at <interactive>:1:0-7
>     Probable fix: add a type signature that fixes these type variable(s)

The literal 10 has type (Num n => n), however, due to ghci's defaulting
rules, it defaults to Integer, hence the error you've experienced.

Try yesno (10 :: Int), and check section 2.4.5 of [1].


Hope this helps,

Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110315/8e501d1b/attachment.htm>

More information about the Beginners mailing list