#+TODO: TODO TO-CLEAN TO-REVIEW | DONE #+TITLE: Haskell for the working programmer #+AUTHOR: Yann Esposito #+EMAIL: yann.esposito@gmail.com #+LANGUAGE: en #+KEYWORDS: haskell #+PROPERTY: header-args :output-dir HWP :mkdirp yes :tangle-mode (identity #o755) * TO-CLEAN Install a dev environment (about 30 minutes) Installing a dev environment should hopefully be the most boring part of this book. But this is a necessary price to pay to really get why Haskell is considered so great by people using it. *** TO-CLEAN Working environment A thing to note is the distinction between learning a language for personal interrest for some personal project and learning with the goal to achieve a "product" with some hard deadline. So for example, it can be nice to understand the language by playing inside a REPL. We won't use that much in this book as the goal is not to really gain a deeper knowledge but perhaps to be able to /use/ the language. The problem I try to solve in this book is to make you a professional /user/ of Haskell more than a /contributor/ to Haskell. While I encourage everybody to gain deeper understanding on the internals of Haskell this is not the primary goal of this book. What I mean by professional /user/ is that you should have the following features at your disposal: - DCVS - Generated documentation - Tests (Unit tests, Generative tests, Integration tests, etc...) - Benchmark - Continuous Integration - Continuous Deployment Choices: - Raw: get GHC and cabal exectuable and work with that. Too long and manual - Nix: this is really great because it's like a super make that can deal with external dependencies. Certainly the best tool in the long term. - Stack: fast to install focused on being user friendly. Has a lot of easy to use features like: - integration with docker that will make it easy to cross-compile, deploy. - integration with nix - easy to deal with many private repositories - good professional starting templates *** TO-CLEAN Stack I recommend [[https://haskellstack.org][stack]]. But there are many different method to install Haskell. Stack should be simple and straight to the point. If thing haven't changed since the book was written it could be installed with: #+BEGIN_SRC shell curl -sSL https://get.haskellstack.org/ | sh #+END_SRC *** TO-CLEAN git You should have =[[https://git-scm.com][git]]= installed. *** TO-CLEAN Editor You should check any of the supported editor here: https://github.com/rainbyte/haskell-ide-chart#the-chart-with-a-link-to-each-plug-in I personnaly use [[http://spacemacs.org][spacemacs]] with the haskell layer because it comes with battery included. If you're not used to vim keybindings I believe it is easy to switch to more classical editor keybindings easily. Even if I don't have a strong opinion on the editor you should choose. It should at least be easy to support the Haskell tooling, like intero or ghc-mod. Because it's one of the best part of Haskell. For example without any configuration I have the following features: - I see errors, warn and even code hints while I'm typing my code. - very good code completion - auto styling of my source code and be able to change the style of my entire buffer - be able to get the type of the expression under my cursor - be able to add the type of a top level declaration - be able to launch a repl easily loading the current code of the file I'm currently editing And many other nice features. Note that in the past I had some problem with ghc-mod during upgrades while intero was mostly a no problem story. It is also useful to have hoogle and hayoo, which are search engine focused on Haskell. **** TO-CLEAN Spacemacs So if you want to choose spacemacs: 1. Install a recent emacs 2. =git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d= 3. Launch emacs 4. Edit your =~/.spacemacs= file to add to the layer list: #+BEGIN_SRC elisp haskell (auto-completion :variables auto-completion-enable-help-tooltip t auto-completion-enable-short-usage t) #+END_SRC If you're not used to vim keybinding and it is too much to handle for you. I think you can change the value of =dotspacemacs-editing-style= from ='vim= to ='hybrid= or ='emacs= in the =.spacemacs= file. It should be good now. *** TO-CLEAN Conclusion First you can congratulate yourself to have installed all the prerequiste to have a great working development environment. I know it was already a lot of boring tasks to perform before being able to write any line of code. But I promise it will be worth it. By starting with this template, you won't use the classic prelude. It's quite a strong opinionated move. Because many classic function will be overwritten by safer/more generic one. So be prepared that the actual learning route is jumping other classical learning steps you can find in other learning resources. Don't worry I'll do my best to make the jump as natural as possible.