Live data from Hacker News

Learn You a Haskell for Great Good

learnyouahaskell.com

41–50 of 67 posts

Re: Learn You a Haskell for Great Good

#41

Earlier quoted context omitted.

The designers of Haskell (and Haskell is one of the few successful design-by-committee languages,) were not doing things "your way" (where I assume you are a working programmer, with knowledge of some or even many traditional imperative languages.) They were PL researchers. Used to ML, Common Lisp, Ada, and, most importantly, Mathematics and Category and Type Theory. `data` introduces an algebraic data type , so it m…

+1 for your thoughtful reply. I've tinkered with other functional languages (Erlang, Scheme and Clojure), but Haskell is a stranger beast.

Scheme, Clojure, and most of Erlang are on an entirely different side of a fairly large chasm within the lay term "functional programming". Haskell, ML, Ada, Coq, and even some parts of Scala are just entirely different beasts. The underlying math is far more pronounced, leadi to new terminology and power.

Re: Learn You a Haskell for Great Good

#42

What I find confusing with Haskell is that the keywords don't seem to be consistent with the concepts they're meant to express. As someone new to Haskell I learnt that the `class` keyword doesn't express the object-oriented concept of class, but the concept of type class, which is different. Fair enough. What about declaring types then? That must be `type`, right? Nope, `type` is for creating type aliases. OK, surely…

The designers of Haskell (and Haskell is one of the few successful design-by-committee languages,) were not doing things "your way" (where I assume you are a working programmer, with knowledge of some or even many traditional imperative languages.) They were PL researchers. Used to ML, Common Lisp, Ada, and, most importantly, Mathematics and Category and Type Theory. `data` introduces an algebraic data type , so it m…

Huge mistake on their part, typical of math people. High level programming languages have to be as close as possible to human languages (English) not to some obscure mathematical concepts and notation that most people don't care about. Actually math notation itself (cryptic, inconsistent, ambiguous) is a horrible result of math people's communication handicap and ineptitude.

Re: Learn You a Haskell for Great Good

#43
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

Haskell can offer absolutely nothing Java can offer, while Haskell can't offer even 0.001% of what Java offers. You see, there's a very, very good reason why you won't see any (even remotely) serious and useful software made in Haskell and why you won't see it used by companies (which means that jobs are literally extremely close to zero) Haskell is nothing more than an exercise of constructing a language based on certain mathematical concepts, mainly abstract stuff like category theory. As a result it as cryptic, hard to understand and useless in practice as those theoretical concepts (though the theoretical stuff might serve as basis for some other stuff that might be useful - not so with functional languages and especially Haskell)

Re: Learn You a Haskell for Great Good

#44
post #42

Earlier quoted context omitted.

The designers of Haskell (and Haskell is one of the few successful design-by-committee languages,) were not doing things "your way" (where I assume you are a working programmer, with knowledge of some or even many traditional imperative languages.) They were PL researchers. Used to ML, Common Lisp, Ada, and, most importantly, Mathematics and Category and Type Theory. `data` introduces an algebraic data type , so it m…

Huge mistake on their part, typical of math people. High level programming languages have to be as close as possible to human languages (English) not to some obscure mathematical concepts and notation that most people don't care about. Actually math notation itself (cryptic, inconsistent, ambiguous) is a horrible result of math people's communication handicap and ineptitude.

> High level programming languages have to be as close as possible to human languages (English) not to some obscure mathematical concepts and notation that most people don't care about.

Haskell wasn't created for "most people". It's not some replacement for Python or Ruby, it was designed for formality.

Re: Learn You a Haskell for Great Good

#45
post #27

Earlier quoted context omitted.

From the perspective of "learn other languages to broaden your horizons": Haskell is worth learning because it has an expressive, strong, static type system. Most other languages do not have that property (Java's type system is static, give or take null, and strong, but not expressive, and Ruby's is strong but neither expressive nor static). The Haskell type system lets you have conversations with the compiler about…

Why makes you say that Ruby's type system is not expressive? I'm not exactly sure what that means. I've heard of a language being called expressive, but not a type system. By the way, does Haskell's type system have the "value restriction" that you run into in ML?

>I've heard of a language being called expressive, but not a type system.

Haskell's type system is practically a language itself. It has many powerful features that aid with expression:

    * sum, product and generalized algebraic data types (GADTs)
    * higher-kinded types
    * universally & existentially quantified types
    * scoped type variables
    * impredicative types
    * associated types
    * type families
    * kind polymorphism (a new feature)
    * type holes (also new)
>By the way, does Haskell's type system have the "value restriction" that you run into in ML?

I'm not sure what you mean by "value restriction". Haskell, like ML, is not a dependently typed programming language. For that you'll want to use something like Agda. As for why you'd want a language to not have dependent types? Well, having them introduces all kinds of considerations with regards to decidability and type inference.

Re: Learn You a Haskell for Great Good

#46
post #44
post #42

Earlier quoted context omitted.

Huge mistake on their part, typical of math people. High level programming languages have to be as close as possible to human languages (English) not to some obscure mathematical concepts and notation that most people don't care about. Actually math notation itself (cryptic, inconsistent, ambiguous) is a horrible result of math people's communication handicap and ineptitude.

> High level programming languages have to be as close as possible to human languages (English) not to some obscure mathematical concepts and notation that most people don't care about. Haskell wasn't created for "most people". It's not some replacement for Python or Ruby, it was designed for formality.

I don't know who it was created for, but I know lots of FP advocates (Haskellers included) whining that FP languages aren't used (almost at all) in the software industry.

