This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MergeState<A> { | |
constructor() {} | |
left : A = null; | |
left_present : boolean = false; | |
right : A = null; | |
right_present : boolean = false; | |
} | |
export class Stream<A> { | |
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class Cell<A> { | |
. | |
. | |
. | |
/** | |
* Apply a value inside a cell to a function inside a cell. This is the | |
* primitive for all function lifting. | |
*/ | |
static apply<A,B>(cf : Cell<(a : A) => B>, ca : Cell<A>, sources? : Source[]) : Cell<B> { | |
return Transaction.run(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("cell lift work", done => { | |
let lines = [ | |
"Work it harder", | |
"Make it better", | |
"Do it faster", | |
"Makes us stronger" | |
]; | |
let idx = 0; | |
let c1 = new CellSink(0); | |
let c2 = new CellSink(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as sodium from 'sodiumjs'; | |
import * as THREE from 'three'; | |
import { EcsComponentType } from './EcsComponentType'; | |
import { EcsReadOnlySceneContext } from './EcsReadOnlySceneContext'; | |
import { EcsSceneChanges } from './EcsSceneChanges'; | |
import { IsEcsComponentValue } from './IsEcsComponentValue'; | |
import { ArcComponent } from './components/ArcComponent'; | |
import { Axes2DComponent } from './components/Axes2DComponent'; | |
import { CircleComponent } from './components/CircleComponent'; | |
import { Line3DComponent } from './components/Line3DComponent'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function cellTrace<A>(ca: sodium.Cell<A>, extractor: (a: A) => (sodium.Stream<any>|sodium.Cell<any>)[]): sodium.Cell<A> { | |
let cKeepAlive = sodium.Cell.switchC(ca.map( | |
a => | |
cellLiftArray( | |
extractor(a).map( | |
x => { | |
if (x instanceof sodium.Stream) { | |
return x.hold({} as any); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as sodium from 'sodiumjs'; | |
import { Option } from './Option'; | |
import * as SodiumUtil from './SodiumUtil'; | |
import { T2 } from './Tuples'; | |
import * as THREE from 'three'; | |
import { Axes3D } from './math/Axes3D'; | |
import { Vector2D } from './math/Vector2D'; | |
import { Vector3D } from './math/Vector3D'; | |
import { Quaternion } from './math/Quaternion'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test<A> { | |
private _value: A; | |
private _listeners: ((a:A)=>void)[] = []; | |
private _onWakeUp: () => {}; | |
private _onSleep: () => {}; | |
public constructor(value: A) { | |
this._value = value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static nz.sodium.Cell<Axes3D> watchEntityAxes( | |
nz.sodium.Cell<Option<EcsReadOnlySceneContext>> cSceneCtxOp, | |
nz.sodium.Stream<EcsSceneChanges> sSceneChanges, | |
int entityId | |
) { | |
return nz.sodium.Cell.switchC(watchEntityComponentOp(cSceneCtxOp, sSceneChanges, entityId, Axes3DComponent.ecsComponent).lift( | |
watchEntityComponentOp(cSceneCtxOp, sSceneChanges, entityId, ChildComponent.ecsComponent), | |
(Option<Axes3DComponent> axesOp, Option<ChildComponent> parentOp) -> { | |
Option<Integer> parentIdOp = parentOp.map(ChildComponent::parentId); | |
Axes3D localAxes = axesOp.map(Axes3DComponent::axes3D).orSome(Axes3D.identity); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <A> nz.sodium.Cell<Option<A>> watchEntityComponentOp( | |
nz.sodium.Cell<Option<EcsReadOnlySceneContext>> cSceneCtxOp, | |
nz.sodium.Stream<EcsSceneChanges> sSceneChanges, | |
int entityId, | |
EcsComponent<A> ecsComponent | |
) { | |
nz.sodium.StreamLoop<Option<A>> slEntityComponentOp = new sodium.StreamLoop<>(); | |
nz.sodium.Cell<Option<A>> cEntityComponentOp = | |
slEntityComponentOp | |
.hold( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fp.ilc; | |
import fj.F2; | |
public class Delta<A,DA> { | |
private final F2<A,DA,A> _patch; | |
private final DA _change; | |
private Delta(F2<A,DA,A> patch, DA change) { | |
this._patch = patch; |