[Haskell-cafe] Extending the idea of a general Num to other types?

Ketil Malde ketil at ii.uib.no
Wed Sep 5 06:47:06 EDT 2007


On Wed, 2007-09-05 at 09:56 +0100, Simon Peyton-Jones wrote:

> Is your suggestion specific to String? 

No.

> then I really might have intended to use Complex as a Num type

IME this is much rarer, and I think if a newbie is told that Complex is
not (but needs to be) and instance of Num, it is relatively easy to find
the relevant information (Looking up 'instance' and/or 'class' in the
index of any Haskell text book should do the trick)

> | rephrase to something like "String is not an instance of Num"?  For a
> | newbie, it may not be clear that Num is the class and String is the
> | type.
> 
> Good point.  Not so easy for multi-parameter type classes! E.g. No instance for (Bar String Int).  So we could have
> 
>         String is not an instance of class Foo  -- single param
>         No instance for (Bar String Int)                -- multi-param

If you quote things, you can also consider:

 	   'String Int' is not an instance of class 'Bar'.

Downside is that 'String Int' by itself may be confusingly unhaskellish.

-k




More information about the Haskell-Cafe mailing list