refactor: Major simplification in providing implementation types (#2)
This PR is an effort to address #1. It removes all boilerplate from individual implementation files, and moves it into a small, fixed section in the single `all.ts` module for each type that collects up all of the implementations relating to that type. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: #2
This commit is contained in:
parent
29bcab1639
commit
3fa216d1f4
6 changed files with 25 additions and 20 deletions
|
@ -1 +1,8 @@
|
|||
export * as Complex from './native.js'
|
||||
import {ForType} from '../core/Dispatcher.js'
|
||||
import * as Complex from './native.js'
|
||||
|
||||
export {Complex}
|
||||
|
||||
declare module "../core/Dispatcher" {
|
||||
interface ImplementationTypes extends ForType<'Complex', typeof Complex> {}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/// <reference path="../numbers/type.ts">
|
||||
import {joinTypes, typeOfDependency, Dependency} from '../core/Dispatcher.js'
|
||||
|
||||
export type Complex<T> = {re: T; im: T;}
|
||||
|
@ -18,13 +17,6 @@ export const Complex_type = {
|
|||
}
|
||||
}
|
||||
|
||||
export const complex_1 = <T>(dep: Dependency<'zero', [T]>) =>
|
||||
export const complex_unary = <T>(dep: Dependency<'zero', [T]>) =>
|
||||
(t: T) => ({re: t, im: dep.zero(t)})
|
||||
export const complex_2 = <T>(t: T, u: T) => ({re: t, im: u})
|
||||
|
||||
declare module "../core/Dispatcher" {
|
||||
interface ImplementationTypes {
|
||||
complex_1_Complex: typeof complex_1
|
||||
complex_2_Complex: typeof complex_2
|
||||
}
|
||||
}
|
||||
export const complex_binary = <T>(t: T, u: T) => ({re: t, im: u})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue