Get to know the basics of Functional programming in Haskell
Haskell is a powerful and well-designed functional programming language designed to work with complex data. Its emphasis on "purity" makes it easier to create rock-solid applications which stay maintainable and error-free even as they grow in scale.
This video course will take you through all the concepts of functional programming (FP) and Haskell language. First we’ll address all the problems with FP and Haskell. Then we’ll help you distinguish the difference between FP and Haskell. We’ll then guide you through Haskell in depth. We’ll help you create your first Haskell program. You’ll then be given a brief insight into GHCi (Glasgow Haskell Compiler). Later we’ll explore the different values, expressions and programs in Haskell in depth.
By the end of this course you’ll have a foundation set-up to start writing your own Haskell programs and also have ample knowledge of the important functionalities of Haskell.
About the Author
- Richard Cook is a staff software engineer at Tableau Software working on high-performance relational database systems. He works primarily in C++ but has experience in broad range of languages and technologies. He frequently applies functional programming and Haskell experience in his daily work. He organizes the Seattle Area Haskell Users’ Group and is an active member of the Seattle functional programming community. He is currently working on developing a machine-learning framework for Haskell.
- He has a deep interest in programming languages and type systems in general, having developed compilers and developer tooling in the past. A keen user of Python and C#, he works regularly on all major desktop operating systems. He also dabbles with web applications.
- In addition to his programming interests, he has an interest in machine learning, data mining, and mathematics. He can be found on various MOOC web sites learning about anything from complex analysis to Scala.
- This course is for software developers with some experience in a “mainstream” imperative or object-oriented programming language such as C, C++, Java, C#, Python, or Ruby
- Discover how functional programming addresses complexity
- Understand the general characteristics of functional programs
- See a comparison of functional programs with traditional imperative programs
- Get to know GHCi in brief
- See how Haskell compares with other functional programming languages
- Know what Haskell programs look like
This video takes the user through the steps required to install the Haskell Stack build tool on Windows using Windows 10 Pro as an example.
- Visit http://haskellstack.org/ and view installation instructions for Windows
- Install Stack using the Windows installer
- Create, build, and run a test program using Stack
This video takes the user through the steps required to install the Haskell Stack build tool on Mac OS using Mac OS X 10.10.5 (Yosemite) as an example.
- Visit http://haskellstack.org/ and view installation instructions for Mac OS
- Install Stack using Homebrew
- Create, build, and run a test program using Stack
This video takes the user through the steps required to install the Haskell Stack build tool on Linux using Ubuntu 12.04.5 LTS as an example.
- Visit http://haskellstack.org/ and view installation instructions for Ubuntu
- Install Stack using generic Linux install method
- Create, build, and run a test program using Stack
This video will develop motivation for learning a new approach to software development and a new and decidedly different programming language.
- Learn some basic terminology and look at complexity of software
- Establish why we might want to learn functional programming
- Motivate participants by telling them that Haskell is fun!
This video will outline the approach to managing complexity that functional programming (FP) encourages.
- Learn the basic principles of FP
- Learn how FP addresses complexity
- Look at the key ways in which functional programs look different from “imperative” programs
This video will talk about what Haskell has in common with other functional programming languages as well as the ways in which it is different.
- Learn how Haskell has core aspects of a functional programming language
- Revisit what pure functions are and look at the evaluation strategy
- Look at static typing, garbage collection, and naming conventions
This video will demonstrate some more realistic programs, incrementally built up from simpler programs. It will run them in GHC’s interpreted mode. We will see more Haskell syntax encounter more functions from Haskell’s standard prelude.
- Write a “Hello world” program and run it from the command line
- We’ll add more features to it and run the resulting programs again
- We’ll look at more Haskell syntax and more standard functions
Haskell is a whitespace-sensitive programming language. It’s worth gaining some comfort with the indentation rules, even though they correspond—for the most part—to the “obvious” way to lay a program out. We’ll relate layout to lexical scoping of names.
- Demonstrate different ways of legally (and illegally) indenting “let” bindings
- Show rules applied to “where,” “do,” and “case…of” constructs
- Learn how to read “brace”-delimited Haskell code
When we’re learning a new programming language, it can be very helpful to be able to query the types of values and expressions, and to be able to browse types and modules. The GHC compiler provides the GHCi read-evaluate-print loop, which allows us to inspect Haskell code at runtime.
- Ensure that we start the correct version of GHCi using Stack
- Explore shell commands as well as types and values
- Explore kinds, browse/load/reload modules and edit code
Haskell employs a non-strict evaluation strategy which can be strange for newcomers to the language. Furthermore, we will inevitably write buggy code. GHCi has useful debugging capabilities that can allow to address both of these concerns.
- Learn about the location of GHCi’s configuration file and set up a GHCi session for debugging
- Set breakpoints, run code, examine bindings including unevaluated thunks
- Show bindings, breakpoints, list program source code, abandon sessions, and quit
We will drill deeper into values, function application and composition, and the various ways to declare functions.
- Look at Haskell’s primitive types
- Examine function application and composition
- Look at lambdas, infix functions, sections, and partial application
So far, we have only skimmed over types and type signatures. You need to know enough to be able to read function declarations and build our own functions and values.
- Learn about type synonyms and type signatures for values and functions
- Learn about type variables and Haskell’s parametric polymorphism
- Learn about type class constraints
We’ve looked at built-in types and values and functions that use them; you need to learn how to define our own composite data types. This will use Haskell’s support for user-defined algebraic data types.
- Learn about sum types and their syntax
- Learn about product types, their syntax, and record syntax
- Learn about Haskell’s predefined algebraic data types
Haskell’s primary mechanism for implementing abstract data types is the type class. We need to know about some of the common built-in type classes as well as how to implement our own type classes and type class instances.
- Learn about common type classes and how to implement instances for them
- Learn about type wrappers to avoid breaking type class instance rules
- Learn how to write our own type classes
You learn all about declaring our own ADTs and creating values for them. Before we can really consume ADTs, you need to know how to extract values from them using pattern matching.
- Learn about pattern matches in function argument lists and lambdas
- Learn about the case of expression for pattern matching in expressions
- Learn how to prevent issues with non-exhaustive pattern matches