Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
indefinitelee committed Oct 23, 2020
2 parents 6a034ac + 106d542 commit f7669b8
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 95 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ test-chapter4:
test-chapter4-basic:
cabal test doctest-chapter4 --enable-tests --test-show-details=direct
cabal run learn4haskell-test --enable-tests -- -m "Chapter4Normal"

.PHONY: test-all
test-all:
cabal test all --enable-tests --test-show-details=direct
115 changes: 57 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

![Learn4Haskell](/images/HacktoberFest2020-Learn4Haskell-Banner.png)

It is this time of the year when thousand pull requests are starting to float in
It's the time of the year when thousand pull requests are starting to float in
the air like a leaf on the wind πŸƒ

It is Hacktoberfest! And we are happy to be part of this fantastic event.
It's Hacktoberfest! And we are happy to be part of this fantastic event.

Usually, people are contributing to the projects within the communities they are
boiling in.
But why not to use this time learning something challenging, something fresh,
Usually, people contribute to projects within the communities they spend most of their time
aleady and don't try to go out of those boundaries.
But why not use this time to learn something challenging, something fresh,
something that you never had time for?

You can get the benefits of the Hacktoberfest itself and learn wholly new but
You can get the benefits of Hacktoberfest while learning something new
fascinating concepts – Functional Programming with Haskell.

And we are here to help!
And we're here to help!

* 4 Pull Request to get the T-Shirt or plant a tree as stands in the Hacktoberfest rules.
* 4 Pull Request to learn to program in Haskell.
Expand All @@ -37,30 +37,30 @@ And we are here to help!

## What is Learn4Haskell

Learn4Haskell is a GitHub-located course that would get you into the Haskell
Learn4Haskell is a GitHub-located course that will get you into the Haskell
Functional Programming world in just 4 Pull Requests.

The course is organised as a coding project. So you would be able to complete
the course without exiting your editor.
This course is organised as a coding project. So you can complete
the course without needing to exit your editor.

This works in the following way. When you decide to start the project, all you
need to do is to fork the project. We prepared 4 separate modules β€” chapters.
need to do is to fork the project. We have prepared 4 separate modules β€” chapters.
Each part contains educational material and lots of examples that we provide in
the simple form that doesn't require you to know anything about FP beforehand.
a simple form that doesn't require you to know anything about functional programming beforehand.
Also, each chapter contains a number of exercises on everything that is
explained by us. You can solve the tasks on your way and at the end open a PR to
your fork with this chapter's solution and summon us (by shouting out our
nicknames there). We would be happy to give you feedback on your progress,
explain problematic concepts or just support you mentally!

Each chapter contains unique information and covers different topics. We suggest
you go through them in order. However, if you think that some of the chapters
are already familiar to you, feel free to skip to the next one. There is
absolutely no problem, if you would like to talk to us only on some PRs and
chapters.
going through them in order. However, if you think that some of the chapters
are already familiar to you, feel free to skip onto the next one.
If you would like to talk to us, you can even rely on PRs for the chapter you
have questions about.

Chapters are very filled with information, but yet are aimed to be doable
without additional sources. You may spend an evening per chapter, but we swear
Chapters are stuffed with information, but are aimed to be completed
without additional resources. You may spend an evening per chapter, but we swear
it's worth it!

At the end of the course you should be able to independently create and read
Expand All @@ -69,7 +69,7 @@ Programming.

### Course Plan

Here is a more concrete plan of all these mystical 4 Chapters we prepare for
Here is a more concrete plan of the mystical 4 Chapters we prepared for
you. These are the highlights of each part.

* __Chapter One__ – What is Haskell, what are its particularities, basic Haskell
Expand All @@ -79,26 +79,26 @@ you. These are the highlights of each part.
applications, eta-reduction.
* __Chapter Three__ – Focus on Types. Type aliases, ADTs, Product types and
Records, Sum types and Enumerations, Newtypes, Typeclasses.
* __Chapter Four__ – Kinds. Also three monsters of the FP: Functor, Applicative,
* __Chapter Four__ – Kinds. Three monsters of functional programming: Functor, Applicative,
Monad.

## Goals

We created the Learn4Haskell project to pursue the following goals:
We created the Learn4Haskell project in pursuit of the following goals:

* Help others to learn Haskell
* Give a beginner-friendly and self-consistent course with theory and practice
in the same place
* Explain Haskell topics before each task, but strive to be concise and useful
at the same time. It is a tough balance!
at the same time. It's a tough balance!
* Help people who want to participate in Hacktoberfest and Open-Source, but also
want to learn new things during this process
* Provide review and feedback on solutions, so people are never alone in this
challenging journey.
* Give people who completed this course with all the necessary understanding to
be able to work with the basic project that uses standard features. Also,
provide a strong basis on which they should be able to continue their FP
study.
challenging yet exciting journey!
* Give people who completed this course all the necessary understandings to
be able to work with basic projects that use standard features. We also intend
that you have a strong basis on what they should do to be able to continue their functional programming
studies.

