
Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions. And there are various things you can do in Haskell which *require* some pretty serious type system hackery. And yet, none of this happens in any other programming language I've met. Take Java for example. In Java, a "type" is just an identifier. It has no further structure than that. It does have the added semantics that it refers to that class *or any subclass*, but that's about it. Even taking an extreme example like Eiffel [which supports generics], complex types are extremely rare. And yet they commonly pop up in Haskell. Can anybody put their finger on precisely why that is? Is it because Haskell is used by more PhDs? Is it because Haskell actually allows you to implement constructs that are impossible in other languages? Is it because Haskell really provides greater type safety? Is it something else? Not trying to suggest that either system is "superior", I'm just curios as to the origin of the difference...

On Fri, Mar 14, 2008 at 2:50 PM, Andrew Coppin
Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions. And there are various things you can do in Haskell which *require* some pretty serious type system hackery.
Well, there wouldn't be much point to a type system extension if you could do just as well without it.
And yet they commonly pop up in Haskell. Can anybody put their finger on precisely why that is?
It's because Haskell is, among other things, a research language. Part
of its stated purpose is providing a basis for experimenting with type
systems and implementation strategies and so forth.
When Haskell 98 was written, higher-ranked polymorphism wasn't
considered practical, and no one had invented multi-parameter type
classes yet. Even type classes started out as an experiment, and then
they were extended to constructor classes (e.g., classes like Monad
where the parameter is a type constructor, not a ground type).
Eventually, the most successful extensions will be rolled into the
next Haskell standard.
The same thing happens in Java. Generics (what we call type
constructors) were available in various extended Javas before being
added to the main standard. The Haskell process is just a lot slower
because we're doing things very few have done before.
--
Dave Menendez

On Fri, Mar 14, 2008 at 11:50 AM, Andrew Coppin
Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions...And yet, none of this happens in any other programming language I've met.
Have you ever programmed in C++? Many of the exotic things that can be done in the Haskell type system can also be carried out in the C++ type system - ranging from factoring integers at compile time to implementing highly optimised array and matrix DSLs. The difference between C++ and Haskell is that in C++ these techniques are highly ad hoc. In the Haskell world people are a lot more conservative and so only allow type system shenanigans if they are supported by some theory that allows us to reason nicely about them. As a side effect, each type system extension is relatively small and controlled. So when you see lots of Haskell type system extensions it looks like a big complicated system, but that's just an illusion that results from it being broken down into reasonable pieces. Read some of the source code for the Boost C++ template libraries (especially the template metaprogramming library) to see how complex the C++ type system really is. -- Dan

dpiponi:
On Fri, Mar 14, 2008 at 11:50 AM, Andrew Coppin
wrote: Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions...And yet, none of this happens in any other programming language I've met.
Have you ever programmed in C++? Many of the exotic things that can be done in the Haskell type system can also be carried out in the C++ type system - ranging from factoring integers at compile time to implementing highly optimised array and matrix DSLs. The difference between C++ and Haskell is that in C++ these techniques are highly ad hoc. In the Haskell world people are a lot more conservative and so only allow type system shenanigans if they are supported by some theory that allows us to reason nicely about them. As a side effect, each type system extension is relatively small and controlled. So when you see lots of Haskell type system extensions it looks like a big complicated system, but that's just an illusion that results from it being broken down into reasonable pieces. Read some of the source code for the Boost C++ template libraries (especially the template metaprogramming library) to see how complex the C++ type system really is.
As Manuel says, in C++ type level programming was an accident, in Haskell, it was by design.

Don Stewart wrote:
As Manuel says, in C++ type level programming was an accident, in Haskell, it was by design.
Was it, really? I was laways under teh impression that Oleg-style type system tricks were not in the least anticipated back when Haskell acquired type classes... Cheers Ben

