Giter Club home page Giter Club logo

haskell-course's Introduction

Haskell Course

VersiΓ³n en πŸ‡ͺπŸ‡Έ traducida por la comunidad

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 Marlowe or Plutus, but it will cover all the Haskell you'll needed to work with them.

For a more detailed explanation, keep reading or watch the introduction video: YouTube

How much should I study if I only wish to use Marlowe/Plutus?

In the outline below, there are clear stopping points (for both Marlowe and Plutus) where we deem you to know enough Haskell to effectively use the technology.

How to read/watch the lessons

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 the one below. If the page loads with a "500: Internal Server Error" just refresh it, and it should be fine. 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.

Binder

And to see the video lessons, click on the button that looks like this:

YouTube

To do the homework

  1. Clone this repository.
  2. Create a GitPod account.
  3. Click this button to create a remote dev environment: Visual Studio Code
  4. Select the Homework/HomeworkXX folder with the homework you want to complete.
  5. Follow the instructions inside the Homework.hs or Main.hs file.
  6. Check the solutions in the solutions branch!

Repository structure

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

To hang out and discuss with other students

FAQ

FAQ

Proposed changes for next iteration/version

Changes

What we'll cover

This is a tentative outline. Changes can (and will) be made as we advance with the course and gather feedback from students.

If there are no buttons on a lesson, it means that it's not published yet.


BEGINNER SECTION - GETTING STARTED WITH HASKELL - πŸ₯šβŸΆπŸ£

In this section, we get familiar with basic concepts and Haskell syntax.


1. Intro and tools Binder YouTube

  • 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.

2. Data types, Signatures, and Polymorphism Binder YouTube

  • 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

3. Conditions and helper constructions Binder YouTube

  • If-then-else
  • Guards
  • let expressions
  • where
  • Should I use let or where?
  • Things to keep in mind

4. Pattern matching and Case Binder YouTube

  • What is pattern matching
  • Pattern matching on
    • Function implementations
    • Lists
    • Tuples
  • Case

5. Improving and combining functions Binder YouTube

  • Higher-order functions
    • The filter function
    • The any function
  • Lambda functions
  • Precedence and associativity
  • Curried functions
    • Partial application
  • Composing and applying functions
    • The $ operator
    • The . operator
  • Point-free style

6. Recursion Binder YouTube

  • Why Recursion?
  • Thinking Recursively
    • sum and product
  • Steps to create your own recursive function
  • Examples of recursion
    • and, length, reverse, drop, take, map, filter
  • Extracting the foldr pattern
  • The foldl function
  • The foldl' function
  • When to use foldr, foldl, and foldl'

7. Intro to Type Classes Binder YouTube

  • The awesomeness of type classes
  • What are type classes
  • Common type classes
    • Eq, Ord
    • Num, Integral, Floating
    • Read, Show
  • The most general valid type
  • Multiple constraints

8. Creating Non-Parameterized Types Binder YouTube

  • Type synonyms
    • How to define type synonyms
    • Why use type synonyms
  • Defining new types
    • Creating new types with data
    • Using new types
    • Value parameters
  • Record syntax

9. Creating Parameterized and Recursive Types Binder YouTube

  • Type Parameters
    • Prameteryzing type synonyms
    • Prameteryzing data types
  • Recursive data types
    • Tweet me a river
    • A Sequence of Nodes
    • A Tree of Nodes
  • Kinds
  • The newType keyword

10. Creating Type Classes and Instances Binder YouTube

  • Overloading
  • Steps to create Type Classes and Instances
  • The Eq type class
    • Defining the Type Class
    • Defining multiple instances
    • Improving our Eq type class with mutual recursion (and Minimal Complete Definitions)
    • Defining an instance for a parameterized type.
  • The WeAccept Type Class
  • The Container Type Class
  • Exploring Ord type class (Subclassing)
  • Deriving
    • Deriving can go wrong

11. Basic IO Binder YouTube

  • Pure functions
  • Introduction to IO actions
  • IO actions under the hood
  • IO actions in practice
    • The () type
  • Interacting with the user
    • getChar, getLine, and putStrLn
  • Actions are first-class values
  • Composing IO actions (>> and >>= operators)
  • The do block
    • Using let, nesting do-blocks, escaping IO and return
  • The main action
  • Concepts and syntax recap

BEGINNER SECTION - GAINING INDEPENDENCE - 🐣⟢πŸ₯

In this section, we learn about Haskell tooling and the necessary concepts to start working on our own projects.


