The aim of this video is to introduce how to install Haskell on OS X.
- [Instructor] In this video, we'll install Haskell onto a Mac running the OSX operating system. So we'll start off on the Haskell.org website. And let's click on the downloads link at the top of the page. As we discussed in the previous video, we're going to install using a method called Stack. So let's click on that link now. And you can see that there are links for all the popular operating systems.
Let's click on OSX now. There are two main options for installing Haskell on OSX, manual download and Homebrew. Now, if you're already a user of the popular Homebrew system, you know exactly what to do. Just type "brew install haskell-Stack." There is a warning at time of making this video about using Homebrew against macOS Sierra, the latest version of OSX. So you may wish to do the manual downloads.
Let's see how that works. First of all, you need to download the release by clicking on this link. Then extract the archive, place it onto your path, and finally run Stack setup. So let's look at our downloads directory, and you can see that we've downloaded this file as a gzipped archive. So let's extract it using tar minus x z f.
Now you can see that the directory's been extracted, and inside it is the executable called Stack. However, it's not yet in our path. So we need to add it to that by export path equals the path to this executable, and can catenate with dollar path. And now, Stack is found by bash.
But of course, we need to make sure that the next time we open a terminal, it'll still be here. So let's simply copy that full path into our bash profile. In all of these examples, I'm using Vim text editor, but of course you're welcome to use whichever text editor you feel most comfortable with. And let's save that, and now the next time we open a terminal session, we'll be able to use Stack.
So now we need to run Stack setup. You can see here that we're using a global project config, and that's because we didn't give any specific Stack configuration for this project. And that's okay, we'll look at that in a later video. For now, we'll just install it globally. So this is now going to be downloading lots of files and packages and it may take some time.
You can see that at the time of this download, I'm downloading GHC eight zero one. That version will depend on whatever the latest version of the Glasgow Haskell Compiler is when you do the downloads. I've sped up this example just a little bit. Don't worry if it takes a little bit longer on your system. So now that this is installed, we get a usage message suggesting how to run the Glasgow Haskell Compiler, or the interpreter.
And we're going to go ahead and run Stack GHCi to invoke the interpreter. Again, you'll be using the version that you downloaded before. And once that opens, you can go ahead and type in any Haskell expression that you like. In the next video, we'll install Haskell onto a Windows machine.
Alternatively, you may want to skip straight to the next section, getting started with Haskell, where we'll experiment with Haskell using GHCi, the interactive Haskell interpreter that we just installed using Stack.
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Discovering Haskell with GHCI
- Haskell datatypes and functions
- Using higher order functions for data manipulation and code reuse
- Editing Haskell source code
- Creating a project with Stack
- Writing and conducting tests