Please describe your proposed solution.
Zero to Haskell is a 10 week program that covers all of the foundational knowledge of Haskell required for students to successfully complete the Plutus Pioneer Program. Through discussions with the IOG Plutus Pioneer team, we developed coursework for novices covering the important fundamentals of Haskell.
Our Catalyst proposal is to fund 20 scholarships for the Zero to Haskell program.
It has a project oriented approach culminating in the building of the snake game in Haskell. Also, a workbook will be provided to extend student knowledge.
One of the key features of the project is that it is written twice. The first time, students will be writing the snake game using pure functions only. Then they will refactor the code to use more common abstractions like Monads and mtl -style. With this double-writing methodology, we address a common problem faced when learning monads: "Why should I use them?" Students will see the advantages of using abstractions and how they lead to more readable code.
The course is planned as follows, and can be adapted depending on students' learning speed:
Week 1
- Haskell Tooling
- Writing basic functions
- List comprehension
- Project Introduction
**Week 2**
- Record Types and Algebraic Data Types
- Pattern matching
- List Recursion
- Project Build the Board: using standard libraries like array
**Week 3**
- Currying and partial application
- Higher order functions.
- Factor out recursion with fmap
, fold
, etc…
- Project Build the Snake: using standard libraries like containers
**Week 4**
- Type classes
- Random value generation
- Introduction to functors
- Project Build the Logic of the Game: Generate a board with random initial values using random
library. Minimal Viable Product
**Week 5**
- More about Functors
- Introduction to Monads: Maybe
and List
- Project Refactor 1: Convert the MVP into a fully feature snake game
**Week 6**
- Monads: State
and Reader
.
- do notation
- Project Refactor 2: Use the state monad to write the game logic.
**Week 7**
- Monads: IO
and async
package for asynchronous programming.
- Introduction Transformers: StateT and ReaderT.
- Project Refactor 3: Write the application using a transformer stack.
**Week 8**
- Transformers: introduction to mtl
library.
- Project Refactor 4: Write the application leaning on mtl
abstractions.
**Week 9**
- Note on other design patterns like RIO
, or effect systems
- Project Finishing the Game: with mtl
abstraction.
**Week 10**
- Brief introduction to template Haskell
- Brief introduction to Plutus API
- Project (Optional) : Use the abstracted version of the software to easily change frontend keeping the backend the same. For example, using brick
or sdl
libraries
After the class ends, each student will have a 1:1 session to help them prepare their application to the Plutus Pioneer Program. Our goal is not just to teach the fundamentals of Haskell, but to give students the absolute best chance at learning Plutus and ultimately finding a career within the Cardano ecosystem.
Please describe how your proposed solution will address the Challenge that you have submitted it in.
The Zero to Haskell program is designed by someone who learned Haskell as their first programming language for novice programmers who lack a background in programming. This foundational knowledge in Haskell is imperative for successfully learning Plutus.
Saurabh Nanda’s talk about this topic is a great resource to understand the difficulties Haskell learners face compared with learning other programming languages. On a technical level, the argument goes like the following:
- Haskell makes a hard commitment on keeping code pure (unlike mainstream PLs)
- This forces the programmer to explicit annotate at the type level whether a function is pure or not
- This leads to abstractions like functors and monads to become crucial to write meaningful Haskell code
- These abstractions are implemented as Type Classes with Higher Kinded Polymorphism.
- This level of polymorphism is uncommon in mainstream languages. Also, learning abstraction is always more difficult than learning concrete examples.
- plus a plethora of oddities like curryfication, partial application, weird operators, etc…
The above can be summarized in ordinary words as follows:
Whereas other languages encourage you to separate pure code from impure code, Haskell forces you to do so. Whereas other languages encourage you to rely on abstractions (normally, via SOLID principles), Haskell pushes you straight into abstractions to write anything useful.
Of course, this leads to a steep learning curve. In most programming languages you start by writing small programs not caring about abstractions or design patterns. As experience is gained, you start to use better interfaces, applying SOLID principles and patterns like Factories, Decorators, dependency injections, etc… In Haskell, you are pretty much forced to jump directly from toy programs to high level abstractions.
So, How do we deal with this jump? We follow an individual mentoring approach as opposed to MOOC based courses. We believe this is a better learning solution because, as stated before, the main problem with Haskell is its high levels of abstraction. Learning abstractions is a difficult task which becomes an order of magnitude more difficult if you are on your own.
There are tons of good resources freely available to learn Haskell on the web, but people still struggle with it. We think they are lacking a companion who can clear out the misconceptions and focus on the key concepts, boosting up the process of acquiring the right mindset. This is only possible if you have access to someone tracking your progress and willing to help you on a 1:1 basis.
We provide students exercises based on the book “Piensa en Haskell” (Translation WIP), which is the book used at University of Sevilla for its Haskell course. This material is written such that no prior experience in any programming language is needed. So we think it is a good choice for our students.
The course’s project is the snake game which is written first using no abstractions at all (except for mandatory IO monad which is given to the student) and then refactor it to introduce monads step by step. This smooths out Haskell’s learning curve, because at first, you are inline with Haskell’s hard commitment to purity. All the abstractions are later introduced step by step on the code with a justification on its necessity and with clarity about the benefits they provide.
What are the main risks that could prevent you from delivering the project successfully and please explain how you will mitigate each risk?
The biggest risk we face in our program is the feasibility of a novice programmer learning the fundamentals of Haskell and being able to apply them while learning Plutus. Being a mathematician, Luis understood mathematical concepts central to certain subjects of Haskell which may have given him a competitive edge compared to someone who does not have a mathematics background. Fortunately, the solution to this problem lies with the teacher of the course, who is well versed in the mathematical concepts underlying the topics covered in the course and will be able to spend ample time with students 1:1 in order to teach them any basic mathematics knowledge they are lacking.
Students not attending the course is a major risk. We will call and email any students that start to miss the in-person classes or are not active in the Discord channel.
Students that attend the class but not putting in the effort for assignments is another risk. This risk can be mitigated by tracking student activity on course work and conducting regular 1:1 check-ins.