// import { getPathValue } from './object'; // import { untypedCurry, pipeline } from './function'; // import { lens, DELETE } from './lens-functions'; // function _foldAndRead(this: Lens2<{}, {}>, defaultValue, data) { // return pipeline(lens(this.path, this.run([defaultValue, data]), defaultValue, data), processedData => [processedData, getPathValue(this.path, processedData), getPathValue(this.path, data)]); // } // function _fold(this: Lens2<{}, {}>, defaultValue, data) { // return lens(this.path, this.run([defaultValue, data]), defaultValue, data); // } // function _read(this: Lens2<{}, {}>, defaultValue, data) { // return getPathValue(this.path, lens(this.path, this.run([defaultValue, data]), defaultValue, data)); // } // function _write(this: Lens2<{}, {}>, value, data) { // return lens(this.path, ([defaultValue, data]) => value, value, data); // } // export class Lens2 { // readonly _A!: A; // readonly _L!: L; // readonly _URI!: 'babakness/lens'; // static readonly _URI: 'babakness/lens'; // constructor(readonly path, readonly run = a => b => b) { } // static type() { // return new Lens2(undefined); // } // //(method) Lens.of(path: A): Lens<{}, {}> // static of(path: A | undefined | null): Lens2<{}, NonNullable> { // return new Lens2(path); // } // of(path: [K1]): Lens2>; // of(path: [K1, K2]): Lens2>; // of(path: [K1, K2, K3]): Lens2>; // of(path: [K1, K2, K3, K4]): Lens2>; // of(path: [K1, K2, K3, K4, K5]): Lens2>; // of(path: [K1, K2, K3, K4, K5, K6]): Lens2>; // of(path: [K1, K2, K3, K4, K5, K6, K7]): Lens2>; // of(path: [K1, K2, K3, K4, K5, K6, K7, K8]): Lens2>; // of(path: [K1, K2, K3, K4, K5, K6, K7, K8, K9]): Lens2>; // of(path: [K1, K2, K3, K4, K5, K6, K7, K8, K9, K10]): Lens2>; // of(path): any { // return new Lens2(path); // } // from(...path: [K1]): Lens2>; // from(...path: [K1, K2]): Lens2>; // from(...path: [K1, K2, K3]): Lens2>; // from(...path: [K1, K2, K3, K4]): Lens2>; // from(...path: [K1, K2, K3, K4, K5]): Lens2>; // from(...path: [K1, K2, K3, K4, K5, K6]): Lens2>; // from(...path: [K1, K2, K3, K4, K5, K6, K7]): Lens2>; // from(...path: [K1, K2, K3, K4, K5, K6, K7, K8]): Lens2>; // from(...path: [K1, K2, K3, K4, K5, K6, K7, K8, K9]): Lens2>; // from(...path: [K1, K2, K3, K4, K5, K6, K7, K8, K9, K10]): Lens2>; // from(...path): any { // return new Lens2(path); // } // map(fn: (pathValue: A) => B): Lens2 { // return new Lens2(this.path, ([defaultValue, data]: [A | B, L]) => (pathValue: A) => fn(this.run([defaultValue, data])(pathValue))); // } // // given time constraints, could not effectively workout making this Foldable Functor a Monad. // // chain(fn: (pathValue: A) => Lens): Lens { // // // return new Lens(this.path, (pathValue:A) => fn(this.run(pathValue)).run(pathValue) ) // // return new Lens(fn(undefined as any).path, ([defaultValue,data]) => (pathValue) => { // // const calculatedData = lens(this.path,this.run([defaultValue,data]),defaultValue,data) // // console.log(this.path,calculatedData) // // return 9999 // returns the pathvalue of next iteration // // } ) // // } // // not sure, not implementing given time constraint // // ap(fab: Lens<{}, (pathValue: A) => B>): Lens { // // return new Lens(this.path, (pathValue:A) => fab.run(pathValue).run(pathValue)) // // } // preRead(data: Data): A { // return getPathValue(this.path, data) as any as A; // } // read(defaultValue: Default): (data: Data) => A; // read(defaultValue: Default, data: Data): A; // read(...args) { // return untypedCurry(_read.bind(this))(...args); // } // write(writeValue: Default): (data: Data) => L; // write(writeValue: Default, data: Data): L; // write(...args) { // return untypedCurry(_write.bind(this))(...args); // } // fold(defaultValue: Default): (data: Data) => L; // fold(defaultValue: Default, data: Data): L; // fold(...args) { // return untypedCurry(_fold.bind(this))(...args); // } // foldAndRead(defaultValue: Default): (data: Data) => [L, A, A]; // foldAndRead(defaultValue: Default, data: Data): [L, A, A]; // foldAndRead(...args) { // return untypedCurry(_foldAndRead.bind(this))(...args); // } // } // declare module 'fp-ts/lib/HKT' { // interface URI2HKT2 { // 'babakness/lens2': Lens2, // } // }