Live data from Hacker News

What I Wish I Knew When Learning Haskell

dev.stephendiehl.com

11–20 of 24 posts

Re: What I Wish I Knew When Learning Haskell

#11
post #4

I have to say that this line irks me: "Any preconceptions one might have for the word 'return' should be discarded, it has an entirely different meaning." This sentence literally does nothing to help me even prepare to understand what is about to be explained. At the least, give a small example of what preconceptions should go. "All of them" implies that someone did a crap job of naming this thing. Edit: Apologies to…

It should probably have been called 'unit' or 'pure' as it was in Wadler's original Monad/Haskell papers.

I don't know who decided that confusing legions of future programmers with the name 'return'; using do notation to carry out sequential programming in the IO Monad made calling it return too tempting I guess, even though it's a misleading name for all the other Monads.

Edit: A quick spelunk through the Haskell literature suggests that John Launchbury is probably to blame. His paper "Lazy Imperative Programming" appears to introduce both return and do-notation.

Re: What I Wish I Knew When Learning Haskell

#12
post #5

Personally, I like to follow the mantra cabal is not a package manager . Because whenever I treat it like one, I get messed up in a bad way. I buy in to this argument[1] as to why it isn't. [1]: http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-...

That argument seems more like (ignoring the naming issues of cabal vs cabal-install), that cabal is a terrible package manager, but still (to me) seems to bare all the major features of a package manager.

Re: What I Wish I Knew When Learning Haskell

#13
post #10
post #4

I have to say that this line irks me: "Any preconceptions one might have for the word 'return' should be discarded, it has an entirely different meaning." This sentence literally does nothing to help me even prepare to understand what is about to be explained. At the least, give a small example of what preconceptions should go. "All of them" implies that someone did a crap job of naming this thing. Edit: Apologies to…

That sentence could have more information, but I think it still serves a worthwhile purpose. It's basically saying that, for now, think of "return" as a new thing you've never seen before and don't worry about correlating it with what you already have seen in other languages. In Haskell, 'return' creates a monadic value. Here are some excerpts from Learn You A Haskell for Great Good: > If you've done imperative langu…

I should have been clearer, myself. My problem is not that I may have to drop preconceptions from other programming languages. My beef is that the word has meaning outside of programming. And is part of the reason it was chosen in said programming languages.

Imagine if it was called "name". And we had to "throw out all preconceptions you have with the word 'name.'"

Re: What I Wish I Knew When Learning Haskell

#14
post #5

Personally, I like to follow the mantra cabal is not a package manager . Because whenever I treat it like one, I get messed up in a bad way. I buy in to this argument[1] as to why it isn't. [1]: http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-...

That argument seems more like (ignoring the naming issues of cabal vs cabal-install), that cabal is a terrible package manager, but still (to me) seems to bare all the major features of a package manager.

The fact that it forwards package registration to the underlying ghc-pkg system, has very poor/nearly nonexistent record keeping, and can't perform uninstall operations are kinda crucial. I've never heard of a packager manager that can't uninstall.

If you present it as a package manager, even if it's a bad one, then you also telegraph a certain amount of implied functionality, and in turn the user has a certain level of confidence that the system is smart enough to do its best to prevent you from damaging your package ecosystem (not a guarantee, but at least an effort); cabal and by extension cabal-install doesn't provide this at all. It simply provides a way to install packages and makes a best effort at meeting the build goals required for individual commands to succeed in a vacuum.

I hesitate to call that a package "manager". It's just a very mediocre package installer.

Re: What I Wish I Knew When Learning Haskell

#15
post #9
post #4

I have to say that this line irks me: "Any preconceptions one might have for the word 'return' should be discarded, it has an entirely different meaning." This sentence literally does nothing to help me even prepare to understand what is about to be explained. At the least, give a small example of what preconceptions should go. "All of them" implies that someone did a crap job of naming this thing. Edit: Apologies to…

All of them. return "lifts" a "plain" value so that it becomes a "monadic" thing. As far as I can see, this has nothing at all to do with returning a value from a function.

Right, but I have preconceptions of the word "return" that have nothing to do with programming. I'm fine if you want to think of it as "returning to the monadic environment."

That is, in English, you can return to things just as easily as you can return from them. I may have to forget some of the things that are common in other environments. But to use a word that has meaning outside of programming and to decry that you have to lose all preconceptions of that word, implies heavily that it was named poorly.

Re: What I Wish I Knew When Learning Haskell

#16
post #13
post #10

Earlier quoted context omitted.

That sentence could have more information, but I think it still serves a worthwhile purpose. It's basically saying that, for now, think of "return" as a new thing you've never seen before and don't worry about correlating it with what you already have seen in other languages. In Haskell, 'return' creates a monadic value. Here are some excerpts from Learn You A Haskell for Great Good: > If you've done imperative langu…

I should have been clearer, myself. My problem is not that I may have to drop preconceptions from other programming languages. My beef is that the word has meaning outside of programming. And is part of the reason it was chosen in said programming languages. Imagine if it was called "name". And we had to "throw out all preconceptions you have with the word 'name.'"

It works in that sense, though.

"return x" is a monad (mobit?) which, when evaluated, returns x. The trick is that it's a distinct function, not a command.

Re: What I Wish I Knew When Learning Haskell

#17
post #14

Earlier quoted context omitted.

That argument seems more like (ignoring the naming issues of cabal vs cabal-install), that cabal is a terrible package manager, but still (to me) seems to bare all the major features of a package manager.

The fact that it forwards package registration to the underlying ghc-pkg system, has very poor/nearly nonexistent record keeping, and can't perform uninstall operations are kinda crucial. I've never heard of a packager manager that can't uninstall. If you present it as a package manager, even if it's a bad one, then you also telegraph a certain amount of implied functionality, and in turn the user has a certain level…

> I've never heard of a packager manager that can't uninstall.

easy_install

Re: What I Wish I Knew When Learning Haskell

#18
post #13

Earlier quoted context omitted.

I should have been clearer, myself. My problem is not that I may have to drop preconceptions from other programming languages. My beef is that the word has meaning outside of programming. And is part of the reason it was chosen in said programming languages. Imagine if it was called "name". And we had to "throw out all preconceptions you have with the word 'name.'"

It works in that sense, though. "return x" is a monad (mobit?) which, when evaluated, returns x. The trick is that it's a distinct function, not a command.

Exactly. My (terribly made) point is I am not throwing out all of my preconceptions. :)

Re: What I Wish I Knew When Learning Haskell

#19
post #5

Personally, I like to follow the mantra cabal is not a package manager . Because whenever I treat it like one, I get messed up in a bad way. I buy in to this argument[1] as to why it isn't. [1]: http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-...

I wonder if Haskell will ever get a package manager like Nix.(?)

Re: What I Wish I Knew When Learning Haskell

#20
post #15
post #9

Earlier quoted context omitted.

All of them. return "lifts" a "plain" value so that it becomes a "monadic" thing. As far as I can see, this has nothing at all to do with returning a value from a function.

Right, but I have preconceptions of the word "return" that have nothing to do with programming. I'm fine if you want to think of it as "returning to the monadic environment." That is, in English, you can return to things just as easily as you can return from them. I may have to forget some of the things that are common in other environments. But to use a word that has meaning outside of programming and to decry that…

Even within programming, using a word in a way that is completely unconnected to the ways it is used by everybody else is... let's say it's not very useful if your goal is to communicate.
Post reply on HN