[Haskell-cafe] Language extensions
Andrew Coppin
andrewcoppin at btinternet.com
Sun May 27 16:34:02 EDT 2007
Philippa Cowderoy wrote:
> On Sun, 27 May 2007, Andrew Coppin wrote:
>
>> Seriously. Haskell seems to attract weird and wonderful type system extensions
>> like a 4 Tesla magnet attracts iron nails... And most of these extensions seem
>> to serve no useful purpose, as far as I can determine.
>>
>
> Yeah, who needed type classes anyway?
>
> By which I mean that that's always been the way with haskell, and once you
> get what the extensions do they tend to in fact be highly natural -
> sometimes to the extent that people forget that they were ever an
> extension (constructor classes, anyone?).
>
Type classes are very easy to explain, and quite obviously useful. This,
presumably, is why they're in the language.
Almost all language extensions seem to be of the form "hey, let's see
what happens if we randomly change the type checking rules so that
*this* is permitted. What would that be like?" Usually it's an extreme
struggle to even wrap my brain around what the extension *is*, never
mind why this would be a useful thing...
(OOC, what's a constructor class?)
> For example, GADTs let you implement monads as interpreters by defining a
> datatype representing the abstract syntax tree that describes a
> computation - you can't get this to type without at a minimum existential
> types and for many monad operations you need the full power of GADTs to
> declare a corresponding constructor.
>
> I imagine it would never have occurred to you to try implementing a monad
> that way, right?
Indeed, I'm still figuring out why you would want to do something like
this. (Beyond "because you can".)
> Similarly, a lot of the developments with type classes
> and polymorphism have been about letting people write sufficiently general
> libraries - they're driven by the demands of code that people want to
> write, but often not so much by the demands of single, simple
> applications.
>
Well, sure enough I've run across useful things the type checker won't
let me do. (For example, you can't make Data.Set into a monad, since it
demands that all elements be in Ord, but a monad is required to accept
*all* possible element types.) It's pretty rare though.
OTOH, given that I've never developed any significant Haskell
applications or libraries, presumably everybody will simply conclude
that I don't know what the **** I'm talking about and simply ignore me...
> Incidentally, Haskell 98 isn't that small a language itself - there's
> plenty of sugar around.
>
Looks like a pretty simple language to me...
I once read about this language called "C++". It's supposed to be like
C, but better. And it is - if by "better" you mean, "exactly the same,
but a lot more complicated". By comparison, Haskell is a *tiny*
language. And yet, Haskell seems to allow you to express algorithms in a
handful of lines of code that would take entire libraries in C, C++,
Pascal, Java, Smalltalk, Tcl... and just about every other language I've
ever seen in my life!
Seriously. Haskell seems to be pretty much the apex of programming. I
can't imagine how you could make it any better. (Well, appart from a few
trivial things like changing some of the poor name choices in the
Prelude, and adding more libraries for "real world" stuff - but nothing
really deep or fundamental about the language itself.) And yet, people
keep adding more and more and more and more extensions. If it was that
somebody added one extension that really transformed the expressiveness
of the language, then fine. But on the contrary, it seems to be millions
of little bits and pieces being added. It just seems messy and complicated.
(I also spent some time using a language called "Eiffel". I read the
book too. Long derrivation of why the language is the way it is, why
each and every feature and detail is there, and how it forms a cohesive
whole. And boy, I was pretty convinced. And Eiffel is a pretty powerful
language. But... um... the type checking rules. OMG, *nobody* I know of
can actually understand that stuff! I mean, in general it just does
"what you want", but if it doesn't... good luck figuring it out!
Multiple inheritance, generics *and* specialisation in the same
language? Hmm... good luck sorting all that out in your code! In short:
a lovely language, but... almost too complicated to use.)
More information about the Haskell-Cafe
mailing list