Skip to content

Commit

Permalink
2024/01/25 - Move some files around, get tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
FadiShawki committed Jan 25, 2024
1 parent 25a570a commit c477f13
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 184 deletions.
9 changes: 8 additions & 1 deletion environments/javascript/@orbitmines/rays/src/Ray.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ray from "./Ray";
import rays from "../index";

describe("Ray", () => {

Expand All @@ -19,7 +20,13 @@ describe("Ray", () => {
},
() => {
try{
ray.initial = new ray()
if (ray) {

}
// ray.initial = new ray();
// ray.initial = ray.terminal();
// ray.initial = (self): Ray.Any => {}
// ray.initial = Ray.Function.Self.Impl((self) => {})

} catch (e) {}
}
Expand Down
41 changes: 33 additions & 8 deletions environments/javascript/@orbitmines/rays/src/Ray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ namespace Ray {
* - Perhaps locally cache (for stuff like count?) - no way to ensure globally coherence
* - a.orbit() -> a.orbit(a)
*
* - .initial/.terminal can be seen as a particular connection on .self, which .self ignores?
*
* TODO: Testing
* - Test if references hold after equivalence/composition...
*
Expand Down Expand Up @@ -157,7 +159,7 @@ namespace Ray {
if (func) { return func.as_method({ self, property }); }

if (property === Symbol.toPrimitive)
return (hint: string) => { return 100; };
return (hint: string) => { return 100; }; // TODO: Can be used to setup label generation through javascript objects if we want to ? + allow search on this
// throw new NotImplementedError(``);

/** Not implemented. */
Expand Down Expand Up @@ -207,24 +209,29 @@ namespace Ray {
/** Ray is an Enum(eration) */
export namespace Enum {

export const Impl = <T extends Array<string>>(...values: T): Enum<T> => {
export const Impl = <T extends Array<string>>(...values: T): Ray.Enum<T> => {
return Object.fromEntries(values.map(value =>
[value, Ray.Function.None.Impl((): Ray.Any => {
throw new NotImplementedError(); // TODO
})]
)) as Enum<T>;
)) as Ray.Enum<T>;
// TODO: ONE OF 4 SELECTION RAY for the case of type.
}

}

/** Ray is a function (.next) */
export namespace Function {

// TODO: Reversible is orbit.

/** {T} is just an example/desired use case. But it generalizes to any function. */
export type Type<T> = T | Ray.Any;

/** From which perspective the Function is implemented. */
enum Perspective { None, Self, /** Ref, */ } // TODO Ray.Enum? or not.
enum Perspective {
None, Self, /** Ref, */
} // TODO Ray.Enum? or not.

// /**
// * Implement a function from the perspective of 'this' for 'this.self'.
Expand Down Expand Up @@ -277,7 +284,13 @@ namespace Ray {
return Impl(self => self); // TODO
}
}
}

/** TODO: Shouldn't classify these? */
export const Type = Ray.Enum.Impl('REFERENCE', 'INITIAL', 'TERMINAL', 'VERTEX');


export namespace Function {
export const Get = <TProperty extends keyof (typeof Ray.Function.All)>(
property: TProperty
): (typeof Ray.Function.All)[TProperty] | undefined => Ray.Function.All[property as TProperty] ?? undefined;
Expand Down Expand Up @@ -461,6 +474,22 @@ namespace Ray {
export const push_front = Ray.Function.Self.Binary(
(a, b) => b.compose(a.first())
);

/**
* Performing a copy (realizing it) can be conceptualized as traversing the entire structure. (Where the 'entire structure' means the current instantiation of it - with many ignorances attached)
*
* - A problem with a copy, is that in or to be generalizable, it needs to alter all references to the thing it's copying to itself - this cannot be done with certainty.
* - This copy does not do that. Instead, it is ignorant of other things referencing the thing it's copying.
* - Additionally, a copy necessarily has some non-redundancy to it:
*
* @see "A copy is necessarily inconsistent": https://orbitmines.com/papers/on-orbits-equivalence-and-inconsistencies#:~:text=If%20I%20have%20one%20thing%20and%20I%20make%20a%20perfect%20copy
*/
// @alias('clone', 'duplicate')
export const copy = Ray.Function.Self.Impl(
(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.
);


}
}

Expand All @@ -474,10 +503,6 @@ namespace Ray {

export const number = (number: number) => { throw new NotImplementedError(); }


/** TODO: Shouldn't classify these? */
export const Type = Ray.Enum.Impl('REFERENCE', 'INITIAL', 'TERMINAL', 'VERTEX');

// export const Boundary = { INITIAL: Type.INITIAL, TERMINAL: Type.TERMINAL }; TODO: LIST O

// TODO CAN ALSO BE ZERO-ARY..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,9 @@
// NOT NEEDED FOR INITIAL DEMONSTRATION:

```ts
// TODO; Could return the ignorant reference to both instances, or just the result., ..

/**
* - The problem with a copy, is that in or to be generalizable, it needs to alter all references to the thing it's copying to itself - this cannot be done with certainty.
*
* - Additionally, a copy necessarily has some non-redundancy to it:
* @see "A copy is necessarily inconsistent": https://orbitmines.com/papers/on-orbits-equivalence-and-inconsistencies#:~:text=If%20I%20have%20one%20thing%20and%20I%20make%20a%20perfect%20copy
*/
// @alias('duplicate')
copy = (): Ray.Any => {
// return this.self.as_reference(); // Copies the reference?
throw new NotImplementedError();

// const copy = new Ray({
// initial: this.self._initial().as_reference().none_or(ref => ref.copy()).as_arbitrary(),
// vertex: this.self._vertex().as_reference().none_or(ref => ref.copy()).as_arbitrary(),
// }).o({ ___dirty_copy_buffer: {} });
// // copy._initial = () => copy.any.___dirty_copy_buffer._initial ??= this.self._initial().as_reference().copy();
// // copy._vertex = () => copy.any.___dirty_copy_buffer._vertex ??= this.self._vertex().as_reference().copy();
// // copy._terminal = () => copy.any.___dirty_copy_buffer._terminal ??= this.self._terminal().as_reference().copy();
//
//
// // TODO: Doesn't copy .any
//
// return copy.as_reference();
}


get count(): Ray.Any { return JS.Number(this.as_array().length); }



// TODO: For chyp used to compare [vtype, size] as domains, just type matching on the vertex. ; each individually, again, additional structure...

// TODO: Ignore the connection between the two, say a.equiv(b) within some Rule [a,b], ignore the existing of the connection in the Rule? What does it mean not to???
Expand All @@ -43,7 +15,6 @@ is_vertex_equivalent = (b: Ray.Any) => {

// none_or = (arbitrary: Implementation): Ray.Any => this.is_none() ? Ray.None() : arbitrary(this);


/**
* https://en.wikipedia.org/wiki/Homoiconicity
*/
Expand Down Expand Up @@ -73,21 +44,6 @@ static zip = Ray.Function.Impl((initial, terminal) => {
});
zip = Ray.zip.as_method(this);

/**
* TODO: This should be constructed at the vertex and in general unsolvable
*
* TODO: Setup labels
* TODO: Use JavaScript engine for generating these for a default impl without someone supplying their own gen func??
* TODO: + allow for searching/doing stuff based on some label ; this can be arbitrarily through the structure
*/
static _label: number = 0;
get label(): string {
if (this.any.label !== undefined)
return this.any.label;

return this.any.label = `"${Ray._label++} (${this.any.debug?.toString() ?? '?'})})"`;
}

/**
* Used for chaining JavaScript-provided properties
*
Expand Down
130 changes: 0 additions & 130 deletions orbitmines.com/useless_junk/generate_chyp.js

This file was deleted.

0 comments on commit c477f13

Please sign in to comment.