Skip to content

manuscriptmastr/fp-workshop

Repository files navigation

🤓 Functional Programming Workshop

⚠️ WARNING: ⚠️ Please do not look at the /solutions directory before attempting the recipes yourself. The forest comes before the machete.

💾 Installation

  1. Download repo
git clone git@github.com:manuscriptmastr/fp-workshop.git
cd fp-workshop
  1. Install Node 14 (this package uses modules)
nvm install 14
nvm use 14
  1. Install package dependencies
npm install

⌨️ Scripts

# Run test suite
npm run test

# Run only contents of playground.js
npm run playground

🧪 Experiment

playground.js is just a blank "notepad" for you can follow along the workshop or jot down ideas/experiments. You can execute it with npm run playground.

🏃 Practice

To practice a recipe, navigate to {recipe}/index.test.js and replace the line import {recipe} from '../solutions/{recipe}' with import {recipe} from '.' Run npm run test and tests should fail. Define your recipe in {recipe}/index.js until all tests pass!

If you get stumped, you can always refer to solutions/{recipe}.js. But who does that help 🤷‍♂️?

ℹ️ Library Documentation

  • Ramda is an auto-curried utility library
  • Sanctuary is another FP utility library (stricter than Ramda) that includes containers like Maybe and Either
  • Assert is a super chill testing library built into Node.js
  • AVA is a highly explicit and concurrent testing framework
  • Nock is a sweet library for mocking highly specific HTTP responses

❓ FAQ

  • What's with comments like add :: Number -> Number -> Number?
    • This is a style of writing type signatures widely adopted in the functional programming community. Don't worry if it looks bizarre now — we'll see this syntax many, many times!
  • An example or test is incorrect.
    • Submit an issue so we can keep this workbook up to date for posterity!
  • How do I slowly build my containers without having all these failing tests?
    • In ava.config.js, uncomment all but the container method(s) you're testing. For instance, if you're trying to make Identity pass the Functor tests, you will leave only !*.map* commented out. Restart npm run test and it will pick up only tests that call SomeContainer.map(...).

😍 More FP please!

About

Workbook for the Functional Programming Workshop

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published