From db715ba88c27a735c6eafc51af873eef2fe56d5d Mon Sep 17 00:00:00 2001 From: Laure Retru-Chavastel Date: Wed, 20 Apr 2022 09:05:56 +0200 Subject: [PATCH] Fix typos (#23) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✏️ Fix typos in exo0 * ✏️ Fix typos in exo1 * ✏️ Fix typo in exo2 * ✏️ Fix typo on "Exercise" --- README.md | 8 ++++---- src/exo0/exo0.ts | 13 +++++++------ src/exo1/exo1.ts | 8 ++++---- src/exo2/exo2.ts | 4 ++-- src/exo3/exo3.ts | 4 ++-- src/exo4/exo4.ts | 2 +- src/exo5/exo5.ts | 4 ++-- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 04966cc..36d49c7 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ This repo is a work in progress toward having a comprehensive training material to onboard people on using `fp-ts` efficiently. -The exercices consist of unimplemented functions and their associated failing +The exercises consist of unimplemented functions and their associated failing tests. -But first, it is essential to understand why we are using `fp-ts`. I suggest you read this [article](https://medium.com/inato/our-journey-to-functional-programing-36854a370de1) and then start the exercices. +But first, it is essential to understand why we are using `fp-ts`. I suggest you read this [article](https://medium.com/inato/our-journey-to-functional-programing-36854a370de1) and then start the exercises. To run the tests, simply run @@ -20,14 +20,14 @@ You can also run them in watch mode: $ yarn test:watch ``` -Finally, if you wish to only run the tests for a given exercice `exoN`, you can +Finally, if you wish to only run the tests for a given exercise `exoN`, you can run the following: ```sh $ yarn test[:watch] exoN ``` -The exercices are organized into `exoN` folders and most of what is required to +The exercises are organized into `exoN` folders and most of what is required to complete each is detailed in the comments. ## code style guide diff --git a/src/exo0/exo0.ts b/src/exo0/exo0.ts index 6c7fb58..49cc85a 100644 --- a/src/exo0/exo0.ts +++ b/src/exo0/exo0.ts @@ -8,10 +8,10 @@ // result of the first one to the second one. By applying this composition // over and over you can chain multiple functions together. // -// The `fp-ts` library provides to helpers to do that: +// The `fp-ts` library provides helpers to do that: // - `pipe` which first needs to be fed a value to start the pipe and then // any number of functions to be applied sequentially. -// - `flow` which is the same thing but were we do not have to provide the +// - `flow` which is the same thing but where we do not have to provide the // first value. It will then return a function which will expect that value // to be provided // @@ -55,11 +55,12 @@ export const isOddF: (value: number) => boolean = unimplemented; // // Below is the functional equivalent of the control flow statement if-else. -export const ifThenElse = (onTrue: () => A, onFalse: () => A) => ( - condition: boolean, -) => (condition ? onTrue() : onFalse()); +export const ifThenElse = + (onTrue: () => A, onFalse: () => A) => + (condition: boolean) => + condition ? onTrue() : onFalse(); -// Using `pipe` the function that computes the next step in the Collatz +// Using `pipe`, write the function that computes the next step in the Collatz // sequence. export const next: (value: number) => number = unimplemented; diff --git a/src/exo1/exo1.ts b/src/exo1/exo1.ts index c79e7d6..38cfcff 100644 --- a/src/exo1/exo1.ts +++ b/src/exo1/exo1.ts @@ -1,4 +1,4 @@ -// `fp-ts` training Exercice 1 +// `fp-ts` training Exercise 1 // Basic types: // - Option // - Either @@ -17,7 +17,7 @@ export const divide = (a: number, b: number): number => { // OPTION // /////////////////////////////////////////////////////////////////////////////// -// Write the safe version of `divide` whith signature: +// Write the safe version of `divide` with signature: // safeDivide : (a: number, b: number) => Option // // HINT: Option has two basic contructors: @@ -31,7 +31,7 @@ export const safeDivide: (a: number, b: number) => Option = // EITHER // /////////////////////////////////////////////////////////////////////////////// -// Write the safe version of `divide` whith signature: +// Write the safe version of `divide` with signature: // safeDivideWithError : (a: number, b: number) => Either // // BONUS POINT: Implement `safeDivideWithError` in terms of `safeDivide`. @@ -67,7 +67,7 @@ export const asyncDivide = async (a: number, b: number) => { return a / b; }; -// Write the safe version of `divide` whith signature: +// Write the safe version of `divide` with signature: // asyncSafeDivideWithError : (a: number, b: number) => TaskEither // // HINT: TaskEither has a special constructor to transform a Promise into diff --git a/src/exo2/exo2.ts b/src/exo2/exo2.ts index ffb7842..8ef866d 100644 --- a/src/exo2/exo2.ts +++ b/src/exo2/exo2.ts @@ -1,4 +1,4 @@ -// `fp-ts` training Exercice 2 +// `fp-ts` training Exercise 2 // Let's have fun with combinators! import { Either } from 'fp-ts/Either'; @@ -133,7 +133,7 @@ export const checkTargetAndShoot: ( // OPTION // /////////////////////////////////////////////////////////////////////////////// -// The next three function take a `Character` and optionnaly return the +// The next three function take a `Character` and optionally return the // expected damage type if the unit match the expected character type. // // HINT: These functions represent the public API. But it is heavily diff --git a/src/exo3/exo3.ts b/src/exo3/exo3.ts index 3d38b82..9441381 100644 --- a/src/exo3/exo3.ts +++ b/src/exo3/exo3.ts @@ -1,4 +1,4 @@ -// `fp-ts` training Exercice 3 +// `fp-ts` training Exercise 3 // Sort things out with `Ord` import { Option } from 'fp-ts/Option'; @@ -12,7 +12,7 @@ import { unimplemented } from '../utils'; // The difference with JavaScript's native `Array.prototype` methods is that // these are more `fp-ts` friendly. // -// In the following exercice, we will take a look at `array.sort`. Contrary to +// In the following exercise, we will take a look at `array.sort`. Contrary to // its JavaScript counterpart, `fp-ts` sort takes as an argument something of // type `Ord` where `T` is the type of elements contained in the collection. // diff --git a/src/exo4/exo4.ts b/src/exo4/exo4.ts index 7b1512f..dd78539 100644 --- a/src/exo4/exo4.ts +++ b/src/exo4/exo4.ts @@ -1,4 +1,4 @@ -// `fp-ts` training Exercice 4 +// `fp-ts` training Exercise 4 // Dependency injection with `Reader` import { Reader } from 'fp-ts/Reader'; diff --git a/src/exo5/exo5.ts b/src/exo5/exo5.ts index 21fcf5d..8360723 100644 --- a/src/exo5/exo5.ts +++ b/src/exo5/exo5.ts @@ -1,4 +1,4 @@ -// `fp-ts` training Exercice 5 +// `fp-ts` training Exercise 5 // Managing nested effectful data with `traverse` import { option, readonlyRecord, task } from 'fp-ts'; @@ -224,5 +224,5 @@ export const sequenceOptionArray: ( arrayOfOptions: ReadonlyArray>, ) => Option> = unimplemented; -// BONUS: try using these two functions in the exercices 'TRAVERSING OPTIONS' +// BONUS: try using these two functions in the exercises 'TRAVERSING OPTIONS' // and 'TRAVERSING ARRAYS' above