From 22f114d7f939018328bc13d42e3aa5e37ea0581b Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Thu, 22 Dec 2022 15:04:12 +0100 Subject: [PATCH] feat: implement generic square (WIP) --- src/generic/all.ts | 10 ++++++++++ src/generic/arithmetic.ts | 17 +++++++++++++++++ src/generic/type.ts | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 src/generic/all.ts create mode 100644 src/generic/arithmetic.ts create mode 100644 src/generic/type.ts diff --git a/src/generic/all.ts b/src/generic/all.ts new file mode 100644 index 0000000..40a35e4 --- /dev/null +++ b/src/generic/all.ts @@ -0,0 +1,10 @@ +import { ForType } from '../core/Dispatcher.js' +import { GenericReturn } from './type.js' +import * as generic from './arithmetic.js' + +export { generic } + +declare module "../core/Dispatcher" { + interface ReturnTypes + extends ForType<'numbers', GenericReturn> { } +} diff --git a/src/generic/arithmetic.ts b/src/generic/arithmetic.ts new file mode 100644 index 0000000..5cb4801 --- /dev/null +++ b/src/generic/arithmetic.ts @@ -0,0 +1,17 @@ +import { ConservativeUnary, Dependency, ImpType, Signature } from "../core/Dispatcher"; + +declare module "./type" { + interface GenericReturn { + // Jos: not sure how to define this or why it is needed + square: Signature + // square: ConservativeUnary + // square: Params extends [infer R] + // ? R extends number ? UnderlyingReal : never + // : never + } +} + +export const square = + (dep: Dependency<'multiply', [T, T]>): + ImpType<'square', [T]> => + z => dep.multiply(z, z) diff --git a/src/generic/type.ts b/src/generic/type.ts new file mode 100644 index 0000000..8589417 --- /dev/null +++ b/src/generic/type.ts @@ -0,0 +1,3 @@ +export interface GenericReturn { + +} \ No newline at end of file