12. Installing Haskell Locally Binder YouTube

  • 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

13. Modules Binder YouTube

  • Importing Modules
    • Controlling environments
    • Controlling namespaces
  • Creating our own Modules
  • The Prelude and Standard Libraries

14. Cabal and language extensions Binder YouTube

  • 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
    • NumericUnderscores
    • TypeApplications

15. Handling Errors Binder YouTube

  • There're always Exceptions to the rule
  • Speed-running Exceptions with a dumb self-driving πŸ€– car πŸš—
    • I'm the Exception cause I have class 😎
    • throw all the Exceptions you want. I'll catch them all!
  • Maybe give me a value? πŸ™
    • Benefits of optional values
  • Ok, you Either give me a value or a reason why you didn't!
  • From Exceptions to optional values
  • Tradeoffs
    • So, what should I use?

16. Learning on your own and final section project Binder YouTube

  • Small tips and tricks 🀹
    • REPL
    • Hackage
    • Hoogle
    • undefined
    • Type Holes πŸ•³οΈ
  • Section's Final Project πŸ₯³

BEGINNER SECTION - BASIC ABSTRACTIONS & EFFECTS - πŸ₯βŸΆπŸ“

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).


17. Semigroup and Monoid Binder YouTube

  • What does it mean to abstract a pattern?
  • Why abstracting patterns (in general)?
  • Teaser: Why abstracting Semigroup and Monoid?
  • The Semigroup type class
  • The Monoid type class
  • What can I do with Semigroup and Monoid?

18. Functor Binder YouTube

  • Abstracting the map function
  • The Functor type class
  • Defining Functor instances
  • Seemingly unintuitive Functor instances
    • The Either a functor πŸ€”
    • The (,) a functor 🀨
    • The (->) r functor 🀯
  • Defining the <$> operator and lifting πŸ‹οΈ a function
  • Functor nesting dolls πŸͺ†
  • Extra functions and Functor as defined in base

19. Applicative and Effects Binder YouTube

  • Why Applicative functors?
    • Our journey until now
    • The limits of Functor
  • Function application at the Functor level πŸ₯‡
  • Being pure πŸ˜‡
  • The Applicative type class
  • The Applicative laws
  • πŸŽ† Programming with effects πŸŽ†
  • Extra functions and Applicative as defined in base

20. Project using Functor and Applicative

  • TODO

x. Monad

  • TODO

x. Reader, Writer, and State Monads

  • TODO

Maybe speed-running other type classes? πŸ€”

  • TODO

x. Final project

  • TODO

πŸ₯³ CONGRATULATIONS! πŸ₯³ You can call yourself a (beginner) Haskell developer!

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. πŸ˜„πŸ™Œ


Where can you go from now?

It depends on your preferences. You could:

  • If you're interested in Cardano, explore Marlowe, Plutus, Atlas, CardanoAPI, 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):
    1. Explore the base library and understand all types and type classes.
    2. Learn about Testing (unit vs property testing and QuickCheck).
    3. Explore how to deal with Concurrency and Parallelism.
    4. Learn about Parsers (Parser combinators, Alternative type class, MonadPlus, Parsec library).
    5. Learn how Haskell deals with data structures under the Hood.
    6. Monad Transformers and Free monads.
    7. Generic programming.
    8. Meta programming with Template Haskell.
    9. Type-level programming.

haskell-course's People

Contributors

bboal avatar cipherlogs avatar cylonyx avatar lambdacc avatar lukakurnjek avatar perturbing avatar rober-m avatar vamanfredi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haskell-course's Issues

Free Online Integrated Development And Education Environment (IDEE) For Cardano To Grow The Community

I am grateful for the invitation to make requests about the course.

First, congratulations to Robertino Martinez for being the very first to write Haskell course material that I can actually follow. I have tried and failed to understand Haskell using all the Haskell courses listed in this index. So if Robertino has found a way to teach me, then he has found a way to teach everyone. And that is exactly who we want joining the Cardano developer community - everyone.

I have the distinction of having failed the Plutus Pioneers program all 3 times.
I failed each time because I was never able to setup my development environment.
I am not the only one who had this problem.
There must be many like me who have failed before even getting started.

On joining the Marlowe Pioneers I received extensive help from the community and was able to setup the development environment well enough to participate. Then with much help from our teacher Brian Bush I was able to understand the lessons and contribute in small ways.

(Brian presents his lessons using Jupyter Notebook)
In this video you can see Brian generating and running smart contracts on the testnet using Jupyter notebooks.

