Skip to content
Mostly adequate guide to FP (in javascript)
JavaScript Other
Branch: master
Clone or download
KtorZ Merge pull request #549 from bouzlibop/patch-1
Fix compose type signature
Latest commit e03775c Jan 3, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
exercises remove now deprecated hint Jan 3, 2020
images Merge remote-tracking branch 'mostly-adequate/master' into es6/es7 Jan 3, 2018
styles Bug: With sepia the links are not highlighted Jan 17, 2018
support bump support version to 2.0.1 Jun 26, 2019
.editorconfig add .editorconfig 👍 Feb 9, 2018
.generate-summary.pl use perl from package.json script to call generate-summary rather tha… Feb 10, 2018
.gitignore remove package-lock.json files May 24, 2019
CONTRIBUTING.md Fix link to LICENSE - it's not .md Mar 2, 2018
FAQ.md update links Jan 2, 2019
LICENSE review package.json(s) and README Dec 31, 2017
README.md Add a few words about the exercises and the npm module Dec 1, 2018
SUMMARY.md Added missing link to append Dec 11, 2019
TRANSLATIONS.md add link to Indonesian translation Feb 25, 2018
appendix_a.md Fix compose type signature Dec 28, 2019
appendix_b.md add missing 'return' statement for 'sequence' in Maybe structure Jun 26, 2019
appendix_c.md update styleguide violations in appendixes & index May 5, 2019
book.json Use ”cover” property in book.json for the cover image Jun 27, 2018
ch01.md Changed the text flock_a to flockA to match the code Apr 12, 2018
ch02.md Unify the headings capitalisation Feb 12, 2018
ch03.md ch03.md: update ringer to wringer Dec 18, 2019
ch04.md move support module into its own directory May 5, 2019
ch05.md Merge pull request #540 from andyfleming/patch-1 Jan 3, 2020
ch06.md update links Jan 2, 2019
ch07.md Fix minor typo with comma Aug 13, 2019
ch08.md Merge pull request #534 from hasparus/patch-1 Jan 3, 2020
ch09.md ch09: update markdown to reflect implementation Jun 25, 2019
ch10.md update links Jan 2, 2019
ch11.md update links Jan 2, 2019
ch12.md ch12: fix exercises Feb 19, 2019
package.json fix security vulnerability in dependencies May 24, 2019

README.md

cover

About this book

This is a book on the functional paradigm in general. We'll use the world's most popular functional programming language: JavaScript. Some may feel this is a poor choice as it's against the grain of the current culture which, at the moment, feels predominately imperative. However, I believe it is the best way to learn FP for several reasons:

  • You likely use it every day at work.

    This makes it possible to practice and apply your acquired knowledge each day on real world programs rather than pet projects on nights and weekends in an esoteric FP language.

  • We don't have to learn everything up front to start writing programs.

    In a pure functional language, you cannot log a variable or read a DOM node without using monads. Here we can cheat a little as we learn to purify our codebase. It's also easier to get started in this language since it's mixed paradigm and you can fall back on your current practices while there are gaps in your knowledge.

  • The language is fully capable of writing top notch functional code.

    We have all the features we need to mimic a language like Scala or Haskell with the help of a tiny library or two. Object-oriented programming currently dominates the industry, but it's clearly awkward in JavaScript. It's akin to camping off of a highway or tap dancing in galoshes. We have to bind all over the place lest this change out from under us, we have various work arounds for the quirky behavior when the new keyword is forgotten, private members are only available via closures. To a lot of us, FP feels more natural anyways.

That said, typed functional languages will, without a doubt, be the best place to code in the style presented by this book. JavaScript will be our means of learning a paradigm, where you apply it is up to you. Luckily, the interfaces are mathematical and, as such, ubiquitous. You'll find yourself at home with Swiftz, Scalaz, Haskell, PureScript, and other mathematically inclined environments.

Read it Online

For a best reading experience, read it online via Gitbook.

  • Quick-access side-bar
  • In-browser exercises
  • In-depth examples

Play Around with Code

To make the training efficient and not get too bored while I am telling you another story, make sure to play around with the concepts introduced in this book. Some can be tricky to catch at first and are better understood by getting your hand dirty. All functions and algebraic data-structures presented in the book are gathered in the appendixes. The corresponding code is also available as an npm module:

$ npm i @mostly-adequate/support

Alternatively, exercises of each chapter are runnable and can be completed in your editor! For example, complete the exercise_*.js in exercises/ch04 and then run:

$ npm run ch04

Download it

Do it yourself

git clone https://github.com/MostlyAdequate/mostly-adequate-guide.git
cd mostly-adequate-guide/
npm install
npm run setup
npm run generate-pdf
npm run generate-epub

Note! To generate the ebook version you will need to install ebook-convert. Installation instructions.

Table of Contents

See SUMMARY.md

Contributing

See CONTRIBUTING.md

Translations

See TRANSLATIONS.md

FAQ

See FAQ.md

Plans for the future

  • Part 1 (chapters 1-7) is a guide to the basics. I'm updating as I find errors since this is the initial draft. Feel free to help!
  • Part 2 (chapters 8-13) address type classes like functors and monads all the way through to traversable. I hope to squeeze in transformers and a pure application.
  • Part 3 (chapters 14+) will start to dance the fine line between practical programming and academic absurdity. We'll look at comonads, f-algebras, free monads, yoneda, and other categorical constructs.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

You can’t perform that action at this time.