Re: Learn You a Haskell for Great Good

#47
post #45
post #27

Earlier quoted context omitted.

Why makes you say that Ruby's type system is not expressive? I'm not exactly sure what that means. I've heard of a language being called expressive, but not a type system. By the way, does Haskell's type system have the "value restriction" that you run into in ML?

>I've heard of a language being called expressive, but not a type system. Haskell's type system is practically a language itself. It has many powerful features that aid with expression: * sum, product and generalized algebraic data types (GADTs) * higher-kinded types * universally & existentially quantified types * scoped type variables * impredicative types * associated types * type families * kind polymorphism (a n…

The value restriction is a rule that governs when type inference is allowed to polymorphically generalize a value declaration. In short, the value restriction says that generalization can only occur if the right-hand side of an expression is syntactically a value. [...] The value restriction prevents a ref cell (or an array) from holding values of different types, which would allow a value of one type to be cast to another and hence would break type safety

http://mlton.org/ValueRestriction

It can be annoying to work around this, because there are potentially ML programs that would be type-safe and would otherwise compile if they were not hindered by the value restriction.

I got my answer, though:

Ii is interesting that in ML, the presence of mutable ref cells and parametric polymorphism requires the whole language to be dominated by a "value restriction" [1] to ensure that the type system remains sound, whereas in Haskell, because IORef's can only be created (and used) in the IO monad, no such restriction is necessary.

http://www.haskell.org/pipermail/haskell-cafe/2007-July/0292...

Re: Learn You a Haskell for Great Good

#48
post #47
post #45

Earlier quoted context omitted.

>I've heard of a language being called expressive, but not a type system. Haskell's type system is practically a language itself. It has many powerful features that aid with expression: * sum, product and generalized algebraic data types (GADTs) * higher-kinded types * universally & existentially quantified types * scoped type variables * impredicative types * associated types * type families * kind polymorphism (a n…

The value restriction is a rule that governs when type inference is allowed to polymorphically generalize a value declaration. In short, the value restriction says that generalization can only occur if the right-hand side of an expression is syntactically a value. [...] The value restriction prevents a ref cell (or an array) from holding values of different types, which would allow a value of one type to be cast to a…

Ahh, thank you. This was very informative. I have no experience with ML. I thought you might have been referring to the mixing of values and types which occurs in dependently typed programming.

Re: Learn You a Haskell for Great Good

#49
post #41

Earlier quoted context omitted.

+1 for your thoughtful reply. I've tinkered with other functional languages (Erlang, Scheme and Clojure), but Haskell is a stranger beast.

Scheme, Clojure, and most of Erlang are on an entirely different side of a fairly large chasm within the lay term "functional programming". Haskell, ML, Ada, Coq, and even some parts of Scala are just entirely different beasts. The underlying math is far more pronounced, leadi to new terminology and power.

Ada?! It's purely imperative, type-safe language, no? At least that was the impression I got when it was forced on me at university.

Also, ML? I know OCaml a bit, but according to this comparison: http://adam.chlipala.net/mlcomp/ Standard ML has a "ref" type, which in effect allows mutable state. While it lack a bit of a syntactic sugar for this, OCaml's mutable record fields are implemented in terms of refs, so in the end SML isn't "more functional" in this than OCaml. Also, according to this answer (didn't check specs) SML has at least a WHILE loop: http://stackoverflow.com/questions/818324/loops-in-sml-nj which is typical to imperative languages. OCaml makes no attempt to outlaw side-effect (I suppose SML is similar), it allows them explicitly by introducing functions which return () (unit type), which are called purely for their side-effects. There is even List.iter function, which accepts a function executed for each element only for side-effects. And side-effects are not restricted in any way.

On the other hand Erlang has nothing like that - no loops, no mutable state in the language and it's side-effects are restricted to message passing.

While Scheme and Clojure, too, allow mutable state and non-pure functions, the default is immutable and pure for almost everything. In Racket the most used data-structure, a pair (and lists by extensions) is immutable by default and all the functions working on pairs and lists are pure. There is another type, "mutable pair", which is used to construct mutable lists, but I haven't seen it used yet.

Coq is not even turing complete.

Anyway, I much prefer talking about "functional style" than "functional programming"/"functional languages". If you think that one cannot use monads outside of Haskell - you're wrong. The same applies for lazy evaluation, which is available in many languages as extension or special syntactic construct in the language itself.

EDIT: I realized that parent probably thought of AGDA instead of ADA. And so I just installed it to check it out :)

Re: Learn You a Haskell for Great Good

#50
post #42

Earlier quoted context omitted.

The designers of Haskell (and Haskell is one of the few successful design-by-committee languages,) were not doing things "your way" (where I assume you are a working programmer, with knowledge of some or even many traditional imperative languages.) They were PL researchers. Used to ML, Common Lisp, Ada, and, most importantly, Mathematics and Category and Type Theory. `data` introduces an algebraic data type , so it m…

Huge mistake on their part, typical of math people. High level programming languages have to be as close as possible to human languages (English) not to some obscure mathematical concepts and notation that most people don't care about. Actually math notation itself (cryptic, inconsistent, ambiguous) is a horrible result of math people's communication handicap and ineptitude.

This depends on the point of view. I expect to find a rather high standards in Haskell programs than, say, Ruby, for exactly the same reasons you've mentioned and I think it's an awesome feature, quite the opposite to a mistake.

And yes, I am a "real programmer" and don't use Haskell at work myself (for the run-time performance reasons).

Post reply on HN