From f6e26212620de411e082cbd52379075ea5a99032 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sun, 10 Dec 2023 16:15:00 +0530 Subject: init commit rewriting shit --- src/index.ts | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/index.ts (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..bd93300 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,43 @@ +export type Op = string | { op: string; a: Op; b: Op }; + +export type Rewrite = { + type: 'rewrite'; + left: left; + right: right; +}; +export type RewriteKind = Rewrite; + +export type Flip = Rewrite; + +export type ApplyRewrite = + O extends R['left'] ? R['right'] + : O extends string ? O + : O extends { a: Op, b: Op, op: string } ? ( + ApplyRewrite extends O['a'] + ? Omit & { b: ApplyRewrite } + : Omit & { a: ApplyRewrite } + ) + : never; + +export type Add = { op: '+'; a: a; b: b }; + +export type Identity = Rewrite, A>; +export type Commutativity = Rewrite, Add>; + +// type _x = ApplyRewrite, Identity<'0'>>; + +// type Assoc = + +/* + +Assoc: (a + b) + c = a + (b + c) + +For a = 0, +(0 + b) + c += b + c += 0 + (b + c) + +For a = succ(), + +*/ + -- cgit v1.3.1