Exercises and notes from Functional Programming in Scala translated to TypeScript.
This repository is essentially split into two halves. One half generates the website containing the notes, and one half contains TypeScript code illustrating the notes. So there are two directories at the top level:
site/
- source files for the VuePress-powered notes websitecode/
- runnable examples and rudimentary FP library in TypeScript
There is a third top-level directory, docs/
, which contains the output of running VuePress on the sources in site/
.
The docs/
directory is required by GitHub pages, on which the site is hosted.
- Install the version of node specified in
/code/.node-version
(10.6.0 as of this writing). On a Mac, using nodenv, do:$ brew update $ brew upgrade node-build $ nodenv install 10.6.0
cd code/
and install dependencies:$ npm install
- Run the TypeScript REPL...
$ npm run console > [email protected] console ~/code/fp_book_club_ts > ts-node > console.log("Hi there!"); Hi there! undefined >
- ...Or run the tests...
$ npm test > [email protected] test ~/code/fp_book_club_ts > jest PASS libfpts/intro/cafe.test.ts ✓ returns a Coffee (51ms) console.log libfpts/intro/impure_example.ts:13 Side effect! Charging the credit card... Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 0.896s, estimated 1s
- ...Or run the affected tests on every file change...
$ npm run test:watch
- ...Or run all the tests on every file change...
$ npm run test:watchAll
We use Jest as our test framework, via ts-jest. In addition to the top-level scripts listed above,
you can invoke Jest with arbitrary arguments with npm test -- [--jestArg1 --jestArg2 ...]
. To see everything Jest can
do for you, run npm test -- --help
.
The notes, under site/src
, are meant to be deployed using GitHub Pages. We use VuePress to
write the notes in Markdown and render them to plain old HTML.
To update the notes:
cd site/
and runnpm run docs:dev
, and point your browser to the address displayed by VuePress, which is likely http://localhost:8080.- Edit the source files in
site/src/
, proofreading as you go in the browser. - When you're done, run
npm run docs:build
, which will output the static site contents intosite/out/
. cd ../
to return to the project root director, and runnpm pages:cp
to copy the static site content intodocs/
, as required by GitHub Pages. Commit all the changes under bothsite/src/
anddocs/
, merge to master if necessary, and push.- GitHub looks for changes to the static site assets under
docs/
. If it finds changes, it redeployes the site at http://calebharris.github.io/fp_book_club_ts.