[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request?for?feedback

ChrisK haskell at list.mightyreason.com
Sun Jul 29 07:28:52 EDT 2007

And the readability is destroyed because you cannot do any type inference in
your head.

If you see

 Matrix m = ....;
 Matrix x = m * y;

Then you know very little about the possible types of y since can only conclude

Matrix can be multiplied by one or more types 'sometype' becuase it has one or
more (operator *(sometype x)) methods defined.

And 'y' is either one of these sometypes's or _any_ other class that matches
_any_ single argument constructor of any of those sometypes (except for those
constructors are marked 'explicit').

Now you need to read the header definitions for Matrix and the headers for every
type that can multiply Matrix.  Only after that can you say what set of types
the 'y' might be.

Now do this for every argument of every method call and every operator in the code.

This is part of the reason that shops that use C++ often have a long list of
features that must never be used.  This is part of the reason that new people
who use C++ are notorious because they produce code that uses too many of C++
features.  Code written in arbitrary C++ is unreadable.

Aaron Denney wrote:
> On 2007-07-27, David Roundy <droundy at darcs.net> wrote:
>> The solution is to add explicit to the constructor for all single-argument
>> constructors (except perhaps occasionally when you actually want explicit
>> construction of objects).
>> The reasoning behind this, of course, is to allow nice interactions of
>> home-made classes such as complex numbers, or string classes (which you
>> might want to be automatically constructed from string constants).
> I'd have thought that adding an "implicit" keyword would make more
> sense, and only do conversions then.  But I forget, C++.

More information about the Haskell-Cafe mailing list