How I Start: Haskell
21–30 of 61 posts
Re: How I Start: Haskell
#22Earlier quoted context omitted.
You can think of a lens as just a pointer (like in C). They're not exactly like a pointer...you can't get or modify the address that it points to. But you can get and modify the thing that it points to, which is primarily how you use pointers in C. But lenses can do things that pointers can't do. Namely, they can be composed. If you have a lens that points to a person's birth date dob :: Lens Person Date ...and a len…
[deleted]
Re: How I Start: Haskell
#23Earlier quoted context omitted.
Huh? In C, if you have a function from Person* to Date* and another function from Date* to Int*, you can compose them as well, and then use the resulting function to both get and set a person's birth year. The syntax is admittedly ugly, but I don't see any asymmetry between get and set.
Yes, I was talking about plain pointers (i.e. Person*), not functions of pointers. Sure, you can do both get and set, but the simple syntax is precisely what we're going for here. Without lenses that set line would have looked like this: person { dob = (dob person) { year = 2004 } } And this is just one level of nesting. Adding more levels gets really ugly. Also, lenses make it easy to do this kind of thing in a dyna…
Much like traditional getters and setters, lenses can offer more functionality though - for instance, an angle can be got and set in radians or degrees.
Re: How I Start: Haskell
#24After learning the basics of Haskell, having a book chock full of practical examples of things like handling CVS files, JSON, trees, graphs, machine learning, and Haskell's outstanding support for parallel computation--is a really helpful resource. The code is extremely well written; clear, concise, and readable. The author has also put the source code on GitHub for each chapter. [2]
Afterwards, to take your skills to the next level, check out Simon Marlow's Parallel and Concurrent Programming in Haskell [3]. Simon now works at Facebook, where they're using Haskell in production [4] [5].
[1] http://www.amazon.com/Haskell-Analysis-Cookbook-Nishant-Shuk...
[2] https://github.com/BinRoot/Haskell-Data-Analysis-Cookbook
[3] http://www.amazon.com/Parallel-Concurrent-Programming-Haskel...
[4] https://code.facebook.com/posts/302060973291128/open-sourcin...
[5] http://community.haskell.org/~simonmar/papers/haxl-icfp14.pd...
Re: How I Start: Haskell
#25Earlier quoted context omitted.
You can think of a lens as just a pointer (like in C). They're not exactly like a pointer...you can't get or modify the address that it points to. But you can get and modify the thing that it points to, which is primarily how you use pointers in C. But lenses can do things that pointers can't do. Namely, they can be composed. If you have a lens that points to a person's birth date dob :: Lens Person Date ...and a len…
Huh? In C, if you have a function from Person* to Date* and another function from Date* to Int*, you can compose them as well, and then use the resulting function to both get and set a person's birth year. The syntax is admittedly ugly, but I don't see any asymmetry between get and set.
A getter is simple:
x = s.foo.bar;
As is an impure setter: s.foo.bar = y;
But a non-mutating setter is a bit more work: Foo foo2 = s.foo;
foo2.bar = y;
S s2 = s;
s2.foo = foo2;Re: How I Start: Haskell
#26I think it is very hard to understand what a "beginner" needs - I now come across tutorials that finally make a certain concept "click", however the reason might not be that that specific tutorial was great, but rather that I have already hit my head on a bunch of other tutorials and practice that "prepared me"... Howver, Chris Allen actually working on teaching Haskell to a bunch of beginners is probably a great way of understanding what helps people to 'get it' sooner.
Re: How I Start: Haskell
#27What do you think about the lens library? I have been trying Haskell for a few weeks and this library feels strange. Also I don't really think I need the things it provides. But perhaps I just don't understand it.
Re: How I Start: Haskell
#28Re: How I Start: Haskell
#29Earlier quoted context omitted.
Yes, I was talking about plain pointers (i.e. Person*), not functions of pointers. Sure, you can do both get and set, but the simple syntax is precisely what we're going for here. Without lenses that set line would have looked like this: person { dob = (dob person) { year = 2004 } } And this is just one level of nesting. Adding more levels gets really ugly. Also, lenses make it easy to do this kind of thing in a dyna…
"Functions of pointers" do seem an in-place equivalent for simple lenses. Pointers themselves less so - you can't compose pointers, and they take zero (when getting) or one (when setting) argument whereas a lens takes one or two. Much like traditional getters and setters, lenses can offer more functionality though - for instance, an angle can be got and set in radians or degrees.
Re: How I Start: Haskell
#30Earlier quoted context omitted.
Not sure if you caught this, but that's what Chris Allen is linking to on this page http://new-www.haskell.org/downloads/osx Also, that app is great. Really nice that it comes with Cabal 1.20 .
Oh. IIRC, haskell.org used to point to a download of the Haskell Platform for OSX (definitely not to ghc.app at any rate), so when I saw that's where it pointed, I didn't even notice that they'd changed it.