From c65559872b7509e07efea9ebcc9e94dfb61cb08e Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 11 Oct 2022 01:51:17 -0400 Subject: [PATCH 1/2] backend: add missing return type annotation in array.ts --- packages/backend/src/prelude/array.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/prelude/array.ts b/packages/backend/src/prelude/array.ts index 0b2830cb7..4e2088e72 100644 --- a/packages/backend/src/prelude/array.ts +++ b/packages/backend/src/prelude/array.ts @@ -84,7 +84,7 @@ export function groupOn(f: (x: T) => S, xs: T[]): T[][] { return groupBy((a, b) => f(a) === f(b), xs); } -export function groupByX(collections: T[], keySelector: (x: T) => string) { +export function groupByX(collections: T[], keySelector: (x: T) => string): Record { return collections.reduce((obj: Record, item: T) => { const key = keySelector(item); if (!Object.prototype.hasOwnProperty.call(obj, key)) { From 683b0cfa8270cb972bc0fede7c4106b49e921a63 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Tue, 11 Oct 2022 01:53:34 -0400 Subject: [PATCH 2/2] backend: remove unused prelude modules Much of these modules are no longer used in the backend. They seem to be from before the code was organized in packages. --- packages/backend/src/prelude/math.ts | 3 --- packages/backend/src/prelude/maybe.ts | 20 -------------------- packages/backend/src/prelude/string.ts | 15 --------------- packages/backend/test/prelude/maybe.ts | 18 ------------------ 4 files changed, 56 deletions(-) delete mode 100644 packages/backend/src/prelude/math.ts delete mode 100644 packages/backend/src/prelude/maybe.ts delete mode 100644 packages/backend/src/prelude/string.ts delete mode 100644 packages/backend/test/prelude/maybe.ts diff --git a/packages/backend/src/prelude/math.ts b/packages/backend/src/prelude/math.ts deleted file mode 100644 index 07b94bec3..000000000 --- a/packages/backend/src/prelude/math.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function gcd(a: number, b: number): number { - return b === 0 ? a : gcd(b, a % b); -} diff --git a/packages/backend/src/prelude/maybe.ts b/packages/backend/src/prelude/maybe.ts deleted file mode 100644 index df7c4ed52..000000000 --- a/packages/backend/src/prelude/maybe.ts +++ /dev/null @@ -1,20 +0,0 @@ -export interface IMaybe { - isJust(): this is IJust; -} - -export interface IJust extends IMaybe { - get(): T; -} - -export function just(value: T): IJust { - return { - isJust: () => true, - get: () => value, - }; -} - -export function nothing(): IMaybe { - return { - isJust: () => false, - }; -} diff --git a/packages/backend/src/prelude/string.ts b/packages/backend/src/prelude/string.ts deleted file mode 100644 index b907e0a2e..000000000 --- a/packages/backend/src/prelude/string.ts +++ /dev/null @@ -1,15 +0,0 @@ -export function concat(xs: string[]): string { - return xs.join(''); -} - -export function capitalize(s: string): string { - return toUpperCase(s.charAt(0)) + toLowerCase(s.slice(1)); -} - -export function toUpperCase(s: string): string { - return s.toUpperCase(); -} - -export function toLowerCase(s: string): string { - return s.toLowerCase(); -} diff --git a/packages/backend/test/prelude/maybe.ts b/packages/backend/test/prelude/maybe.ts deleted file mode 100644 index 0f4b00065..000000000 --- a/packages/backend/test/prelude/maybe.ts +++ /dev/null @@ -1,18 +0,0 @@ -import * as assert from 'assert'; -import { just, nothing } from '../../src/prelude/maybe.js'; - -describe('just', () => { - it('has a value', () => { - assert.deepStrictEqual(just(3).isJust(), true); - }); - - it('has the inverse called get', () => { - assert.deepStrictEqual(just(3).get(), 3); - }); -}); - -describe('nothing', () => { - it('has no value', () => { - assert.deepStrictEqual(nothing().isJust(), false); - }); -});