Skip to content

Commit 15425f1

Browse files
committed
refactor
1 parent de9d3b2 commit 15425f1

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ by the same author (See also https://github.com/MostlyAdequate/mostly-adequate-g
1919

2020

2121
## What makes Prof. Frisby's course and book awesome?
22-
2322
Both course and book amazingly manage to avoid suffering from the two widespread diseases when explaining abstract functional concepts:
2423

2524
- The first disease is to stay with abstract artifically simplified examples that can be easily manipulated
@@ -37,7 +36,6 @@ demonstrating real benefits of the functional abstractions with sharp focus and
3736

3837

3938
## Running Examples
40-
4139
Install the packages with either of
4240
```js
4341
yarn install
@@ -50,5 +48,4 @@ node <file.js>
5048

5149

5250
## Related Projects
53-
5451
- [Monadic Libraries Examples with Tests](https://github.com/dmitriz/monadic-libraries-examples)

examples/22-creed-traversable.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,35 @@ const { runNode, Promise: CreedPromise } = require('creed')
1111

1212
// readFilePromise :: String -> String -> Promise Error Buffer
1313
const readFilePromise = (fileName, encoding = 'utf-8') =>
14-
runNode(fs.readFile, fileName, {encoding})
14+
runNode(fs.readFile, fileName, {encoding})
1515

1616
// wrap into List that provides 'traverse'
1717
const files = List(['file1.txt', 'file2.txt'])
1818

1919
console.log(
2020
`Running...
2121
List(['file1.txt', 'file2.txt'])
22-
.traverse( CreedPromise.of, readFilePromise )
23-
.then( console.log, console.error ) :
22+
.traverse( CreedPromise.of, readFilePromise )
23+
.then( console.log, console.error ) :
2424
`
2525
)
2626

2727
/*
28-
'files' is List of files 'List(a)'
29-
'map' preserves the List wrapper, so we can get 'List(Promise(a))'
30-
'traverse' applies the function (a -> f b) to each List entry,
31-
then lifts the List to Promise of Lists via CreedPromise's 'ap' operator
32-
running Promises in parallel!
28+
'files' is List of files 'List(a)'
29+
'map' preserves the List wrapper, so we can get 'List(Promise(a))'
30+
'traverse' applies the function (a -> f b) to each List entry,
31+
then lifts the List to Promise of Lists via CreedPromise's 'ap' operator
32+
running Promises in parallel!
3333
*/
3434

3535
files
3636
.traverse(
3737

38-
// type hint, applicative functor
39-
// needed in case of failure or never running the function
40-
CreedPromise.of,
38+
// type hint, applicative functor
39+
// needed in case of failure or never running the function
40+
CreedPromise.of,
4141

42-
// traversing function a -> f b
43-
file => readFilePromise(file)
42+
// traversing function a -> f b
43+
file => readFilePromise(file)
4444
)
4545
.then( console.log, console.error )

examples/coyoneda.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,22 @@ console.log("Set([1, 1, 2, 3, 3, 4]) : ", set)
3333

3434

3535
// Wrap set into Coyoneda with 'id' function
36-
const coyo_result = Coyoneda.lift(set)
36+
const coyoResult = Coyoneda.lift(set)
3737
.map(x => x + 1)
3838
.map(x => `${x}!`)
3939

4040
console.log(
4141
"Coyoneda.lift(set).map(x => x + 1).map(x => `${x}!`): ",
42-
coyo_result
42+
coyoResult
4343
)
4444

4545

46-
// equivalent to buildUpFn = coyo_result.f, our_set = coyo_result.x
47-
const {f: builtUpFn, x: our_set} = coyo_result
46+
// equivalent to buildUpFn = coyoResult.f, ourSet = coyoResult.x
47+
const {f: builtUpFn, x: ourSet} = coyoResult
4848

49-
console.log("builtUpFn is: ", builtUpFn, "; our_set is: ", our_set)
49+
console.log("builtUpFn is: ", builtUpFn, "; ourSet is: ", ourSet)
5050

51-
our_set
51+
ourSet
5252
.forEach(n => console.log(builtUpFn(n)))
5353
// 2!
5454
// 3!

0 commit comments

Comments
 (0)