The easiest way to learn Haskell - R.M.
This course is designed to teach non-engineers (e.g., self-taught/bootcamp coders) Haskell from zero to productive in an interactive, easy-to-follow way. The course doesn't contain content specific to Plinth, but it will cover all the Haskell you'll needed to start using it.
For a more detailed explanation, keep reading or watch the introduction video:
To go through the interactive lessons, go to your chosen lesson's outline inside "What we'll cover" and click on the button that looks like this: . At the top, you will see a console that displays the progress of preparing your interactive lesson. During this time, you can scroll down and look at the lesson, that is displayed non-interactively.
NOTE: If the page loads with a "500: Internal Server Error" just refresh it, and it should be fine.
And to see the video lessons, click on the button that looks like this:
- Clone this repository.
- Create a GitPod account.
- Click this button to create a remote dev environment:
- Select the
Homework/HomeworkXXfolder with the homework you want to complete. - Follow the instructions inside the
Homework.hsorMain.hsfile. - Check the solutions in the
solutionsbranch!
Haskell-Course
| |
| |---- Homework
| |
| |---- Homework01 (Homework for lesson 01)
| |---- Homework02 (Homework for lesson 02)
| ...
|
|-------- lessons (Lessons in Jupyter notebook format. Access through Binder.)
|
|---- 1-Introduction-to-haskell
|---- 2-Functions-Data-Types-and-Signatures
Everything else can be safely ignored
If there are no buttons on a lesson, it means that it's not published yet.
In this section, we get familiar with basic concepts and Haskell syntax.
- Intro to the course and lectures
- What weβll cover
- Repository structure
- Intro to Haskell
- How to open and use JupyterLab
- Purely functional programming language
- Basic syntax
- Haskell Type system
- Laziness
- GHC (and GHCi)
- GitPod
- How to open and use GitPod
- Example of how to complete a homework assignment.
- Pragmatic intro to types
- Type signature
- Functionβs signatures
- Variables in Haskell
- Parameters in functions
- Names/Definitions
- Infix and prefix functions
- Data Types in depth
- Int, Integer
- Float, Double
- Rational
- Bool
- Char
- Lists
- Strings
- Tuples + Tuples VS Lists
- Polymorphic values and type variables
- If-then-else
- Guards
letexpressionswhere- Should I use
letorwhere? - Things to keep in mind
- What is pattern matching
- Pattern matching on
- Function implementations
- Lists
- Tuples
- Case
- Higher-order functions
- The
filterfunction - The
anyfunction
- The
- Lambda functions
- Precedence and associativity
- Curried functions
- Partial application
- Composing and applying functions
- The
$operator - The
.operator
- The
- Point-free style
- Why Recursion?
- Thinking Recursively
sumandproduct
- Steps to create your own recursive function
- Examples of recursion
and,length,reverse,drop,take,map,filter
- Extracting the
foldrpattern - The
foldlfunction - The
foldl'function - When to use
foldr,foldl, andfoldl'
- The awesomeness of type classes
- What are type classes
- Common type classes
Eq,OrdNum,Integral,FloatingRead,Show
- The most general valid type
- Multiple constraints
- Type synonyms
- How to define type synonyms
- Why use type synonyms
- Defining new types
- Creating new types with
data - Using new types
- Value parameters
- Creating new types with
- Record syntax
- Type Parameters
- Prameteryzing
typesynonyms - Prameteryzing
datatypes
- Prameteryzing
- Recursive data types
Tweetme a river- A
SequenceofNodes - A
TreeofNodes
- Kinds
- The
newTypekeyword
- Overloading
- Steps to create Type Classes and Instances
- The
Eqtype class- Defining the Type Class
- Defining multiple instances
- Improving our
Eqtype class with mutual recursion (and Minimal Complete Definitions) - Defining an instance for a parameterized type.
- The
WeAcceptType Class - The
ContainerType Class - Exploring
Ordtype class (Subclassing) - Deriving
- Deriving can go wrong
- Pure functions
- Introduction to IO actions
- IO actions under the hood
- IO actions in practice
- The
()type
- The
- Interacting with the user
getChar,getLine, andputStrLn
- Actions are first-class values
- Composing IO actions (
>>and>>=operators) - The
doblock- Using
let, nesting do-blocks, escapingIOandreturn
- Using
- The
mainaction - Concepts and syntax recap
In this section, we learn about Haskell tooling and the necessary concepts to start working on our own projects.
- Installing Haskell
- Installing GHCup
- Installing GHC, Cabal, Stack, and HLS with GHCup
- Installing VSCode Extensions
- Creating our first program
- Writing the simplest Haskell program
- Compiling and running our program
- Importing Modules
- Controlling environments
- Controlling namespaces
- Creating our own Modules
- The
Preludeand Standard Libraries
- Cabal
- Introduction to Cabal
- Creating a new Haskell project
- Going over the Cabal file using an external library
- Building and running our executable
- Language extensions and Pragmas
- Introduction
NumericUnderscoresTypeApplications
- There're always
Exceptions to the rule - Speed-running
Exceptions with a dumb self-driving π€ car π- I'm the
Exceptioncause I haveclassπ throwall theExceptions you want. I'llcatchthem all!
- I'm the
Maybegive me a value? π- Benefits of optional values
- Ok, you
Eithergive me a value or a reason why you didn't! - From
Exceptions to optional values - Tradeoffs
- So, what should I use?
- Small tips and tricks π€Ή
- REPL
- Hackage
- Hoogle
undefined- Type Holes π³οΈ
- Section's Final Project π₯³
In this section, we learn about a few of the most useful and talked about Abstractions in Haskell and how we deal with effects in general (not only IO).
- What does it mean to abstract a pattern?
- Why abstracting patterns (in general)?
- Teaser: Why abstracting
SemigroupandMonoid? - The
Semigrouptype class - The
Monoidtype class - What can I do with
SemigroupandMonoid?
- Abstracting the
mapfunction - The
Functortype class - Defining
Functorinstances - Seemingly unintuitive
Functorinstances- The
Either afunctor π€ - The
(,) afunctor π€¨ - The
(->) rfunctor π€―
- The
- Defining the
<$>operator and lifting ποΈ a function Functornesting dolls πͺ- Extra functions and
Functoras defined inbase
- Why
Applicativefunctors?- Our journey until now
- The limits of Functor
- Function application at the
Functorlevel π₯ - Being
pureπ - The
Applicativetype class - The
Applicativelaws - π Programming with effects π
- Extra functions and
Applicativeas defined inbase
- Why
Monads? - Extracting the pattern for:
MaybeEither eLog
- Abstracting the
MonadType Class - The abstraction
Monadchy - The
Monadic laws Monadas defined inbase- You have to
dowhat you have todo
- Introduction
- Logs
Writer(based onLog)- Incentive
- Generalizing
Log - Helper fucntions
- Environment
Reader- Interacting with a (fake) database
- Extracting the pattern
- Using the
ReaderMonad
- The
Stateof things- Implementing a vending machine
- Extracting the pattern
- Using the
StateMonad
In this project, we'll build a CLI that converts Markdown files into HTML files. We're going to learn about:
- The
textlibrary - How to build a CLI using
optparse-applicative - How to parse text using
megaparsecand combinators - How to generate HTML from a Markdown AST
Ideally, you'll see the video without taking notes, and then try to implement the whole thing referencing only the libraries' documentation. Have fun!! π
Thank you for going on this journey with me! Please feel free to give us feedback through issues, email, or Twitter. And share this course if you find it valuable. ππ
It depends on your preferences. You could:
- If you're interested in Cardano, explore Plinth, Atlas, and other Cardano-related tools and libraries.
- Start your own project and learn what you need on the way (e.g., a server, a compiler, a full-stack app using IHP)
- Read Haskell books and sources that go into more advanced subjects. See recommended resources here.
- Learn about specific subjects, for example (organized roughly by difficulty):
- Explore the
baselibrary and understand all types and type classes. - Learn about Testing (unit vs property testing and QuickCheck).
- Explore how to deal with Concurrency and Parallelism.
- Learn how Haskell deals with data structures under the Hood.
- Monad Transformers and Free monads.
- Generic programming.
- Meta programming with Template Haskell.
- Type-level programming.
- Explore the