Skip to content

Commit

Permalink
2024/01/21 - Moving function implementation to JS.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
FadiShawki committed Jan 21, 2024
1 parent 9322d41 commit 356588d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import {
torus
} from "../OrbitMinesExplorer";
import {HotkeyEventOptions, useHotkeys} from "../../js/react/hooks/useHotkeys";
import {Implementation, Ray, RayType} from "../Ray";
import {Ray, RayType} from "../Ray";
import {HotkeyConfig} from "@blueprintjs/core/src/hooks/hotkeys/hotkeyConfig";
import _ from "lodash";
import {useThree} from "@react-three/fiber";
import {StatsPanels} from "./DebugCanvas";
import JS from "../JS";

const ___index = (ray: Ray): number => {
switch (ray.type) {
Expand Down Expand Up @@ -349,7 +350,7 @@ export const QuickVisualizationInterface = ({scale = 1.5}: InterfaceOptions) =>
// TODO Then expand these to any-dimensional
];
const isFollowing = directions.map(
([initial, terminal]): Implementation => {
([initial, terminal]): JS.Implementation => {
const toInitial = initial.some(option => pressed.includes(option));
const toTerminal = terminal.some(option => pressed.includes(option));

Expand Down
31 changes: 16 additions & 15 deletions src/@orbitmines/external/chyp/Chyp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Arbitrary, Ray} from "../../explorer/Ray";
import {Ray} from "../../explorer/Ray";
import {NotImplementedError} from "../../explorer/errors/errors";
import JS from "../../explorer/JS";

/**
* An interface from Aleks Kissinger's [Chyp (Cospans of HYPergraphs)](https://github.com/akissinger/chyp) to (OrbitMines') Rays.
Expand Down Expand Up @@ -32,22 +33,22 @@ export namespace Chyp {
}

// Vertex.in_edges = Ray.initial
get in_edges(): Ray { return this.initial; } set in_edges(ray: Arbitrary<Ray>) { this.initial = ray; }
get in_edges(): Ray { return this.initial; } set in_edges(ray: JS.Arbitrary<Ray>) { this.initial = ray; }

// Vertex.out_edges = Ray.terminal
get out_edges(): Ray { return this.terminal; } set out_edges(ray: Arbitrary<Ray>) { this.terminal = ray; }
get out_edges(): Ray { return this.terminal; } set out_edges(ray: JS.Arbitrary<Ray>) { this.terminal = ray; }

}

export type EData = Edge; export class Edge extends Ray {

// Edge.source = Ray.initial
get source(): Ray { return this.initial; } set source(ray: Arbitrary<Ray>) { this.initial = ray; }
get s(): Ray { return this.initial; } set s(ray: Arbitrary<Ray>) { this.initial = ray; }
get source(): Ray { return this.initial; } set source(ray: JS.Arbitrary<Ray>) { this.initial = ray; }
get s(): Ray { return this.initial; } set s(ray: JS.Arbitrary<Ray>) { this.initial = ray; }

// Edge.targets = Ray.terminal
get target(): Ray { return this.terminal; } set target(ray: Arbitrary<Ray>) { this.terminal = ray; }
get t(): Ray { return this.terminal; } set t(ray: Arbitrary<Ray>) { this.terminal = ray; }
get target(): Ray { return this.terminal; } set target(ray: JS.Arbitrary<Ray>) { this.terminal = ray; }
get t(): Ray { return this.terminal; } set t(ray: JS.Arbitrary<Ray>) { this.terminal = ray; }

}

Expand All @@ -73,10 +74,10 @@ export namespace Chyp {
}

// Match.domain = Ray.initial
get domain(): Ray { return this.initial; } set domain(ray: Arbitrary<Ray>) { this.initial = ray; }
get domain(): Ray { return this.initial; } set domain(ray: JS.Arbitrary<Ray>) { this.initial = ray; }

// Match.codomain = Ray.terminal
get codomain(): Ray { return this.terminal; } set codomain(ray: Arbitrary<Ray>) { this.terminal = ray; }
get codomain(): Ray { return this.terminal; } set codomain(ray: JS.Arbitrary<Ray>) { this.terminal = ray; }

}

Expand All @@ -91,10 +92,10 @@ export namespace Chyp {
}

// Rule.lhs = Ray.initial
get lhs(): Ray { return this.initial; } set lhs(ray: Arbitrary<Ray>) { this.initial = ray; }
get lhs(): Ray { return this.initial; } set lhs(ray: JS.Arbitrary<Ray>) { this.initial = ray; }

// Rule.rhs = Ray.terminal
get rhs(): Ray { return this.terminal; } set rhs(ray: Arbitrary<Ray>) { this.terminal = ray; }
get rhs(): Ray { return this.terminal; } set rhs(ray: JS.Arbitrary<Ray>) { this.terminal = ray; }

/**
* TODO: We can use the same implementation to rewrite where there's not necessarily a match between initial/terminal side of a rule.
Expand Down Expand Up @@ -141,12 +142,12 @@ export namespace Chyp {
}

// Graph.inputs = Ray.initial
get inputs(): Ray { return this.initial; } set inputs(ray: Arbitrary<Ray>) { this.initial = ray; }
set_inputs = (ray: Arbitrary<Ray>): Graph => { this.inputs = ray; return this; }
get inputs(): Ray { return this.initial; } set inputs(ray: JS.Arbitrary<Ray>) { this.initial = ray; }
set_inputs = (ray: JS.Arbitrary<Ray>): Graph => { this.inputs = ray; return this; }
add_inputs = (ray: Ray): Graph => { this.inputs.compose(ray); return this; }
// Graph.inputs = Ray.terminal
get outputs(): Ray { return this.terminal; } set outputs(ray: Arbitrary<Ray>) { this.terminal = ray; }
set_outputs = (ray: Arbitrary<Ray>): Graph => { this.outputs = ray; return this; }
get outputs(): Ray { return this.terminal; } set outputs(ray: JS.Arbitrary<Ray>) { this.terminal = ray; }
set_outputs = (ray: JS.Arbitrary<Ray>): Graph => { this.outputs = ray; return this; }
add_outputs = (ray: Ray): Graph => { this.outputs.compose(ray); return this; }

}
Expand Down

0 comments on commit 356588d

Please sign in to comment.