[Haskell-cafe] Extending the idea of a general Num to other types?
dpiponi at gmail.com
Wed Sep 5 10:12:10 EDT 2007
On 9/5/07, Ketil Malde <ketil at ii.uib.no> wrote:
> On Wed, 2007-09-05 at 08:19 +0100, Simon Peyton-Jones wrote:
> Error message from GHCi:
> No instance for (Num String)
> arising from use of `+' at test/error.hs:2:8-17
> Possible fix: add an instance declaration for (Num String)
> In the expression: x + (show s)
> In the definition of `f': f x s = x + (show s)
> > your suggestion for the error message you'd like to have seen.
ghc --newbie-errors error.hs
. . .
. . .
Error message from GHCi:
You have tried to apply the operator '+' to 'x' and 'show s'
'show s' is a String.
I don't know how to apply '+' to a String.
May I suggest either:
(1) '+' is a method of type class Num. Tell me how to apply
'+' to a String by making String an instance of the class Num
(2) You didn't really mean '+'
In the expression: x + (show s)
In the definition of `f': f x s = x + (show s)
More information about the Haskell-Cafe