## Who can participate

Expand All @@ -109,31 +109,31 @@ We welcome everyone and would be happy to assist you in this journey!
The course is intended for people who don't know Haskell or know only language
basics, though.

If you are already an experienced Haskell developer and came here for learning
advanced topics, this course might not be that for you. But you still can help!
If you are already an experienced Haskell developer and have come here for learning
advanced topics, this course might not be that for you. But you still can help us!
Your feedback and suggestions would be helpful for us as well as for the
language newcomers who decide to go with this course.
language newcomers who decide to work with this course.

## What you will get from this course

This course is coming with many benefits. Check them out to be sure that it fits
you!
This course has many benefits upon completion. Check them out to be sure that it fits
your expectations!

So, the participation in this course would give you:
The participation in this course would give you:

* 4 Pull Requests required for Hacktoberfest completion
* Basic knowledge of the most functional programming language
* Understanding of the FP concepts that you would be able to use in your
* Understanding of the functional programming concepts that you would be able to use in your
day-to-day life afterwards
* On-the-fly feedback and help from experienced Haskell developers and educators
* Interesting challenges
* Fun!

This seems like a neat deal!
Honestly this seems like a pretty rad deal!

## How to get started
## So how do I get started?

Starting to learn Haskell with Learn4Haskell is very easy!
Starting to learn Haskell with Learn4Haskell is a piece of cake!