Despite many attempts, I was never able to run Brian's lessons from Jupyter Notebook. Instead I was forced to cut and paste mountains of code from the notebooks into my local terminal window. This extra step was inefficient and very error prone. As far as I know, none of the other students were able to run the code from Jupyter Notebook either. Something about our local environments were different from Brian's

Robertino has clearly solved the setup problem by using a version of Jupyter that runs in the cloud.

In summary:
In this video, Brian has demonstrated the advantages of generating and running Cardano smart contracts from Jupyter.
Robertino has demonstrated that he can distribute to all a cloud version of Jupyter that we know will work because it runs with no install or local complications.
We know we are losing developers before they even arrive because it is so difficult to setup the development environment.

Ask Number One
Please, can Robertino's Haskell lessons in Jupyter be expanded to include Plutus and Marlowe such that we can query and deploy to the testnet right from the lesson materials the way we see Brian doing it?

Aside from providing course materials in Jupyter, Robertino has also provided us with an online version of the VS Code IDE which hosts Jupyter. When I saw that I thought "Oh My God!, That's Remix for Cardano"
Remix is Ethereum's free online integrated development and education environment (IDEE).
It's the gateway drug to Ethereum smart contract development.
Anyone with access to the Internet can go to https://remix.ethereum.org/ to learn Solidity and then deploy a smart contract for free (not counting the enormous transaction fees)
We need that too!

Robertino's online VS Code implementation has something that Remix does not have - Jupyter.
Well it almost has Jupyter. It displays Jupyter but sadly it doesn't run it.
That's because the online VS Code implementation is not free after 50 hours and Robertino wants users to have the service available for the lesson homework.

Ask Number Two
Please, Give us a free IDEE for Cardano like Remix but that also runs Jupyter.
You are so close. Please, you are almost there.

Ask Number Three
Finally, when Robertino's lessons are all recorded, May we please see the lessons in one giant video on FreeCodeCamp much like this one for Remix which is 32 hours long and has been view more than 800,000 times? That will bring more developers to Cardano as they learn to love Haskell, Plutus, and Marlowe.

Much thanks for considering all these requests.

Bug in last exercise on lesson 6 Homework

I think the filtering is applied to the wrong list, it should filter "bevogBeerPrices" with orderList", it's doing the opposite as it is right now

It works as it is now because the "orderList" has only the first three types of beers but won't work for other order lists.

Example: if we change orderList so it is
orderList =
[ ("Tak", 5),
("Kramah", 4),
("Baja", 7)
]

Then answer should be 8.5+(56+47+7*7.5)=119
beerCosts orderList gives = 126 as it zips "Ond" cost with # of Baja beers ordered.

Solution proposal:

`beerCosts orderlst =
  foldr (+) deliveryCost
 . zipWith (*) (map snd orderlst) 
 . map snd
 $ filter (\name -> fst name `elem` map fst orderlst) bevogBeerPrices`

Enclosed pdf file with handwritten comments on VSCode might help!

Lesson 6 Homework Solution Bug.pdf

A tiny, not so important, thing in the solution of Homework 06

In lines 98 & 104 of 6th lesson solution, namely

factorial :: Int -> String

and

    result = product [1 .. n]

I think the type should be Integer instead of Int, it seems the same but this code won't work if n > 20. I know this homework isn't meant to deal with such things, but I think it's a good opportunity to show when Integer is more suitable than Int.

Speedup the Integrated Development Environment (IDE)

From: #6

I understand that IDE is coming but the timeline is a discouraging. Developers are struggling. They can’t wait months. See: https://forum.cardano.org/t/developers-are-having-dismal-experience-building-on-cardano/110080

There are projects (like Sundaeswap, JPG.store, etc) currently running on Cardano. I can imagine they already developed in-house IDE or something similar. Can you reach out and ask them to open-source their tools? Or maybe form some kind of co-development of a Cardano IDE, based on what they already have, to be share with the ecosystem? That would speed things up immensely. Developers, especially new ones wanting to get into Cardano, desperately need the IDE. Most of them can't wait months.

This is urgent. Make it happens before they go build elsewhere.

Spanish translation

Hi Rober, I thought it was a great idea to have a community translation so IΒ΄ve forked and translated the repo to Spanish (up to lesson 1).
HereΒ΄s the repo, anyone can help improving it.
Saludos ;)

Solutions

Hi, can someone point out where can I find the solutions to the Homework? Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.