feat: add more type functions (FAIL: type recursion)

This commit is contained in:
Glen Whitney 2022-12-27 11:09:30 -05:00
parent 40d05045fc
commit fafc747be5
2 changed files with 13 additions and 2 deletions

View File

@ -20,5 +20,13 @@ export const Complex_type = {
export const typeImps = <T>() => ({
complex_unary: (dep: Dependency<'zero', [T]>) =>
(t: T) => ({re: t, im: dep.zero(t)}),
complex_binary: (t: T, u: T) => ({re: t, im: u})
complex_binary: (t: T, u: T) => ({re: t, im: u}),
zero: (dep: Dependency<'zero', [T]>) =>
(z: Complex<T>) => ({re: dep.zero(z.re), im: dep.zero(z.im)}),
one: (dep: Dependency<'zero' | 'one', [T]>) =>
(z: Complex<T>) => ({re: dep.one(z.re), re: dep.zero(z.im)}),
nan: (dep: Dependency<'nan', [T]>) =>
(z: Complex<T>) => ({re: dep.nan(z.re), im: dep.nan(z.im)}),
re: (dep: Dependency<'re', [T]>) =>
(z: Complex<T>) => dep.re(z.re)
})

View File

@ -5,5 +5,8 @@ export const number_type = {
}
export const typeImps = <T>() => ({
zero: (a: number) => 0
zero: (a: number) => 0,
one: (a: number) => 1,
nan: (a: number) => NaN,
re: (a: number) => a
})