1. [Fork this repository](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo).
2. :warning: Add the `hacktoberfest` topic to your fork. Otherwise, [your PRs won't count](https://hacktoberfest.digitalocean.com/hacktoberfest-update).
Expand All @@ -146,19 +146,18 @@ Starting to learn Haskell with Learn4Haskell is very easy!
[Pull Request](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)
__to your fork__ with the solution and mention @vrom911 and @chshersh and we
would be on our way for the review.
> Note, that you should open PR for your fork of this repo, not this repo.
> Everyone has their own solutions to our tasks, and they don't mix together
> Note, that you should open a PR for your fork of this repo, not this repo.
> Everyone has their own solutions to the included tasks, and they don't mix together
> well in one repo πŸ™‚
> However, if you find some bugs or problems in this repo, you can, of course,
> open PR to Learn4Haskell directly. We appreciate any help and feedback!
> However, if you find some bugs or problems in this repo, you can of
> open a PR to Learn4Haskell directly. We appreciate any help and feedback!
Learn4Haskell has 4 chapters you can walk through and submit 4 pull requests to
complete the Hacktoberfest (or just for knowledge and fun sake).
Learn4Haskell has 4 chapters that you can walk through and submit 4 pull requests to
complete the Hacktoberfest event (or just for knowledge and your own enjoyment).

So, you can start right now with forking. And we will describe how you can
install all necessary to be able to run this course locally in the following
section.
So, you can start right now with forking. Following this will describe how you can
install all the necessary items to be able to run this course locally.

### Installing Haskell

Expand All @@ -173,7 +172,7 @@ Then, do [the workaround](https://www.stackage.org/blog/2020/08/ghc-8-10-2-windo
If you're on Linux or macOS, then the process is easy:

1. Install [ghcup](https://www.haskell.org/ghcup/) and follow `ghcup`
instructions for successful installation.
instructions for successful installation (remember to restart your terminal afterwards to avoid an `unknown ghcup command` error on the next step).
2. Install the latest version of the Haskell compiler β€” GHC β€” and the
[Cabal](https://www.haskell.org/cabal/) build tool. After you install
`ghcup`, it is easy to install the rest with a few commands from your
Expand All @@ -191,18 +190,18 @@ If you're on Linux or macOS, then the process is easy:
If you don't have any IDE preferences, we recommend installing
[Visual Studio Code](https://code.visualstudio.com/download) with the
[Haskell plugin](https://marketplace.visualstudio.com/items?itemName=haskell.haskell).
The mentioned plugin would give you all the necessary to immediately start coding with Haskell.
The mentioned plugin would give you everything required to immediately start coding with Haskell.
### How to develop
The course assumes that you install Haskell tooling (GHC and Cabal), edit code
in the corresponding chapters, run GHCi (Haskell interpreter, explained in the
course) from the root of this project and load your chapters to check your code.
Don't worry, each Chapter explains all relevant information!
Don't worry, each Chapter explains all the needed information!

We also provide Makefile with commands to test your solutions locally with our
prepared test-suite locally. At the same time, we configured CI using GitHub
Actions for Learn4Haskell to check your answers at GitHub right away!
We also provide Makefile with commands to test your solutions locally with the included
prepared test-suite. We have also configured the CI using GitHub
Actions on Learn4Haskell to check your answers at GitHub automatically!

To run all tests for Chapter One:

Expand All @@ -227,14 +226,14 @@ Together we drive this open source organisation β€”
and libraries in Haskell that are used in the Haskell community. We are also
working on a lot of tutorials and guides in Haskell and mentoring people who are
keen to learn Haskell as well. Moreover, Dmitrii has a few years of experience
teaching Haskell courses in the university for the CS students.
teaching Haskell courses in the university to CS students.

We are passionate about Functional Programming and Haskell in particular. But at
the same time we understand how difficult it could be to get into all these
ideas on your own. That is why we decided to start this course to help
newcomers. With the interactive learning process and live discussions, Haskell
could be not that scary, at least we will do our best that it won't be the case
for you!
the same time we understand how difficult it can be to get into all these
ideas on your own. That is why we've decided to start this course to help
newcomers. With the interactive learning process and live discussions we've included, Haskell
will not be that scary. We will do our best so that it especially won't be the case
for you or any others participating here!
## How can you help
Expand Down
22 changes: 17 additions & 5 deletions src/Chapter1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -301,31 +301,43 @@ expressions in GHCi
functions and operators first. Remember this from the previous task? ;)
>>> 1 + 2
INSERT THE RESULT INSTEAD OF THE TEXT
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> 10 - 15
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> 10 - (-5) -- negative constants require ()
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> (3 + 5) < 10
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> True && False
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> 10 < 20 || 20 < 5
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> 2 ^ 10 -- power
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> not False
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> div 20 3 -- integral division
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> mod 20 3 -- integral division remainder
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> max 4 10
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> min 5 (max 1 2)
<INSERT THE RESULT INSTEAD OF THE TEXT>
>>> max (min 1 10) (min 5 7)
<INSERT THE RESULT INSTEAD OF THE TEXT>
Because Haskell is a __statically-typed__ language, you see an error each time
you try to mix values of different types in situations where you are not
Expand Down Expand Up @@ -604,7 +616,7 @@ You can define multiple functions inside __where__!
Just remember to keep proper indentation.
-}

{-
{- |
=βš”οΈ= Task 9
Implement a function that returns the sum of the last two digits of a number.
Expand All @@ -613,7 +625,7 @@ Implement a function that returns the sum of the last two digits of a number.
6
>>> sumLast2 134
7
>>> sumLast 1
>>> sumLast2 1
1
Try to introduce variables in this task (either with let-in or where) to avoid
Expand Down Expand Up @@ -645,7 +657,7 @@ firstDigit n = error "firstDigit: Not implemented!"


{-
You did it! Now it is time to the open pull request with your changes
You did it! Now it is time to open pull request with your changes
and summon @vrom911 and @chshersh for the review!
-}

Expand Down
23 changes: 12 additions & 11 deletions src/Chapter2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ values of variables you defined before.
Let's talk a bit about list implementation details. Lists in Haskell
are implemented as __linked lists__ (or cons-lists). And because
everything is Haskell is immutable, adding elements at the beginning
everything in Haskell is immutable, adding elements at the beginning
of the lists is cheap. Haskell doesn't need to allocate new memory and
copy the whole list there; it can just create a new list from a new
element and a pointer to an already existing list. In other words,
Expand Down Expand Up @@ -398,13 +398,14 @@ always matches (the same as a variable), but we don't use its value.
πŸ‘©β€πŸ”¬ Unlike 'switch' and 'case' in other languages, that try to go
through each switch and perform all actions in there until it reaches
the breakpoint, 'case' in Haskell always returns only a single
expression for a single branch. You can think of this process as
trying to match all patterns from the first one to the last one and
returning the expression on the right side of "=" only for the pattern
that matches first. This is a helpful thing to keep in mind,
especially when you have overlapping patterns. Also note that, if no
pattern matches the value, the function fails in runtime.
the breakpoint, pattern matching on function parameters in Haskell
always returns only a single expression for a single branch. You can
think of this process as trying to match all patterns from the first
one to the last one and returning the expression on the right side
of "=" only for the pattern that matches first. This is a helpful
thing to keep in mind, especially when you have overlapping patterns.
Also note that, if no pattern matches the value, the function fails
in runtime.
In addition to pattern matching in the function definition, you can
Expand Down Expand Up @@ -651,7 +652,7 @@ the same way as any other values and expressions:
✲ And much more!
The ability to create __lambdas__ (or anonymous functions) nicely
complements the concept of HOF. For example, we can easily append
complements the concept of HOF. For example, we can easily add
number 3 to each element of the list by introducing a lambda function:
>>> map (\x -> x + 3) [0..5]
Expand All @@ -665,7 +666,7 @@ specify space-separated arguments. Instead of the "=" in the ordinary
function body, you should write "->" and then you can use these
arguments and all variables in scope inside the lambda-body.
There are equal:
These are equal:
@
foo a b = a + b
Expand Down Expand Up @@ -861,6 +862,6 @@ rewind = error "rewind: Not Implemented!"


{-
You did it! Now it is time to the open pull request with your changes
You did it! Now it is time to open pull request with your changes
and summon @vrom911 and @chshersh for the review!
-}
Loading

0 comments on commit f7669b8

Please sign in to comment.