Skip to content

Commit e43a472

Browse files
committed
move support module into its own directory
1 parent 56fcd5f commit e43a472

File tree

9 files changed

+153
-12
lines changed

9 files changed

+153
-12
lines changed

ch04.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ What's demonstrated here is the ability to "pre-load" a function with an argumen
5353

5454
I encourage you to clone the Mostly Adequate repository (`git clone
5555
https://github.com/MostlyAdequate/mostly-adequate-guide.git`), copy the code above and have a
56-
go at it in the REPL. The curry function (and actually anything defined in the appendixes) has
57-
been made available from the `exercises/support.js` module.
56+
go at it in the REPL. The curry function, as well as actually anything defined in the appendixes,
57+
are available in the `support/index.js` module.
58+
59+
Alternatively, have a look at a published version on `npm`:
60+
61+
```
62+
npm install @mostly-adequate/support
63+
```
5864

5965
## More Than a Pun / Special Sauce
6066

exercises/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Mostly Adequate Exercises
2+
3+
## Overview
4+
5+
All exercises from the book can be completed either:
6+
7+
- in browser (using the version of the book published on [gitbook.io](https://mostly-adequate.gitbooks.io/mostly-adequate-guide/))
8+
- in your editor & terminal, using `npm`
9+
10+
In every folder named `ch**` from this `exercises/` folder, you'll find three types of files:
11+
12+
- exercises
13+
- solutions
14+
- validations
15+
16+
Exercises are structured with a statement in comment, followed by an incomplete
17+
or incorrect function. For example, `exercise_a` from `ch04` looks like this:
18+
19+
20+
```js
21+
// Refactor to remove all arguments by partially applying the function.
22+
23+
// words :: String -> [String]
24+
const words = str => split(' ', str);
25+
```
26+
27+
Following the statement, your goal is to refactor the given function `words`. Once done,
28+
your proposal can be verified by running:
29+
30+
```
31+
npm run ch04
32+
```
33+
34+
Alternatively, you can also have a peak at the corresponding solution file: in this case
35+
`solution_a.js`.
36+
37+
> The files `validation_*.js` aren't really part of the exercises but are used
38+
> internally to verify your proposal and, offer hints when adequate. The curious
39+
> reader may have a look at them :).
40+
41+
Now go and learn some functional programming λ!
42+
43+
## About the Appendixes
44+
45+
Important notice: the exercise runner takes care of bringing all
46+
data-structures and functions from the appendixes into scope. Therefore, you
47+
may assume that any function present in the appendix is just available for you
48+
to use! Amazing, isn't it?

exercises/package.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"name": "@mostly-adequate/support",
3-
"version": "1.1.0",
4-
"description": "Support functions and data-structures from the Mostly Adequate Guide to Functional Programming",
2+
"name": "@mostly-adequate/exercises",
3+
"version": "1.0.0",
4+
"description": "Exercises coming with the Mostly Adequate Guide to Functional Programming",
55
"license": "MIT",
6-
"main": "index.js",
76
"repository": {
87
"type": "git",
98
"url": "https://github.com/MostlyAdequate/mostly-adequate-guide"
@@ -13,12 +12,6 @@
1312
"url": "https://github.com/MostlyAdequate/mostly-adequate-guide/issues"
1413
},
1514
"homepage": "https://github.com/MostlyAdequate/mostly-adequate-guide",
16-
"keywords": [
17-
"functional programming",
18-
"mostly adequate",
19-
"guide",
20-
"fp"
21-
],
2215
"dependencies": {},
2316
"devDependencies": {
2417
"cli": "^1.0.1",

support/.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const globals = Object
2+
.keys(require('./support'))
3+
.reduce((o, k) => ({ ...o, [k]: true }), { requirejs: true, assert: true });
4+
5+
module.exports = {
6+
extends: 'airbnb',
7+
env: {
8+
browser: true,
9+
amd: true,
10+
},
11+
globals,
12+
rules: {
13+
'import/no-amd': 0,
14+
'import/no-dynamic-require': 0,
15+
'no-unused-vars': 0,
16+
'object-curly-newline': [2, {
17+
multiline: true,
18+
consistent: true,
19+
minProperties: 5,
20+
}],
21+
},
22+
};
File renamed without changes.

support/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Mostly Adequate Guide to Functional Programming - Support
2+
3+
## Overview
4+
5+
This package contains all functions and data-structure referenced in the
6+
appendixes of the [Mostly Adequate Guide to Functional Programming](https://github.com/MostlyAdequate/mostly-adequate-guide).
7+
8+
These functions have an educational purpose and aren't intended to be used in
9+
any production environment. They are however, a good learning material for anyone
10+
interested in functional programming.
11+
12+
## How to install
13+
14+
The package is available on `npm` and can be installed via the following incantation:
15+
16+
```
17+
npm install @mostly-adequate/support
18+
```
19+
20+
## How to use
21+
22+
There's no particular structure to the module, everything is flat and exported
23+
from the root (the curious reader may have a quick glance at the `index.js` to
24+
get convinced about this).
25+
26+
Also, all top-level functions are curried so you don't have to worry about calling
27+
`curry` on any of them.
28+
29+
For example:
30+
31+
```js
32+
const { Maybe, liftA2, append, concat, reverse } = require('@mostly-adequate/support');
33+
34+
const a = Maybe.of("yltsoM").map(reverse);
35+
const b = Maybe.of("Adequate").map(concat(" "));
36+
37+
liftA2(append)(b)(a);
38+
// Just("Mostly Adequate")
39+
```
File renamed without changes.
File renamed without changes.

support/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@mostly-adequate/support",
3+
"version": "1.2.0",
4+
"description": "Support functions and data-structures from the Mostly Adequate Guide to Functional Programming",
5+
"license": "MIT",
6+
"main": "index.js",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/MostlyAdequate/mostly-adequate-guide"
10+
},
11+
"author": "@mostly-adequate",
12+
"bugs": {
13+
"url": "https://github.com/MostlyAdequate/mostly-adequate-guide/issues"
14+
},
15+
"homepage": "https://github.com/MostlyAdequate/mostly-adequate-guide/support",
16+
"keywords": [
17+
"functional programming",
18+
"mostly adequate",
19+
"guide",
20+
"fp"
21+
],
22+
"dependencies": {},
23+
"devDependencies": {
24+
"eslint": "^5.9.0",
25+
"eslint-config-airbnb": "^16.1.0",
26+
"eslint-plugin-import": "^2.8.0",
27+
"eslint-plugin-jsx-a11y": "^6.0.2",
28+
"eslint-plugin-react": "^7.5.1"
29+
},
30+
"scripts": {
31+
"lint": "eslint ."
32+
}
33+
}

0 commit comments

Comments
 (0)