Live data from Hacker News

Haskell tutorial for C programmers

haskell.org

31–40 of 56 posts

Re: Haskell tutorial for C programmers

#31
post #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.

Of course you don't have to believe me, but I'm genuinely puzzled why apparently most tutorials spend such an disproportionate amount on these more theoretical explanations.

One explanation of course might be that a lot of the crowd looking into this are coming from a computer-science background where they are more enthusiastic about the basics. And to them, the fact that (after a lot of coding chores, writing up libraries) it eventually will make sql-injection harder, or parallel handling of web-service faster will be seen just as a logical consequence not worth making a lot of fuzz about.

But for attracting a larger community one has to make the gains for the average programmer more visible.

Re: Haskell tutorial for C programmers

#32
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…

There are helpful tutorials for all of the things you've mentioned. I think that part of the problem is that people don't go looking for these things. If you want to write a backend for a web-app, there are three frameworks that are all mature: Snap, Yesod, and Happstack. There are tutorials, books, and documentation for all of these frameworks. If you want to do 3D graphics, there are some pretty straightforward bindings to OpenGL, again with tutorials and documentation. If you want to talk to a USB peripheral, there's the usb-safe. For databases, there are a myriad of options and tutorials for those.

The tutorials are all out there, but one is going to have to have a pretty solid grasp on Haskell before one can understand them, just like with any other language.

Re: Haskell tutorial for C programmers

#33
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…

There are helpful tutorials for all of the things you've mentioned. I think that part of the problem is that people don't go looking for these things. If you want to write a backend for a web-app, there are three frameworks that are all mature: Snap, Yesod, and Happstack. There are tutorials, books, and documentation for all of these frameworks. If you want to do 3D graphics, there are some pretty straightforward bin…

> For databases, there are a myriad of options and tutorials for those

Where? The only half appealing type safe query DSL that I've found for Haskell is Esqueleto, and that features a blank github readme[1] o_O

[1] https://github.com/meteficha/esqueleto

Re: Haskell tutorial for C programmers

#34
post #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/

Agreed compared to RWH, LYAH was next to useless for me. RWH could use a refresh though (published in 2008), hopefully a 2nd edition will be in the works at some point.

Re: Haskell tutorial for C programmers

#35

Earlier quoted context omitted.

How do you express the Ordinality constraint in C++?

Multiple inheritance from a purely virtual class. In Java, they're called interfaces; Comparable is the analogue to Ord. The advantage that Haskell's typeclasses have over either Java or C++ is that the types aren't closed. I can define a new typeclass and tell the compiler that a type you defined is a member of that class at any point. In Java, if you don't define that your type is Comparable, there's nothing that I…

The advantage you mention is one of many (over OOP interfaces), I'll repeat it as (A).

(A) Ability to instantiate old types with new classes

(B) Conditional instantiation: "Maybe a" is an instance of "Show" iff "a" is an instance of "Show"

(C) Can do return-type polymorphism, or polymorphism on any part of the signature

(D) Objects do not need to pay for the interface vtable pointer. Large array of some type-class instance can be much smaller than an array of an OOP interface subclass.

(E) When comparing two Ord instance values, there is only one Ord dictionary, rather than 2 to choose from. No false dilemma.

Re: Haskell tutorial for C programmers

#36
post #23

Earlier quoted context omitted.

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…

You can define a mutable std::sort like function in Haskell:

  mutableSort :: (MArray arr elem m, Ord elem, Ix ix) => arr ix elem -> m ()
This can work on mutable arrays in the IO, ST, or other mutable-array supporting monads. It also has a generalized index type (though newer array libraries threw that part away, so it's not considered a good idea anymore).

Re: Haskell tutorial for C programmers

#37

This makes for very good reading indeed. I started reading it and just now realised that I'd spent the last couple of hours on it. It's written well, approachable and very pragmatic. I spent a short while on Haskell a few years back and stopped after 3 or 4 chapters of Learn You A Haskell due to time constraints. I think I'm going to make this my evening reading and finally pick up the language. Thanks for posting th…

That's great!

Don't expect to "pick up the language" in an evening :)

Haskell takes a few evenings at the very least!

Re: Haskell tutorial for C programmers

#38

Earlier quoted context omitted.

There are helpful tutorials for all of the things you've mentioned. I think that part of the problem is that people don't go looking for these things. If you want to write a backend for a web-app, there are three frameworks that are all mature: Snap, Yesod, and Happstack. There are tutorials, books, and documentation for all of these frameworks. If you want to do 3D graphics, there are some pretty straightforward bin…

> For databases, there are a myriad of options and tutorials for those Where? The only half appealing type safe query DSL that I've found for Haskell is Esqueleto, and that features a blank github readme[1] o_O [1] https://github.com/meteficha/esqueleto

Groundhog is pretty awesome[1]. Persistent also works, but it does some wonky stuff on SQL databases. Acid-state is really neat! Of course, there's stuff like postgresql-simple, but that's not very type safe.

[1]https://www.fpcomplete.com/school/to-infinity-and-beyond/pic...

Edit: Also, esqueleto has a pretty okay looking hackage page[2], but I've never used esqueleto, so I don't really know.

[2]http://hackage.haskell.org/package/esqueleto

Re: Haskell tutorial for C programmers

#39
@kissthblade: Your comment (dead) below is very sad. You've been hell-banned for more than a year and a half. It doesn't just seem like nobody is seeing your comments, it's true.

For those without showdead on:

"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?"

Looking through your comments, I don't see an obvious reason you were hellbanned.

Re: Haskell tutorial for C programmers

#40
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…

If all you've done is looked at tutorials and glimpsed at a book, I think it's very unlikely that you actually get the advantages or really understand any of the patterns like Monads. Write some code. The only way that you'll actually grok the language and get any of the benefits from learning it is if you actually write code in it.
Post reply on HN