Skip to content

Commit

Permalink
2024/01/25 - as_(reference, vertex, terminal, initial)
Browse files Browse the repository at this point in the history
  • Loading branch information
FadiShawki committed Jan 25, 2024
1 parent 66b8249 commit 8b8769f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 46 deletions.
36 changes: 0 additions & 36 deletions environments/javascript/@orbitmines/rays/src/Ray.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,6 @@ describe("Ray", () => {
}))).toBe(false);

});
test(".traverse", () => {
// const events: any[] = [];
// const ray = Ray.New();
//
// ray.debug(
// (event) => {
// events.push(event);
// },
// () => {
// // // Reference
// // ray.initial = none;
// // // ray.self = // SOMETHING
// // ray.terminal = none;
// //
// // // Initial
// // ray.initial = none;
// // ray.self = self_reference;
// // ray.terminal = self_reference;
// //
// // // Vertex:
// // ray.initial = self_reference;
// // ray.self = self_reference;
// // ray.terminal = self_reference;
// //
// // // Terminal
// // ray.initial = self_reference;
// // ray.self = self_reference;
// // ray.terminal = none;
// }
// );
//
// expect(events.map(event => ({
// event: event.event, context: { method: { property: event.context.method.property} }
// }))).toBe(false);

});
})
})

Expand Down
50 changes: 40 additions & 10 deletions environments/javascript/@orbitmines/rays/src/Ray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ namespace Ray {
export class Compiler { // Ray is Compiler

/**
* TODO: Compiler could have things like other composed rays which tell it cares about the other (even if that's correct or not??)
*
*
* TODO: Do I want to keep the is_equiv/is_composed pattern? Or simplify to one of the two?
*
* // TODO: NEVER DIRECTLY EXECUTE, ONLY AFTER CHAIN OF FUNCS, possibly arbitrarily LAZY
Expand Down Expand Up @@ -373,15 +376,6 @@ namespace Ray {
self => self
);

/**
* Moving `self` to `.self` on an abstraction layer (higher). As a way of being able to describe `self`.
*
* TODO: the .reference might need two levels of abstraction higher, one to put it at the .self, another to reference that thing? (Depends a bit on the execution layer)
*/
export const reference = Ray.Function.Self.Impl(
self => Ray.Op.Zeroary.All.none().self = self
);

/**
* @see "Continuations as Equivalence (can often be done in parallel - not generally)": https://orbitmines.com/papers/on-orbits-equivalence-and-inconsistencies#:~:text=Constructing%20Continuations%20%2D%20Continuations%20as%20Equivalence
*/
Expand Down Expand Up @@ -511,11 +505,47 @@ namespace Ray {
export const copy = Ray.Function.Self.Impl(
// or
// (self) => self.self.copy.reference()
(self) => Ray.Op.Zeroary.All.none().self = self.self.copy()
(self) => none().self = self.self.copy()

// TODO Relies heavily on the execution layer to copy initial/terminal etc... ; and an is_orbit check before calling copy again. - Then again on the execution layer it can lazily do this copy (by not evaluating (i.e.) traversing everywhere), or it first does this traversing directly.
);

export const none = Ray.Op.Zeroary.All.none; // TODO FOR ALL OPS, ? automatic, or just put them here.

// TODO: These should allow as_vertex as zero-ary, but that means self = self_reference, not none. ?
/**
* Moving `self` to `.self` on an abstraction layer (higher). As a way of being able to describe `self`.
*
* TODO: the .reference might need two levels of abstraction higher, one to put it at the .self, another to reference that thing? (Depends a bit on the execution layer)
*/
export const as_reference = Ray.Function.Self.Impl(
self => none().self = self
);

export const as_vertex = Ray.Function.Self.Impl((self) => {
const vertex = Ray.Op.Zeroary.All.none();
vertex.initial = self_reference;
vertex.terminal = self_reference;
vertex.self = self; // TODO: Like this, ignorant vs non-ignorant? What to do here?

return vertex;
});
export const as_terminal = Ray.Function.Self.Impl((self) => {
const terminal = Ray.Op.Zeroary.All.none();
terminal.initial = self_reference;
// terminal.terminal = none;
terminal.self = self;

return terminal;
});
export const as_initial = Ray.Function.Self.Impl((self) => {
const initial = Ray.Op.Zeroary.All.none();
// initial.initial = none;
initial.terminal = self_reference;
initial.self = self;

return initial;
});

}
}
Expand Down

0 comments on commit 8b8769f

Please sign in to comment.