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

Peter Verswyvelen bf3 at telenet.be
Tue Sep 4 17:03:37 EDT 2007


Jonathan Cast wrote:
> I don't think this has been mentioned explicitly yet, but the
> discrepancy is purely for pedagogical purposes.
>
> In Gofer, list comprehensions (and list syntax, IIRC) /was/ generalized
> (to an arbitrary instance of MonadPlus).  But that means that any
> mistake in your syntax likely brings up a type error mentioning
> MonadPlus.  This confuses CS freshmen (who are easily confused anyway);
> thus, Haskell restricts list syntax to lists so the type errors are
> simpler.
>
> By contrast, most CS freshman have already used languages with multiple
> number types, so all you have to do is explain that type errors
> involving Num are Haskell's way of dealing with them.  So the syntax can
> be generalized to the type class in that case without confusing freshmen
> as much.
>
> jcc
>
>   
Well, that is a very good reason, but for newbies (or should I say, for 
me ;-) ), most error messages are very confusing anyway! An since 
Haskell is really an advanced language, why not go all the way? It feels 
to me that for learning FP to newbies, a small subset of Haskell would 
be more suitable to get started, so really easy error messages can be 
given (Helium does that already?) Otherwise you would need a very clever 
compiler/editor machine learning system, that looks at how a class of 
users fixes a certain error, so the compiler can adapt its error message 
the next time a similar pattern occurs (which is science fiction right 
now I think...)

Now, these complex error messages are not just for Haskell; when I did 
complicated C++ template programming, the error message sometimes became 
as long as a full page when printed, and it took me more time to 
decipher the error than to fix the code ;-)

PS: Gofer, is that an existing language? As far as some googling can 
tell me, it's dead?



More information about the Haskell-Cafe mailing list