Skip to content

Commit 0fc59ba

Browse files
vpyshnenkolnewson
andauthored
Fix some typos (#3)
* separate interface entries with semicolon * mistype trueIfSome * generic expected after func name * export toPositiveInteger for testing purpose * mix up 'constant' function typings' * without webpack config default entry point src/index.js * update constant function type in comments * grammar fix Co-authored-by: Lee Newson <[email protected]> * remove non-relevant comment block Co-authored-by: Lee Newson <[email protected]>
1 parent b5d57f7 commit 0fc59ba

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Dummy entry point for webpack.

src/main/ts/Part2Ex2ArrayFunctions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Let's set up some dummy test data to talk about frogs, and write some code about
2727
*/
2828

2929
export interface Frog {
30-
readonly name: string,
31-
readonly ribbits: boolean,
32-
readonly age: number
30+
readonly name: string;
31+
readonly ribbits: boolean;
32+
readonly age: number;
3333
}
3434

3535
export const myFrogs: Frog[] = [
@@ -61,7 +61,7 @@ export const runMap1 = (xs: number[]): number[] =>
6161

6262
// prepend a string to each element
6363
export const runMap2 = (xs: number[]): string[] =>
64-
Arr.map(xs, (x) => "the number is " + 1);
64+
Arr.map(xs, (x) => "the number is " + x);
6565

6666
// TODO: Return the frog's names and check it by running
6767
// yarn bedrock-auto -b chrome-headless -f src/test/ts/Exercise2ArrayFunctionsTest.ts

src/main/ts/Part2Ex3Optional.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const parseIntOpt = (s: string): Optional<number> => {
3232
return Number.isNaN(n) ? Optional.some(n) : Optional.none();
3333
};
3434

35-
const toPositiveInteger = (n: number): Optional<number> =>
35+
export const toPositiveInteger = (n: number): Optional<number> =>
3636
n > 0 ? Optional.some(n) : Optional.none();
3737

3838
// TODO: create a function which takes a string and returns some if the string is non-empty
@@ -83,7 +83,7 @@ export const message = (e: Optional<string>): string =>
8383
// TODO: Implement a function using fold, that takes an Optional<number>. If it's some, double it. If it's none, return 0;
8484

8585
// TODO: Implement a function that takes an Optional<T> for any type T. Return true if it's some, and false if it's none.
86-
const trueIfSome = <T> (x: T): Optional<T> => {
86+
const trueIfSome = <T> (x: Optional<T>): boolean => {
8787
throw new Error("TODO");
8888
};
8989

@@ -147,7 +147,7 @@ Some examples, then some exercises:
147147

148148
const x: Optional<string> = Optional.some(3).map((x) => String(x)); // returns Optional.some("3")
149149

150-
const y: Optional<string> = Optional.none<number>().map((x) => String(x)); // returns Optional.<string>none()
150+
const y: Optional<string> = Optional.none<number>().map((x) => String(x)); // returns Optional.none<string>()
151151

152152
// TODO: Write a function that takes an Optional<number> and adds 3 to the number
153153

src/main/ts/Part2Ex4FP.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const constant = <A> (a: A) => (...args: unknown[]): A => a;
143143
const always3 = constant(3);
144144

145145
/*
146-
So, constant ignores whatever is passed for the B parameter, and just returns the A.
146+
So, constant ignores whatever is passed for input parameters, and just returns the A.
147147
148148
Again, this looks familiar from our getOrElse1 function above.
149149
@@ -152,15 +152,7 @@ TODO: rewrite getOrElse1 using both Fun.identity and the "constant" function def
152152

153153

154154
/*
155-
Now, katamari's Fun.constant is slightly different to ours above:
156-
157-
const constant = <A, B> (a: A) => (b: B) => a; // ours
158-
const constant = <A> (a: A) => () => a; // katamari's
159-
160-
In most languages, this would be make the two incompatible. However, TypeScript is a bit more lenient and lets us
161-
use the second form everywhere the first form is expected.
162-
163-
TODO: don't just take my word for it - use katamari's Fun.constant in you getOrElse and see if it compiles.
155+
TODO: use katamari's Fun.constant in your getOrElse and see if it compiles.
164156
*/
165157

166158
// TODO: Write a function that takes an array of numbers and replaces each value with 9.
@@ -222,4 +214,3 @@ signature and handling for n-ary functions. Your rule-of-thumb is to use Fun.com
222214
// TODO: Rewrite this function to use a single map call and function composition
223215
const dblOs = (oa: Optional<number>): Optional<string> =>
224216
oa.map(dbl).map(String);
225-

src/main/ts/Webpack.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)