No, Haskell wasn't designed with type level programming in mind. In fact it
took a few years before any serious type level programming was done. And lo
and behold, the type level has an untyped logic language.
-- Lennart
On Fri, Mar 14, 2008 at 9:41 PM, Ben Franksen
Don Stewart wrote:
As Manuel says, in C++ type level programming was an accident, in Haskell, it was by design.
Was it, really? I was laways under teh impression that Oleg-style type system tricks were not in the least anticipated back when Haskell acquired type classes...
Cheers Ben
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Yeah, I should clarify, this quote came up in relation to ATs, which are designed speifically to make type programming easier (unlike MPTCs and FDs, where it was an Olegian accident) lennart:
No, Haskell wasn't designed with type level programming in mind. In fact it took a few years before any serious type level programming was done. And lo and behold, the type level has an untyped logic language.
-- Lennart
On Fri, Mar 14, 2008 at 9:41 PM, Ben Franksen <[1]ben.franksen@online.de> wrote:
Don Stewart wrote: > As Manuel says, in C++ type level programming was an accident, in > Haskell, it was by design.
Was it, really? I was laways under teh impression that Oleg-style type system tricks were not in the least anticipated back when Haskell acquired type classes...
Cheers Ben _______________________________________________ Haskell-Cafe mailing list [2]Haskell-Cafe@haskell.org [3]http://www.haskell.org/mailman/listinfo/haskell-cafe
References
Visible links 1. mailto:ben.franksen@online.de 2. mailto:Haskell-Cafe@haskell.org 3. http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Andrew Coppin wrote:
Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions. And there are various things you can do in Haskell which *require* some pretty serious type system hackery.
And yet, none of this happens in any other programming language I've met. Take Java for example. In Java, a "type" is just an identifier. It has no further structure than that. It does have the added semantics that it refers to that class *or any subclass*, but that's about it. Even taking an extreme example like Eiffel [which supports generics], complex types are extremely rare.
And yet they commonly pop up in Haskell. Can anybody put their finger on precisely why that is?
I think this is at least partly because Haskell takes being a (typed) functional language very serious. With OO languages, such as Java or Eiffel, you can swipe a lot of the complexity under the stateful object carpet. Functional programs explicitly operate on values, however complex their types may be... and thus themselves become values with even more complex types... I found this paper http://www.eecs.usma.edu/webs/people/okasaki/pubs.html#jfp98 quite illuminating (it uses SML, not Haskell, which rather confirms my point). Cheers Ben

Am Freitag, 14. März 2008 19:50 schrieb Andrew Coppin:
[…]
Is it because Haskell is used by more PhDs? Is it because Haskell actually allows you to implement constructs that are impossible in other languages? Is it because Haskell really provides greater type safety? Is it something else?
Haskell’s type system gives you greater type safety, i.e., it allows to statically check certain properties which cannot be statically checked in other languages. It also improves code reuse in certain cases. For example, the Control.Monad module works for all monads (lists, I/O actions, etc.) which is only possible because of constructor classes, at least, if you don’t want to introduce dynamic typing.
[…]
Best wishes, Wolfgang

Hi Andrew, Andrew Coppin wrote:
Haskell has an expressive and powerful type system - which I love. It also has a seemingly endless list of weird and obscure type system extensions. And there are various things you can do in Haskell which *require* some pretty serious type system hackery.
And yet, none of this happens in any other programming language I've met. Take Java for example. In Java, a "type" is just an identifier. It has no further structure than that. It does have the added semantics that it refers to that class *or any subclass*, but that's about it. Even taking an extreme example like Eiffel [which supports generics], complex types are extremely rare.
There are a lot of Java extensions in various directions (Multimethods, Mixins, Virtual Classes, Aspects, Effect Typing). Some extensions have been included into the "official" Java Language (Anonymous Classes, Generics). Other extensions have lead to the creation of new languages different from, but related to Java (Scala). A lot of research teams, both academic and industrial, are working on new extensions of the Java Language. Such extensions may come as libraries, preprocessors or compilers, they may reuse, extend or substitute the run time system. From my limited view, the Java research community seems to be bigger then the Haskell research community. But I may be wrong here, and the meaning of a "big community" isn't clear at all, so that's not the point. Clearly, Haskell feels like a research language, and Haskell hacking is like pushing the border into unexplored territory, while Java feels like a lot of boilerplate without actual content, and Java development is like taking care of paperwork. Why is this the case? I see four reasons all working together: First, Java is designed for the software industry, while Haskell "avoids success at all cost". This means that we have 90% research people working with Haskell, and 0.01% research people working with Java, *even if there are more Java researchers as Haskell researchers*. It's the absence of non-researchers which makes Haskell a research language, not the abundance of researchers. Second, Java extensions tend to be incompatible with each other, since they typically consist of an modified compiler, while Haskell extensions tend to get integrated into GHC or lost forever. With GHC as de-facto standard compiler, we have a number of extensions available for every productive Haskell system. Third, the theoretical base of pure functional languages is relatively clear and easy to understand, while the theoretical base of imperative object-oriented languages is still widely unexplored and hard to grasp. This means that formal, scientific papers about Haskell are more likely to be user-understandable then formal, scientific papers about Java. Ever seen one of the formal calculi proposed as semantic core of the Java language? Fourth, Haskell is just better. (Had to include this one to avoid being victim to a flame war). But hey, it is my personal opinion too. Tillmann

G'day all.
Quoting Andrew Coppin
And yet they commonly pop up in Haskell. Can anybody put their finger on precisely why that is?
One of the reasons why advanced type hackery shows up a lot in Haskell is that Haskell has never taken the easy way out. When confronted with an issue that doesn't seem to fit with purity, Haskell's answer has always been to apply more research, raid more category theory or generally think hard about the problem and come up with a clean solution, rather than sell out to impurity. And almost always, the theoretically clean solution has opened up new uses for types that were not previously considered. Cheers, Andrew Bromage
participants (9)
-
ajb@spamcop.net
-
Andrew Coppin
-
Ben Franksen
-
Dan Piponi
-
David Menendez
-
Don Stewart
-
Lennart Augustsson
-
Tillmann Rendel
-
Wolfgang Jeltsch