Live data from Hacker News

How I Start: Haskell

howistart.org

11–20 of 61 posts

Re: How I Start: Haskell

#11
post #2

What 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.

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

#12
post #5

Nice article. As of lately, I've been using a bundled GHC app for OSX development. Makes it quite easy to keep (and switch between) multiple Haskell environments. http://ghcformacosx.github.io/

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 .

Re: How I Start: Haskell

#13
post #2

What 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.

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.

Re: How I Start: Haskell

#14
post #5

Nice article. As of lately, I've been using a bundled GHC app for OSX development. Makes it quite easy to keep (and switch between) multiple Haskell environments. http://ghcformacosx.github.io/

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.

Re: How I Start: Haskell

#15
post #5

Nice article. As of lately, I've been using a bundled GHC app for OSX development. Makes it quite easy to keep (and switch between) multiple Haskell environments. http://ghcformacosx.github.io/

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 .

[deleted]

Re: How I Start: Haskell

#16
Awesome article! You really cover a lot, in a short but easily digestable write-up! It might be a little fast for complete beginners though :/...

I've come to be quite happy with my current VIM setup. I'm using,

* haskellmode for _t and _T (show and insert types, respectively) [0]

* ghc-mod for integration with neco-ghc and syntastic and for running ghc check [1]

* neco-ghc [2]

* neocomplete that uses neco-ghc, for completion suggestions [3]

* syntastic for hlint checking on save [4]

[0] https://github.com/lukerandall/haskellmode-vim

[1] https://github.com/eagletmt/ghcmod-vim

[2] https://github.com/eagletmt/neco-ghc

[3] https://github.com/Shougo/neocomplete.vim

[4] https://github.com/scrooloose/syntastic/

Re: How I Start: Haskell

#17
I like the How I Start serie.On the other hand,while I get that languages have their specificities,I'd like the same project to be implemented in all these languages,to be able to get a quick understanding about how working with these languages feels like.

You know like a TodoMVC ,but in form of tutorial around the same project,a webapp for instance,which would require as little library as possible.

Re: How I Start: Haskell

#18
When it comes to learning something like Haskell you are caught in dilemma between two ideas - Should you learn a functional programming language for fun and because it will make you a better thinker? or should you use your existing tools / stack to build something better than you have done before. What will be the better utilization of time?

While I was more oriented to former in the past, I have been inclining to latter, lately, for the reason, that what you have built remains more obvious to show and be proud of rather than knowledge of a programming language which might not be practical to build something good for variety of reasons (not soon to say the least).

Re: How I Start: Haskell

#19
post #17

I like the How I Start serie.On the other hand,while I get that languages have their specificities,I'd like the same project to be implemented in all these languages,to be able to get a quick understanding about how working with these languages feels like. You know like a TodoMVC ,but in form of tutorial around the same project,a webapp for instance,which would require as little library as possible.

You might like this post and repo on the iterated prisoner's dilemma then: http://jacquesfuentes.com/essays/2014/10/31/Iterated-Prisone...

Re: How I Start: Haskell

#20

Earlier 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.

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 dynamic and generalized way.
Post reply on HN