Course info
May 22, 2014
1h 53m

Haskell is an innovative, functional programming language with many exceptional features that help you to write highly readable, error-resistant code. In this course, the second in a two part series, you will learn more about this language, including ways to organize larger projects and increase code reuse. Some basic understanding of Haskell is assumed, including the topics covered in Haskell Fundamentals Part 1.

About the author
About the author

Benson is an expert in algorithms and functional programming, and is passionate about Haskell. He is currently pursuing a PhD at the University of Waterloo in Canada.

More from the author
Haskell Fundamentals Part 1
2h 57m
Aug 16, 2013
Section Introduction Transcripts
Section Introduction Transcripts

Modules, Packages, and Cabal
Hello, welcome to Part 2 of Haskell Fundamentals. In this second part, I will be teaching you many more of the key Haskell concepts. In Part 1 of this course, I talked about how to use and define Basic Functions, which are always pure functions with no side effects. I also taught you about Higher-Order Functions, which are just functions that take another function as an argument. I introduced you to Haskell's rich Type System, which is quite different from most programming languages, and showed you how to define your own data types. I also showed you how to define and use Type Classes to achieve more powerful code reuse. Finally, I taught you about the IO Type, which is Haskell's way of affecting the outside world, despite the strict policy that no function can have a side effect. If any of these concepts are a little fuzzy, you might want to brush up on them before going on to the more advanced topics I'll be covering now. In this part of the course, I will be teaching you about Haskell's Modules and Packages, which provide ways to organize your projects. I will also be covering Standard Collection Types, including sets and maps, which are sometimes called dictionaries in other languages. I will also show you Monads; one of the most talked about topics in Haskell, because they provide a common abstraction and code reuse for so many things. Finally, I'll wrap up the course by showing off some of my favorite Haskell Libraries. These libraries exemplify Haskell's strengths and will, I hope, inspire you. So let's get started.

Standard Collections
Hello, and welcome back to Haskell Fundamentals. In this module, you're going to learn about some of Haskell's Standard Collection Types, which allow you to store collections and values in various ways, like a set or a list or a key value store, like a dictionary. First, I'm going to talk a bit about some of the restrictions placed on collection types by Haskell being a purely functional language and some of the rather peculiar, but very useful properties that functional collections have. Then, I'll introduce you to some of the most useful collection types, starting with set, which is an unordered collection of values. This means that you can find out whether a value is in the set, but you can't say that a particular value is the first element in the set. Next, I'll show you map, which is a key value pair data structure, similar to dictionaries in other languages. Seq, or sequence, stores elements in an order, just like a good old list that you are already familiar with. However, seq is more efficient than a list in many circumstances and supports more operations.

Hello, and welcome back to this course on Haskell Fundamentals. This module will cover Monads; one of the most powerful concepts in Haskell, which allow you to generalize your code using a surprisingly common pattern. Several things that you've already seen in this course are, in fact, monads. So we'll start off by showing you these familiar examples and the common pattern that ties them all together. Next, we'll take a closer look at this common pattern and some of the functions that ought to work for all monads. Thanks to Haskell's amazingly powerful type system, once we recognize this pattern, it's easy to wrap it up in a type class so that we can reuse code between different monads. Finally, we will take a look at a Haskell language feature called do-notation, which makes code using monads more readable and intuitive.

Common Monads
Hello, and welcome back to Haskell Fundamentals. In this module, you'll learn about some standard monads that can help you write beautiful and useful code. First, I will show you the Reader Monad, which lets you write computations that have access to a contacts value, like the name of a logged-in user, for example. Then, I will show you how you can use the State Monad to express computations that have a changing state, such as a simulation. This is especially helpful because some problems are inherently stateful and can be very difficult to solve using the more elementary functional programming techniques you've seen in this course. Finally, I will show you the ST Monad, which allows you to write high performance imperative code without losing Haskell's functional purity.

Monadic Functions
Hello, and welcome back to Haskell Fundamentals. This module will cover some helpful general purpose functions for working with monads. First, I'll show you some monadic functions that mimic familiar flow control concepts in other languages. Then, I'll show you a very useful set of functions for turning ordinary functions into monadic functions. Finally, I'll cover some functions for dealing with lists and monads.

Hello, and welcome back to Haskell Fundamentals. In this module, I'll wrap up this course, by showing off some of the exceptional and unique software libraries that are at your disposal in Haskell. I will show you the Diagrams library, which is a beautifully designed, declarative drawing library. I will also show you the Lens library, which provides a nice way to access and manipulate values in nested data structures. And finally, I will show you one of Haskell's many implementations of Functional Reactive Programming, which basically provides a declarative way to react to events and other things that change over time.