Dan Piponi wrote: > On 9/5/07, Ketil Malde <[EMAIL PROTECTED]> wrote: >> On Wed, 2007-09-05 at 08:19 +0100, Simon Peyton-Jones wrote: >> Error message from GHCi: >> test/error.hs:2:8: >> 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: > test/error.hs:2:8: > 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)
Splendid! And w/o the --newbie-errors drop the 'Possible fix:...'. In my experience, it is either unnecessary (because it is obvious which instance is missing) or (more often) misleading. As to the first line of the message 'No instance for (Num String)': I dislike the proposed 'String is not an instance of Num' for reasons already mentioned by others (multi parameter classes). I suggest to make it even shorter by directly quoting the missing syntax, i.e. 'Missing (instance Num String)'. Cheers Ben _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe