diff --git a/src/exo0/exo0.ts b/src/exo0/exo0.ts index 7a7fc7c..dab5136 100644 --- a/src/exo0/exo0.ts +++ b/src/exo0/exo0.ts @@ -2,7 +2,7 @@ // Composing computations with `pipe` and `flow` // Functional programming is all about composing small functions together like -// lego bricks to build more and more complex computations. +// Lego bricks to build more and more complex computations. // // Strictly speaking, composing two functions `f` and `g` means applying the // result of the first one to the second one. By applying this composition diff --git a/src/exo1/exo1.ts b/src/exo1/exo1.ts index 08ec470..9278168 100644 --- a/src/exo1/exo1.ts +++ b/src/exo1/exo1.ts @@ -20,24 +20,22 @@ export const divide = (a: number, b: number): number => { // Write the safe version (meaning it handles the case where b is 0) of `divide` with signature: // safeDivide : (a: number, b: number) => Option // -// HINT: Option has two basic contructors: +// HINT: Option has two basic constructors: // - `option.some(value)` // - `option.none` export const safeDivide: (a: number, b: number) => Option = unimplemented; - // You probably wrote `safeDivide` using `if` statements and it's perfectly valid! // There are ways to not use `if` statements. -// Keep in mind that extracting small functions out of pipes and using `if` statements in them +// Keep in mind that extracting small functions out of pipes and using `if` statements in them // is perfectly fine and is sometimes more readable than not using `if`. // // BONUS: Try now to re-write `safeDivide` without any `if` // // HINT: Have a look at `fromPredicate` constructor - /////////////////////////////////////////////////////////////////////////////// // EITHER // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/exo2/exo2.ts b/src/exo2/exo2.ts index 9624614..b6cd038 100644 --- a/src/exo2/exo2.ts +++ b/src/exo2/exo2.ts @@ -10,7 +10,7 @@ import { unimplemented } from '../utils'; // SETUP // /////////////////////////////////////////////////////////////////////////////// -// We are developping a small game, and the player can control either one of +// We are developing a small game, and the player can control either one of // three types of characters, mainly differentiated by the type of damage they // can put out. @@ -133,7 +133,7 @@ export const checkTargetAndShoot: ( // OPTION // /////////////////////////////////////////////////////////////////////////////// -// The next three function take a `Character` and optionally return the +// The next three functions take a `Character` and optionally return the // expected damage type if the unit matches the expected character type. // // HINT: These functions represent the public API. But it is heavily diff --git a/src/exo5/exo5.ts b/src/exo5/exo5.ts index 7527eb3..36619ea 100644 --- a/src/exo5/exo5.ts +++ b/src/exo5/exo5.ts @@ -76,6 +76,7 @@ export const naiveGiveCurrencyOfCountryToUser = ( task.map(getCountryCode), task.map(option.map(getCountryCurrency)), ); + // The result type of this method is: `Task>>` // Not ideal, right? We would need to await the first `Task`, then check if it's // `Some` to get the `Task` inside and finally await the `Task` to retrieve the @@ -103,7 +104,7 @@ export const getCountryCurrencyOfOptionalCountryCode: ( // `Task>` // // HINT: You should be able to copy the pipe from naiveGiveCurrencyOfCountryToUser -// and make only few updates of it. `task.chain` helper may be usefull. +// and make only few updates of it. The `task.chain` helper may be useful. export const giveCurrencyOfCountryToUser: ( countryNameFromUserMock: string, @@ -123,6 +124,7 @@ export const giveCurrencyOfCountryToUser: ( export const getCountryCodeOfCountryNames = ( countryNames: ReadonlyArray, ) => countryNames.map(getCountryCode); + // As expected, we end up with a `ReadonlyArray>`. We know for // each item of the array if we have been able to find the corresponding country // code or not. @@ -134,7 +136,7 @@ export const getCountryCodeOfCountryNames = ( // Doing this allows you to stop the process if you have a `None` to tell the user // that some countries are not valid or move on with a `ReadonlyArray>` // if all are valid. -// Typewise, it means going from `ReadonlyArray>` to +// Type-wise, it means going from `ReadonlyArray>` to // `Option>` // This is what traversing array is about. @@ -208,7 +210,7 @@ export const performAsyncComputationInSequence: ( // `Option` in our example) // Sometimes, you just have two nested containers that you want to 'invert'. It // can be because the order of containers is meaningful (like `Either