feat: implement generic square (WIP)
This commit is contained in:
parent
9aec1bca17
commit
22f114d7f9
10
src/generic/all.ts
Normal file
10
src/generic/all.ts
Normal file
@ -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<Params>
|
||||||
|
extends ForType<'numbers', GenericReturn<Params>> { }
|
||||||
|
}
|
17
src/generic/arithmetic.ts
Normal file
17
src/generic/arithmetic.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { ConservativeUnary, Dependency, ImpType, Signature } from "../core/Dispatcher";
|
||||||
|
|
||||||
|
declare module "./type" {
|
||||||
|
interface GenericReturn<Params> {
|
||||||
|
// Jos: not sure how to define this or why it is needed
|
||||||
|
square: Signature<Params, [T], T>
|
||||||
|
// square: ConservativeUnary<Params, T>
|
||||||
|
// square: Params extends [infer R]
|
||||||
|
// ? R extends number ? UnderlyingReal<R> : never
|
||||||
|
// : never
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const square =
|
||||||
|
<T>(dep: Dependency<'multiply', [T, T]>):
|
||||||
|
ImpType<'square', [T]> =>
|
||||||
|
z => dep.multiply(z, z)
|
3
src/generic/type.ts
Normal file
3
src/generic/type.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export interface GenericReturn<Params> {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user