What I Wish I Knew When Learning Haskell
dev.stephendiehl.com
dev.stephendiehl.com
[1]: http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-...
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.
easy_install
(setq haskell-process-type 'ghci
haskell-process-path-ghci "/home/ben/.nix-profile/bin/nix-shell"
haskell-process-args-ghci '("-I" "." "shell.nix" "--pure" "--command" "cabal configure; cabal repl"))
This drops you into a nix shell with all the dependencies for the project you're working on present.You can also (especially easy if you're using projectile) run compile with the command nix-shell -I . shell.nix --command "cabal configure; cabal build" and that give you a nice list of type errors in your current project.
Repeatable builds with no cabal hell. In the words of disney: "I'm never going back, the past is in the past!"
As soon as I do though, I'll be stealing this emacs snippet and Haskell/Nix development technique.
Also I believe last time Stephen was surprised folks had gotten a hold of content on his "pre-prod" domain (e.g. http://dev.stephendiehl.com/), because he was still working on that post, before it was ready.
I like points as much as the next person, but maybe "pre-release" content should not be posted to aggregreators like HN before they are "realeased"
That said I'm excited he's continuing to update this series, it's helped a lot of people and there is a ton for me to learn still!
Reposts may not be encouraged but it gives the chance for new followers and those who missed seeing this post before. Not to mention the added karma for the poster.
On the other hand, for the sake of others, who don't know, please visit http://hn.algolia.com to check if something's already been posted!
https://hn.algolia.com/?q=What+I+Wish+I+Knew+When+Learning+H...
So I think this one counts as a dupe, even though the content has been augmented.
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 responses. I responded to two, but I'm not sure I have different responses for each. If it seems I've ignored some aspect, apologies.
More or less by coincidence, 'return' tends to appear in the same places you would see the 'return' statement in C and derived languages. But the purpose of the 'return' function in Haskell is quite different from the 'return' statement.
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.
In Haskell, 'return' creates a monadic value. Here are some excerpts from Learn You A Haskell for Great Good:
> If you've done imperative languages like C, Java or Python, you're probably thinking that you know what this return does and chances are you've already skipped this really long paragraph. Well, here's the thing: the return in Haskell is really nothing like the return in most other languages! It has the same name, which confuses a lot of people, but in reality it's quite different. In imperative languages, return usually ends the execution of a method or subroutine and makes it report some sort of value to whoever called it. In Haskell (in I/O actions specifically), it makes an I/O action out of a pure value. If you think about the box analogy from before, it takes a value and wraps it up in a box. The resulting I/O action doesn't actually do anything, it just has that value encapsulated as its result.
...
> return is sort of the opposite to <-. While return takes a value and wraps it up in a box, <- takes a box (and performs it) and takes the value out of it, binding it to a name.
Imagine if it was called "name". And we had to "throw out all preconceptions you have with the word 'name.'"
"return x" is a monad (mobit?) which, when evaluated, returns x. The trick is that it's a distinct function, not a command.
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.