Live data from Hacker News

Haskell tutorial for C programmers

haskell.org

21–30 of 56 posts

Re: Haskell tutorial for C programmers

#22
post #16

Chris Allen / coolsunglasses maintains a great gist of a learning path for haskell: https://gist.github.com/bitemyapp/8739525 The current intro course looks really nice: http://www.seas.upenn.edu/~cis194/lectures.html

This gist was what helped me finally learn Haskell, after failing on my first two tries.

Re: Haskell tutorial for C programmers

#23
post #4

>What this means is that existing sort functions such as mergeSort and quickSort would need to be rewritten to sort values of the new type. In constrast, here is the type of mergeSort in Haskell mergeSort :: Ord a => [a] -> [a] Er, you could define mergesort using templates in c++ and it would work pretty much the same.

Yeah, I don't get why that's superior to something like std::sort : http://en.cppreference.com/w/cpp/algorithm/sort (or a similar approach however you like).

The difference is entirely in the types. A sort function in Haskell has type:

    Ord a => [a] -> [a]
You therefore know that the implementation of the function can only make use of functions provided by Ord, and manipulation of the list structure. The function cannot inspect the values in the list except via comparison. This is an incredibly powerful guarantee. It's also really useful when you go to implement the function because this level of parametricity guarantees that there are only so many valid implementations and only a couple of them are even close to correct.

Re: Haskell tutorial for C programmers

#24
Was hopeful but almost immediately this article also devolved into introducing the fibonacci function. This is almost as bad as examples of "aspect oriented programming" in java 10 years ago when every example involved inserting logging aspects to your code...

Just write a simple tutorial about a real world example, nowadays usually having something to do with the web, and especially point out how it's better than doing the same thing in ruby, php or even gasp java! We'll learn ourselves how you define lists and how magical they are in haskell...

And people who write compilers and parses all day long probably won't have a problem with the way haskell looks.

Re: Haskell tutorial for C programmers

#25
post #23

Earlier quoted context omitted.

Yeah, I don't get why that's superior to something like std::sort : http://en.cppreference.com/w/cpp/algorithm/sort (or a similar approach however you like).

The difference is entirely in the types. A sort function in Haskell has type: Ord a => [a] -> [a] You therefore know that the implementation of the function can only make use of functions provided by Ord, and manipulation of the list structure. The function cannot inspect the values in the list except via comparison. This is an incredibly powerful guarantee. It's also really useful when you go to implement the functi…

All true. On the other hand, std::sort in C++ works on RandomAccessIterator, which means that it can sort vectors, C arrays, deques, strings, your custom container type, etc. The Haskell implementation can only sort lists. Furthermore, the Haskell type signature fails to express that the input and output have the same size. But std::sort necessarily preserves its size, because you pass it a range, and a range cannot access its underlying container to change its size (a limitation leading to bizarre APIs like std::unique).

Re: Haskell tutorial for C programmers

#27
Oh my, another tutorial. I've looked at many of them, trying to learn something from the Haskell way. And I think I get the fundamental advantages of the type systems, the lazy evaluation enabled by the languages purity, I think I can somehow make sense of the Monads even. I have the "learn you a haskell for good" on a pile of books where I have a glimpse from time to time.

Most tutorials and books are very enthusiastic in how they can detect that I try to zip two lists of different cardinality during compile time, or how they can lazily calculate the Fibbonacci sequence. And that's really nice and fine...

But nevertheless, I use C all of the time, and I learnt how to make use of a myriad of libraries, combine connections to a SQL database, embedd a webserver, talk to USB,... Must have been 20 years ago that I wrote code to calculate the Fibbonacci sequence.

So, where are tutorials that showcase all the wonderful "high-level" functionality that has already been written for Haskell, so that I, after reading through the text, will be thrilled how much work I can avoid, or how much security I can gain when switching over from my "almost bare-matel not-much-more-like-an-assembler C" to Haskell? Not in calculating the Fibunacci sequency, but in writing a backend for my web-app, or talk to a USB peripheral? Do 3D graphics?...

Re: Haskell tutorial for C programmers

#28
post #27

Oh my, another tutorial. I've looked at many of them, trying to learn something from the Haskell way. And I think I get the fundamental advantages of the type systems, the lazy evaluation enabled by the languages purity, I think I can somehow make sense of the Monads even. I have the "learn you a haskell for good" on a pile of books where I have a glimpse from time to time. Most tutorials and books are very enthusias…

These kinds of questions feels like they're treading the fine line between being honest inquiries, and dares.

Re: Haskell tutorial for C programmers

#29
post #27

Oh my, another tutorial. I've looked at many of them, trying to learn something from the Haskell way. And I think I get the fundamental advantages of the type systems, the lazy evaluation enabled by the languages purity, I think I can somehow make sense of the Monads even. I have the "learn you a haskell for good" on a pile of books where I have a glimpse from time to time. Most tutorials and books are very enthusias…

Why isn't there ever any discussion in hacker news (yes some great comments but really no general discussion other than that). I posted about the same comment as the parent hours ago. I don't know if anybody even sees my posts, never gotten a response, and my "karma" or something has always been 15. And posting and reading the forum is very slow. What gives? Sorry about the off topic rant, it's just hard to feel part of the discussion here...

Re: Haskell tutorial for C programmers

#30
post #27

Oh my, another tutorial. I've looked at many of them, trying to learn something from the Haskell way. And I think I get the fundamental advantages of the type systems, the lazy evaluation enabled by the languages purity, I think I can somehow make sense of the Monads even. I have the "learn you a haskell for good" on a pile of books where I have a glimpse from time to time. Most tutorials and books are very enthusias…

I know your comment is more targeted at tutorials, but in case you don't know the book Real World Haskell explores, as the name implies, some real world problems: http://book.realworldhaskell.org/read/
Post reply on HN