From 397ad76923bc240ce785c09cecd0a1e8e293b54e Mon Sep 17 00:00:00 2001 From: rowan Date: Thu, 17 Apr 2025 11:50:49 -0500 Subject: [PATCH] add esbuild, move to node packaging ;n; --- dist/index.js | 1712 +++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 497 +++++++++++++ package.json | 10 +- src/char.js | 2 +- src/combinator.js | 2 +- src/cond.js | 4 +- src/fn.js | 4 +- src/seq.js | 4 +- src/state.js | 3 +- vendor/izuna | 1 - vendor/kojima | 1 - 11 files changed, 2227 insertions(+), 13 deletions(-) create mode 100644 dist/index.js delete mode 160000 vendor/izuna delete mode 160000 vendor/kojima diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..0a9b921 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,1712 @@ +"use strict"; +(() => { + // src/iter.js + var Iter = class _Iter { + _iterator; + _source; + /** + * @param {Iterator} iterator + * @param {Iterabl} [source] + */ + constructor(iterator, source) { + this._iterator = iterator; + this._source = source; + } + /** + * @template T + * @param {any} value + * @returns {value is Iterable} + */ + static _isIterable(value) { + return typeof value[Symbol.iterator] === "function"; + } + /** + * @template T + * @param {T} value + */ + static from(value) { + if (value instanceof _Iter) { + return value; + } + if (_Iter._isIterable(value)) { + const iterator = value[Symbol.iterator](); + if (iterator instanceof _Iter) { + return iterator; + } + return new _Iter(iterator, value); + } + throw new TypeError("object is not an iterator"); + } + clone() { + if (this._source) { + return _Iter.from(this._source); + } + throw new Error("Cannot clone Iterator: not created from an iterable"); + } + /** + * @param {any} [value] + */ + next(value) { + const n = this._iterator.next(value); + return n; + } + /** + * @param {any} [value] + */ + return(value) { + return this._iterator.return(value); + } + /** + * @param {any} err + */ + throw(err2) { + return this._iterator.throw(err2); + } + /** + * @param {number} limit + */ + drop(limit) { + return new DropIter(this, limit); + } + /** + * @param {(value: T, index: number) => boolean} callbackFn + */ + every(callbackFn) { + let next2 = this.next(); + let index = 0; + let result = true; + while (!next2.done) { + if (!callbackFn(next2.value, index)) { + result = false; + break; + } + next2 = this.next(); + index += 1; + } + this.return(); + return result; + } + /** + * @param {(value: T, index: number) => boolean} callbackFn + */ + filter(callbackFn) { + return new FilterIter(this, callbackFn); + } + /** + * @param {(value: T, index: number) => boolean} callbackFn + */ + find(callbackFn) { + let next2 = this.next(); + let index = 0; + while (!next2.done) { + if (callbackFn(next2.value, index)) { + this.return(); + return next2.value; + } + next2 = this.next(); + index += 1; + } + } + /** + * @param {(value: T, index: number) => U} callbackFn + */ + flatMap(callbackFn) { + return new FlatMapIter(this, callbackFn); + } + /** + * @param {(value: T, index: number) => void} callbackFn + */ + forEach(callbackFn) { + let next2 = this.next(); + let index = 0; + while (!next2.done) { + callbackFn(next2.value, index); + next2 = this.next(); + index += 1; + } + } + /** + * @param {(value: T, index: number) => U} callbackFn + */ + map(callbackFn) { + return new MapIter(this, callbackFn); + } + /** + * @template U + * @param {(accumulator: U, value: T, index: number) => U} callbackFn + * @param {U} init + */ + reduce(callbackFn, init) { + let next2 = this.next(); + let index = 0; + let acc = init; + while (!next2.done) { + acc = callbackFn(acc, next2.value, index); + next2 = this.next(); + index += 1; + } + this.return(); + return acc; + } + /** + * @param {(value: T, index: number) => boolean} callbackFn + */ + some(callbackFn) { + let next2 = this.next(); + let index = 0; + let result = false; + while (!next2.done) { + if (callbackFn(next2.value, index)) { + result = true; + break; + } + next2 = this.next(); + index += 1; + } + this.return(); + return result; + } + /** + * @param {number} limit + */ + take(limit) { + return new TakeIter(this, limit); + } + /* + * @returns {T[]} + */ + toArray() { + const result = []; + for (const item of this) { + result.push(item); + } + return result; + } + *[Symbol.iterator]() { + return this; + } + }; + var DropIter = class extends Iter { + _limit; + /** + * @param {Iterator} iterator + * @param {number} limit + */ + constructor(iterator, limit) { + super(iterator); + this._limit = limit; + } + /** + * @param {any} value + */ + next(value) { + for (let i = this._limit; i > 0; i--) { + const next2 = super.next(value); + if (next2.done) { + return next2; + } + } + return super.next(value); + } + }; + var FilterIter = class extends Iter { + _filter; + _index = 0; + /** + * @param {Iterator} iterator + * @param {(value: T, index: number) => boolean} callbackFn + */ + constructor(iterator, callbackFn) { + super(iterator); + this._filter = callbackFn; + } + /** + * @param {any} [value] + * @returns {IteratorResult} + */ + next(value) { + let next2 = super.next(value); + while (!next2.done && !this._filter(next2.value, this._index)) { + next2 = super.next(value); + this._index += 1; + } + return next2; + } + }; + var FlatMapIter = class extends Iter { + _flatMap; + _index = 0; + /** @type {Iterator | undefined} */ + _inner = void 0; + /** + * @param {Iterator} iterator + * @param {(value: T, index: number) => Iterator | Iterable} callbackFn + */ + constructor(iterator, callbackFn) { + super(iterator); + this._flatMap = callbackFn; + } + /** + * @param {any} value + * @returns {IteratorResult} + */ + next(value) { + if (this._inner) { + const innerResult = this._inner.next(value); + if (!innerResult.done) { + this._index += 1; + return { value: innerResult.value, done: false }; + } + this._inner = void 0; + } + const outerResult = super.next(value); + if (outerResult.done) { + return { value: void 0, done: true }; + } + const nextIterable = this._flatMap(outerResult.value, this._index || 0); + if (Iter._isIterable(nextIterable)) { + this._inner = Iter.from(nextIterable); + return this.next(value); + } else { + throw new TypeError("value is not an iterator"); + } + } + }; + var MapIter = class extends Iter { + _map; + _index = 0; + /** + * @param {Iterator} iterator + * @param {(value: T, index: number) => U} callbackFn + */ + constructor(iterator, callbackFn) { + super(iterator); + this._map = callbackFn; + } + /** @param {any} value */ + next(value) { + let next2 = super.next(value); + if (next2.done) { + return next2; + } + const result = { + done: false, + value: this._map(next2.value, this._index) + }; + this._index += 1; + return result; + } + }; + var TakeIter = class extends Iter { + _limit; + /** + * @param {Iterator} iterator + * @param {number} limit + */ + constructor(iterator, limit) { + super(iterator); + this._limit = limit; + } + /** + * @param {any} value + * @returns {IteratorResult} + */ + next(value) { + if (this._limit > 0) { + const next2 = super.next(value); + if (!next2.done) { + this._limit -= 1; + } + return next2; + } + return { value: void 0, done: true }; + } + }; + + // node_modules/kojima/src/mixin.js + var _appliedMixin = "__mixwith_appliedMixin"; + var apply = (superclass, mixin) => { + let application = mixin(superclass); + application.prototype[_appliedMixin] = unwrap(mixin); + return application; + }; + var isApplicationOf = (proto, mixin) => proto.hasOwnProperty(_appliedMixin) && proto[_appliedMixin] === unwrap(mixin); + var hasMixin = (o, mixin) => { + while (o != null) { + if (isApplicationOf(o, mixin)) return true; + o = Object.getPrototypeOf(o); + } + return false; + }; + var _wrappedMixin = "__mixwith_wrappedMixin"; + var wrap = (mixin, wrapper) => { + Object.setPrototypeOf(wrapper, mixin); + if (!mixin[_wrappedMixin]) { + mixin[_wrappedMixin] = mixin; + } + return wrapper; + }; + var unwrap = (wrapper) => wrapper[_wrappedMixin] || wrapper; + var _cachedApplications = "__mixwith_cachedApplications"; + var Cached = (mixin) => wrap(mixin, (superclass) => { + let cachedApplications = superclass[_cachedApplications]; + if (!cachedApplications) { + cachedApplications = superclass[_cachedApplications] = /* @__PURE__ */ new Map(); + } + let application = cachedApplications.get(mixin); + if (!application) { + application = mixin(superclass); + cachedApplications.set(mixin, application); + } + return application; + }); + var DeDupe = (mixin) => wrap(mixin, (superclass) => hasMixin(superclass.prototype, mixin) ? superclass : mixin(superclass)); + var BareMixin = (mixin) => wrap(mixin, (s) => apply(s, mixin)); + var Mixin = (mixin) => DeDupe(Cached(BareMixin(mixin))); + var mix = (superclass) => new MixinBuilder(superclass); + var MixinBuilder = class { + constructor(superclass) { + this.superclass = superclass || class { + }; + } + /** + * Applies `mixins` in order to the superclass given to `mix()`. + * + * @param {Array.} mixins + * @return {FunctionConstructor} a subclass of `superclass` with `mixins` applied + */ + with(...mixins) { + return mixins.reduce((c, m) => m(c), this.superclass); + } + }; + + // node_modules/kojima/src/algebra/interfaces.js + var ProtectedConstructor = Symbol("ProtectedConstructor"); + var NotImplementedError = class extends Error { + /** @param {string} name */ + constructor(name) { + super(`${name} is not implemented`); + } + }; + var MethodType = Object.freeze({ + Instance: 0, + Static: 1 + }); + var Method = class _Method { + #name; + /** @type {MethodType} */ + #type = MethodType.Instance; + /** @type {Fn} */ + #implementation; + /** + * @param {string | Method} name + */ + constructor(name) { + if (name instanceof _Method) { + return name; + } + this.#name = name; + } + /** + * @param {string | Method} value + */ + static from(value) { + return new _Method(value); + } + isInstance() { + this.#type = MethodType.Instance; + return this; + } + isStatic() { + this.#type = MethodType.Static; + return this; + } + /** @param {Fn} f */ + implementation(f) { + this.#implementation = f; + return this; + } + /** + * @param {string} interfaceName + */ + _defaultImplementation(interfaceName) { + const err2 = new NotImplementedError( + `${interfaceName}::${this.#name}` + ); + return function() { + throw err2; + }; + } + /** + * @param {Function} target + */ + _getInstallationPoint(target) { + switch (this.#type) { + case 0: + return Object.getPrototypeOf(target); + case 1: + return target; + default: + return target; + } + } + /** + * @param {Interface} builder + * @param {Function} target + */ + implement(builder, target) { + const impl = this.#implementation || this._defaultImplementation(builder.name); + this._getInstallationPoint(target)[this.#name] = impl; + } + }; + var Implementations = Symbol(); + var Interface = class { + #name; + /** @type {MixinFunction} */ + #mixin; + /** @type {Set} */ + #methods = /* @__PURE__ */ new Set(); + /** @type {Set} */ + #interfaces = /* @__PURE__ */ new Set(); + /** @param {string} name */ + constructor(name) { + this.#name = name; + this.#mixin = Mixin(this.build.bind(this)); + } + get name() { + return this.#name; + } + findInterfaces(type) { + let interfaces = /* @__PURE__ */ new Set(); + let current = type; + while (current != null) { + interfaces = new Set(current[Implementations]).union(interfaces); + current = Object.getPrototypeOf(current); + } + return interfaces; + } + /** + * @param {{ name: string }} type + * @returns {boolean} + */ + implementedBy(type) { + return this.findInterfaces(type).has(this); + } + /** + * @param {...(PropertyKey | Method)} methods + * @returns {this} + */ + specifies(...methods) { + this.#methods = new Set( + methods.map(Method.from).concat(...this.#methods) + ); + return this; + } + /** + * @param {...Interface} interfaces + * @returns {this} + */ + extends(...interfaces) { + this.#interfaces = new Set(interfaces.concat(...this.#interfaces)); + return this; + } + /** + * @returns {MixinFunction} + */ + asMixin() { + return this.#mixin; + } + /** + * @param {FunctionConstructor} base + */ + build(base) { + const interfaces = [...this.#interfaces.values()]; + const mixins = interfaces.map((x) => x.asMixin()); + const Interfaces5 = mix(base).with(...mixins); + const Algebra2 = class extends Interfaces5 { + }; + for (const method of this.#methods) { + method.implement(this, Algebra2); + } + const prototype = Object.getPrototypeOf(Algebra2); + prototype[Implementations] = new Set(interfaces); + return Algebra2; + } + }; + var BaseSet = class { + }; + var AlgebraWithBase = (base) => (...algebras) => { + return mix(base).with(...algebras.map((x) => x.asMixin())); + }; + var Algebra = AlgebraWithBase(BaseSet); + var Setoid = new Interface("Setoid").specifies("equals"); + var Ord = new Interface("Ord").specifies("lte"); + var Semigroupoid = new Interface("Semigroupoid").specifies("compose"); + var Category = new Interface("Category").extends(Semigroupoid).specifies( + Method.from("id").isStatic() + ); + var Semigroup = new Interface("Semigroup").specifies("concat"); + var Monoid = new Interface("Monoid").extends(Semigroup).specifies( + Method.from("empty").isStatic() + ); + var Group = new Interface("Group").extends(Monoid).specifies("invert"); + var Filterable = new Interface("Filterable").specifies("filter"); + var Functor = new Interface("Functor").specifies("map"); + var Contravariant = new Interface("Contravariant").specifies("contramap"); + var Apply = new Interface("Apply").extends(Functor).specifies("ap"); + var Applicative = new Interface("Applicative").extends(Apply).specifies( + Method.from("of").isStatic() + ); + var Alt = new Interface("Alt").extends(Functor).specifies("alt"); + var Plus = new Interface("Plus").extends(Alt).specifies( + Method.from("zero").isStatic() + ); + var Alternative = new Interface("Alternative").extends(Applicative, Plus); + var Foldable = new Interface("Foldable").specifies("fold"); + var Traversable = new Interface("Traversable").extends(Functor, Foldable).specifies("traverse"); + var Chain = new Interface("Chain").extends(Apply).specifies( + Method.from("chain").implementation(function(f) { + return f(this._value); + }) + ); + var ChainRef = new Interface("ChainRec").extends(Chain).specifies( + Method.from("chainRec").isStatic() + ); + var Monad = new Interface("Monad").extends(Applicative, Chain); + var Extend = new Interface("Extend").extends(Functor).specifies("extend"); + var Comonad = new Interface("Comonad").extends(Extend).specifies("extract"); + var Bifunctor = new Interface("Bifunctor").extends(Functor).specifies("bimap"); + var Profunctor = new Interface("Profunctor").extends(Functor).specifies("promap"); + + // node_modules/kojima/src/algebra/identity.js + var Identity = class extends Algebra(Monad, Comonad) { + #value; + /** + * @param {T} value + */ + constructor(value) { + super(); + this.#value = value; + } + /** + * @template T + * @param {T} value + */ + static of(value) { + return id(value); + } + /** + * @template U + * @type {Functor['map']} + * @param {Morphism} f + * @returns {Identity} + */ + map(f) { + return id(f(this.#value)); + } + /** + * @template U + * @type {Apply['ap']} + * @param {Apply>} b + * @returns {Apply} + */ + ap(b) { + return ( + /** @type {Apply} */ + b.map((f) => f(this.#value)) + ); + } + /** + * @template U + * @param {Morphism>} f + */ + chain(f) { + return f(this.#value); + } + /** + * @param {(value: Identity) => T} f + */ + extend(f) { + return id(f(this)); + } + extract() { + return this.#value; + } + toString() { + return `Identity(${this.#value})`; + } + }; + var id = (value) => new Identity(value); + + // node_modules/kojima/src/algebra/option.js + var Interfaces = Algebra(Setoid, Alternative, Monad, Foldable); + var Some = class _Some extends Interfaces { + /** @type {T} */ + #value; + /** @param {T} value */ + constructor(value) { + super(); + this.#value = value; + } + /** + * @type {SetoidT['equals']} + * @param {Some} other + */ + equals(other) { + if (other instanceof _Some) { + return false; + } + const eq = ( + /** @type {Some} */ + other.chain((v) => id(v === this.#value)) + ); + return ( + /** @type {Identity} */ + eq.extract() + ); + } + /** + * @template U + * @type {Apply['ap']} + * @param {Some>} b + * @returns {Some} + */ + ap(b) { + return ( + /** @type {Some} */ + b.chain( + (f) => ( + /** @type {Some} */ + this.map(f) + ) + ) + ); + } + /** + * @type {Alt['alt']} + */ + alt(b) { + return this; + } + /** + * @type {Chain['chain']} + */ + chain(f) { + return f(this.#value); + } + /** + * @template U + * @type {Functor['map']} + * @param {Morphism} f + * @returns {Some} + */ + map(f) { + return ( + /** @type {Some} */ + this.chain((v) => some(f(v))) + ); + } + /** + * @type {Functor['map']} + */ + then(f) { + return this.map(f); + } + /** + * @template U + * @type {FoldableT['reduce']} + * @param {(acc: U, value: T) => U} f + * @param {U} init + * @returns {U} + */ + reduce(f, init) { + return f(init, this.#value); + } + toString() { + return `Some(${this.#value})`; + } + }; + var None = class extends Interfaces { + /** + * @type {SetoidT['equals']} + */ + equals(other) { + return other === none; + } + /** + * @type {Apply['ap']} + * @returns {this} + */ + ap(_b) { + return this; + } + /** + * @type {Alt['alt']} + */ + alt(b) { + return b; + } + /** + * @template U + * @type {Chain['chain']} + * @param {Morphism} _f + * @returns {this} + */ + chain(_f) { + return this; + } + /** + * @template U + * @type {Functor['map']} + * @param {Morphism} _f + * @returns {this} + */ + map(_f) { + return this; + } + /** + * @template R + * @type {Functor['map']} + * @param {Morphism} _f + * @returns {None} + */ + then(_f) { + return this; + } + /** + * @template U + * @type {FoldableT['reduce']} + * @param {(acc: U, value: T) => U} _f + * @param {U} init + * @returns {U} + */ + reduce(_f, init) { + return init; + } + toString() { + return "None"; + } + }; + var some = (value) => new Some(value); + var none = new None(); + var TypeRef = some; + TypeRef.constructor["of"] = some; + TypeRef.constructor["zero"] = none; + + // node_modules/kojima/src/algebra/result.js + var Interfaces2 = Algebra(Setoid, Alternative, Monad, Foldable, Bifunctor); + var Ok = class _Ok extends Interfaces2 { + /** @type {T} */ + #value; + /** + * @param {T} value + * @constructs {Ok} + */ + constructor(value) { + super(); + this.#value = value; + } + /** + * @type {SetoidT['equals']} + * @param {Result} other + * @returns {boolean} + */ + equals(other) { + if (!(other instanceof _Ok)) { + return false; + } + const eq = other.chain((v) => id(v === this.#value)); + return ( + /** @type {Identity} */ + eq.extract() + ); + } + /** @returns {this is Ok} */ + isOk() { + return true; + } + /** @returns {this is Err} */ + isErr() { + return false; + } + /** + * @type {Chain['chain']} + */ + chain(f) { + return f(this.#value); + } + /** + * @template E2 + * @type {Chain['chain']} + * @param {Morphism} _f + * @returns {this} + */ + chainErr(_f) { + return this; + } + /** + * @template U + * @type {Functor['map']} + * @param {Morphism} f + * @returns {Functor} + */ + map(f) { + return this.chain((v) => ok(f(v))); + } + /** + * @template E2 + * @type {Functor['map']} + * @this {Result} + * @param {Morphism} _f + * @returns {Result} + */ + mapErr(_f) { + return ( + /** @type {never} */ + this + ); + } + /** + * @template U + * @type {Apply['ap']} + * @param {Apply>} b + * @returns {Result} + */ + ap(b) { + return ( + /** @type {Result} */ + this.chain( + (v) => ( + /** @type {Chain} */ + b.map((f) => f(v)) + ) + ) + ); + } + /** + * @type Alt['alt'] + */ + alt(_b) { + return this; + } + /** + * @template U + * @borrows {Result~map} + * @param {Morphism} f + */ + then(f) { + return this.map(f); + } + /** + * @template R + * @param {Morphism} _f + * @returns {this} + */ + catch(_f) { + return this; + } + /** + * @template U + * @type {FoldableT['reduce']} + * @param {(acc: U, value: T) => U} f + * @param {U} init + * @returns {U} + */ + reduce(f, init) { + return f(init, this.#value); + } + /** + * @template T2, E2 + * @type {BifunctorT['bimap']} + * @param {Morphism} f + * @param {Morphism} _g + * @returns {Result} + */ + bimap(f, _g) { + return ( + /** @type {Result} */ + this.map(f) + ); + } + toString() { + return `Ok(${this.#value})`; + } + }; + var Err = class _Err extends Interfaces2 { + /** @type {E} */ + #value; + /** + * @param {E} value + * @constructs {Err} + */ + constructor(value) { + super(); + this.#value = value; + } + /** + * @type {SetoidT['equals']} + * @param {Err} other + * @returns {boolean} + */ + equals(other) { + if (!(other instanceof _Err)) { + return false; + } + const eq = other.chainErr((v) => id(v === this.#value)); + return ( + /** @type {Identity} */ + eq.extract() + ); + } + /** @returns {this is Ok} */ + isOk() { + return false; + } + /** @returns {this is Err} */ + isErr() { + return true; + } + /** + * @type {Chain['chain']} + * @returns {this} + */ + chain(_f) { + return this; + } + /** + * @template E2 + * @type {Chain['chain']} + * @param {Morphism>} f + * @returns {Result} + */ + chainErr(f) { + return f(this.#value); + } + /** + * @type {Functor['map']} + * @returns {this} + */ + map(_f) { + return this; + } + /** + * @template E2 + * @type {Functor['map']} + * @param {Morphism} f + * @returns {Result} + */ + mapErr(f) { + return ( + /** @type {Result} */ + this.bimap(id, f) + ); + } + /** + * @type {Functor['map']} + * @returns {this} + */ + then(_f) { + return this; + } + /** + * @template R + * @type {Functor['map']} + * @param {Morphism} f + * @returns {Err} + */ + catch(f) { + return new _Err(f(this.#value)); + } + /** + * @type Alt['alt'] + */ + alt(b) { + return b; + } + /** + * @template U + * @type {FoldableT['reduce']} + * @param {(acc: U, value: T) => U} _f + * @param {U} init + * @returns {U} + */ + reduce(_f, init) { + return init; + } + /** + * @template T2, E2 + * @type {BifunctorT['bimap']} + * @param {Morphism} _f + * @param {Morphism} g + * @returns {Result} + */ + bimap(_f, g) { + return ( + /** @type {Result} */ + err(g(this.#value)) + ); + } + toString() { + return `Err(${this.#value})`; + } + }; + var ok = (v) => new Ok(v); + var err = (e) => new Err(e); + var TypeRef2 = ok; + TypeRef2.constructor["of"] = ok; + TypeRef2.constructor["zero"] = err; + + // node_modules/kojima/src/algebra/list.js + var Interfaces3 = Algebra(Semigroup, Foldable, Monoid, Comonad); + var Empty = class extends Interfaces3 { + constructor() { + super(); + } + /** + * @template U + * @type {Chain['chain']} + * @this {Empty} + * @param {Morphism>} _f + * @returns {List} + */ + chain(_f) { + return ( + /** @type {List} */ + this + ); + } + /** + * @template U + * @type {Functor['map']} + * @this {Empty} + * @param {Morphism} _f + * @returns {List} + */ + map(_f) { + return this; + } + /** + * @template U + * @type {Apply['ap']} + * @this {Empty} + * @param {List>} _b + * @returns {List} + */ + ap(_b) { + return ( + /** @type {List} */ + this + ); + } + /** + * @type {SemigroupT['concat']} + */ + concat(b) { + return b; + } + /** + * @type {FoldableT['reduce']} + */ + reduce(_f, acc) { + return acc; + } + count() { + return 0; + } + /** @returns {this is Empty} */ + isEmpty() { + return true; + } + toString() { + return `List(Empty)`; + } + }; + var empty = new Empty(); + + // node_modules/kojima/src/algebra/free.js + var Interfaces4 = Algebra(Monad); + + // node_modules/kojima/src/algebra/io.js + var IO = class _IO extends Algebra(Monad) { + _effect; + /** + * @param {T} effect + */ + constructor(effect) { + super(); + this._effect = effect; + } + /** + * @template {Fn} T + * @param {T} a + */ + static of(a) { + return new _IO(() => a); + } + /** + * @template {Fn} U + * @type {Chain['chain']} + * @param {Morphism>} f + * @returns {IO} + */ + chain(f) { + return ( + /** @type {IO} */ + _IO.of(() => f(this.run()).run()) + ); + } + /** + * @template {Fn} U + * @type {Functor['map']} + * @param {Morphism} f + * @returns {IO} + */ + map(f) { + return ( + /** @type {IO} */ + _IO.of(() => f(this.run())) + ); + } + /** + * @template {Fn} U + * @type {Apply['ap']} + * @param {IO>} other + * @returns {IO} + */ + ap(other) { + return ( + /** @type {IO} */ + _IO.of(() => other.run()(this.run())) + ); + } + run() { + return this._effect(); + } + toString() { + return `IO(${this._effect})`; + } + }; + + // node_modules/kojima/vendor/izuna/src/curry.js + function curryN(arity, func) { + return function curried(...args) { + if (args.length >= arity) { + return func.apply(this, args); + } else { + return function(...args2) { + return curried.apply(this, args.concat(args2)); + }; + } + }; + } + function curry(func) { + return curryN(func.length, func); + } + + // node_modules/kojima/vendor/izuna/src/list.js + function isIterable(value) { + return value[Symbol.iterator] != null; + } + function* iter(value) { + if (isIterable(value)) { + yield* Iterator.from(value); + } else { + yield value; + } + } + var concat = function* (...iterators) { + for (const iter3 of iterators) { + for (const item of Iterator.from(iter3)) { + yield item; + } + } + }; + var prepend = curry( + /** + * @template T + * @param {T} x + * @param {Iterable} xs + */ + (x, xs) => concat([x], xs) + ); + + // node_modules/kojima/vendor/izuna/src/function.js + var id2 = (x) => x; + var compose = curry( + /** + * @template T, U, V + * @param {Morphism} f + * @param {Morphism} g + * @param {T} x + * @returns V + */ + (f, g, x) => chain(g, chain(f, x)) + ); + var liftA = (a) => Array.isArray(a) ? a : [a]; + var liftF = curry((binary, x, y) => binary(x, y)); + var ifElse = curry( + /** + * @template T + * @param {Predicate} pred + * @param {InferredMorphism} pass + * @param {InferredMorphism} fail + * @param {T} x + */ + (pred, pass, fail2, x) => pred(x) ? pass(x) : fail2(x) + ); + var when = curry( + /** + * @template T + * @param {Predicate} pred + * @param {InferredMorphism} pass + * @param {T} x + */ + (pred, pass, x) => ifElse(pred, pass, id2, x) + ); + var unless = curry( + /** + * @template T + * @param {Predicate} pred + * @param {InferredMorphism} fail + * @param {T} x + */ + (pred, fail2, x) => ifElse(pred, id2, fail2, x) + ); + var ap = curry( + /** + * @template A, B + * @template {Morphism} Ap + * @param {Morphism} f + * @param {{ ap: Ap } | Ap} a + */ + (f, a) => { + const fs = liftA(dispatchF("ap", f)); + const args = liftA(a); + const xs = fs.reduce((acc, f2) => concat(acc, iter(map(f2, args))), []); + return [...xs]; + } + ); + var chain = curry( + function chain2(f, a) { + } + ); + var map = curry((f, a) => { + }); + var reduce = curry((f, acc, xs) => { + }); + + // node_modules/kojima/vendor/izuna/src/type.js + var is = curry( + /** + * @template T + * @param {FunctionConstructor} ctr + * @param {T} x + */ + (ctr, x) => x.constructor === ctr + ); + var isArray = Array.isArray; + + // node_modules/kojima/src/algebra/reader.js + var Reader = class _Reader extends Algebra(Monad) { + #run; + /** @param {InferredMorphism} run */ + constructor(run) { + super(); + this.#run = run; + } + /** + * @template T + * @type {ApplicativeTypeRef>['of']} + * @param {T} a + * @returns {Reader} + */ + static of(a) { + return new _Reader( + /** @type {InferredMorphism} */ + (_env) => a + ); + } + /** @template T */ + static ask() { + return new _Reader( + /** @type {InferredMorphism} */ + id2 + ); + } + /** + * @type {Functor['map']} + * @param {InferredMorphism} f + * @returns {Reader} + */ + map(f) { + return ( + /** @type {Reader} */ + this.chain((value) => _Reader.of(f(value))) + ); + } + /** + * @type {Chain['chain']} + * @param {InferredMorphism} f + * @returns {Reader} + */ + chain(f) { + return new _Reader((env) => { + const result = this.#run(env); + const next2 = f(result); + return next2.run(env); + }); + } + /** + * @template U + * @type {Apply['ap']} + * @param {Reader>} b + * @returns {Reader} + */ + ap(b) { + return ( + /** @type {Reader} */ + b.chain( + (f) => ( + /** @type {Reader} */ + this.map(f) + ) + ) + ); + } + /** + * @param {InferredMorphism} f + * @returns {Reader} + */ + local(f) { + return new _Reader( + /** @type {InferredMorphism} */ + (env) => this.#run(f(env)) + ); + } + /** + * @template U + * @param {T} env + * @returns {U} + */ + run(env) { + return this.#run(env); + } + }; + + // node_modules/izuna/src/curry.js + function curryN2(arity, func) { + return function curried(...args) { + if (args.length >= arity) { + return func.apply(this, args); + } else { + return function(...args2) { + return curried.apply(this, args.concat(args2)); + }; + } + }; + } + function curry2(func) { + return curryN2(func.length, func); + } + + // node_modules/izuna/src/list.js + function isIterable2(value) { + return value[Symbol.iterator] != null; + } + function* iter2(value) { + if (isIterable2(value)) { + yield* Iterator.from(value); + } else { + yield value; + } + } + var concat2 = function* (...iterators) { + for (const iter3 of iterators) { + for (const item of Iterator.from(iter3)) { + yield item; + } + } + }; + var prepend2 = curry2( + /** + * @template T + * @param {T} x + * @param {Iterable} xs + */ + (x, xs) => concat2([x], xs) + ); + + // node_modules/izuna/src/function.js + var id3 = (x) => x; + var pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x); + var compose2 = curry2( + /** + * @template T, U, V + * @param {Morphism} f + * @param {Morphism} g + * @param {T} x + * @returns V + */ + (f, g, x) => chain3(g, chain3(f, x)) + ); + var liftA2 = (a) => Array.isArray(a) ? a : [a]; + var liftF2 = curry2((binary, x, y) => binary(x, y)); + var ifElse2 = curry2( + /** + * @template T + * @param {Predicate} pred + * @param {InferredMorphism} pass + * @param {InferredMorphism} fail + * @param {T} x + */ + (pred, pass, fail2, x) => pred(x) ? pass(x) : fail2(x) + ); + var when2 = curry2( + /** + * @template T + * @param {Predicate} pred + * @param {InferredMorphism} pass + * @param {T} x + */ + (pred, pass, x) => ifElse2(pred, pass, id3, x) + ); + var unless2 = curry2( + /** + * @template T + * @param {Predicate} pred + * @param {InferredMorphism} fail + * @param {T} x + */ + (pred, fail2, x) => ifElse2(pred, id3, fail2, x) + ); + var ap2 = curry2( + /** + * @template A, B + * @template {Morphism} Ap + * @param {Morphism} f + * @param {{ ap: Ap } | Ap} a + */ + (f, a) => { + const fs = liftA2(dispatchF("ap", f)); + const args = liftA2(a); + const xs = fs.reduce((acc, f2) => concat2(acc, iter2(map2(f2, args))), []); + return [...xs]; + } + ); + var chain3 = curry2( + function chain4(f, a) { + } + ); + var map2 = curry2((f, a) => { + }); + var reduce2 = curry2((f, acc, xs) => { + }); + + // node_modules/izuna/src/type.js + var is2 = curry2( + /** + * @template T + * @param {FunctionConstructor} ctr + * @param {T} x + */ + (ctr, x) => x.constructor === ctr + ); + var isArray2 = Array.isArray; + + // src/fn.js + var Tuple = (...values) => Object.freeze(values); + var clone = ([h, iter3]) => [h, iter3.clone()]; + var succeed = (v, [x, y]) => ok(Tuple(x.concat(v), y)); + var fail = (msg, state, e = void 0) => err(new ParseError(msg, state, e)); + var next = (state) => state[1].next().value; + var diff = (a, b) => b.slice(-Math.max(0, b.length - a.length)); + var join = curry2( + /** + * @param {string} delim + * @param {string[]} val + */ + (delim, val) => val.join(delim) + ); + var mapStr = curry2( + /** + * @param {(...args: any[]) => any} fn + * @param {string} str + */ + (fn, str2) => Array.from(str2).map((v) => fn(v)) + ); + + // src/seq.js + var take = (n) => (state) => { + let result = anyChar(state); + for (let i = n; i > 0; i--) { + if (result.isErr()) { + return result.chain((e) => fail(`"take(${n})" failed`, state, e)); + } + result = result.chain(anyChar); + } + return result; + }; + var seq = (...parsers) => ( + /** @param {ParserState} state */ + (state) => { + let acc = ok(state); + for (const parser of parsers) { + if (acc.isOk()) { + acc = acc.chain(parser); + } else { + break; + } + } + return acc; + } + ); + var many = curry2((parser, state) => { + let result = ok(state); + while (true) { + const res = parser(clone(state)); + if (res.isOk()) { + result = res; + } else { + break; + } + } + return result; + }); + var many1 = (parser) => seq(parser, many(parser)); + + // src/cond.js + var maybe = curry2( + /** + * @param {(...args: any[]) => Result} parser + * @param {ParserState} state + */ + (parser, state) => { + const result = parser(clone(state)); + return result.isOk() ? result : succeed([], state); + } + ); + var not = curry2((parser, state) => { + const result = parser(clone(state)); + if (result.isOk()) { + return fail(`'not' parser failed for ${parser.name}`, state); + } else { + return succeed([], state); + } + }); + var until = curry2((parser, state) => { + let result = ok(state); + while (result.isOk()) { + console.log(parser.name, state); + result = result.chain(pipe(clone, parser)); + if (result.isOk()) { + break; + } else { + result = anyChar(state); + } + } + return result; + }); + var skip = curry2((parser, state) => { + }); + + // src/combinator.js + var any = (...parsers) => ( + /** + * @param {ParserState} state + */ + (state) => { + for (const parser of parsers) { + const result = parser(clone(state)); + if (result.isOk()) { + return result; + } + } + return fail("no matching parsers", state); + } + ); + var anyOf = curry2( + /** + * @param {string} str + * @param {ParserState} state + */ + (str2, state) => any(...mapStr(char, str2))(state) + ); + var map3 = curry2( + /** + * @param {(...args: any[]) => any} fn + * @param {Parser} parser + * @param {ParserState} state + */ + (fn, parser, state) => { + return parser(state).chain((result) => { + try { + const parsed = fn(diff(state[0], result[0])); + const backtrack = Tuple(state[0], result[1]); + return succeed(parsed, backtrack); + } catch (e) { + return fail("failed to map", state, e); + } + }); + } + ); + var eof = (state) => { + return clone(state).next().done ? succeed([], state) : fail("not end of stream", state); + }; + + // src/state.js + var ParseError = class extends Error { + /** + * @param {string} message + * @param {ParserState} state + * @param {Error} [cause] + */ + constructor(message, state, cause) { + super(message, { cause }); + this.state = state; + } + }; + var State = (value) => Object.freeze([[], Iter.from(value)]); + var parse = curry2((parser, input) => parser(State(input))); + var parseAll = curry2((parser, input) => pipe( + State, + seq( + parser, + until(eof) + ) + )(input)); + + // src/const.js + var LowerAlpha = "abcdefghijklmnopqrstuvwxyz"; + var UpperAlpha = LowerAlpha.toUpperCase(); + var Alpha = LowerAlpha + UpperAlpha; + var Digits = "1234567890"; + var Alphanumeric = Alpha + Digits; + + // src/char.js + var char = curry2( + /** + * @param {string} ch + * @param {ParserState} state + */ + (ch, state) => next(state) === ch ? succeed(ch, state) : fail(`could not parse ${ch} `, state) + ); + var str = curry2( + /** + * @param {string} str + * @param {ParserState} state + */ + (str2, state) => map3( + join(""), + seq(...mapStr(char, str2)) + )(state) + ); + var anyChar = (state) => { + const ch = next(state); + return !!ch ? succeed(ch, state) : fail("end of input", state); + }; + var digit = anyOf(Digits); + var lowerAlpha = anyOf(LowerAlpha); + var upperAlpha = anyOf(UpperAlpha); + var alpha = any(lowerAlpha, upperAlpha); + var alphanumeric = any(alpha, digit); +})(); diff --git a/package-lock.json b/package-lock.json index 327c712..e48dff3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,15 +8,512 @@ "name": "kuebiko", "version": "1.0.0", "license": "ISC", + "dependencies": { + "izuna": "git+https://git.kitsu.cafe/rowan/izuna.git", + "kojima": "git+https://git.kitsu.cafe/rowan/kojima.git" + }, "devDependencies": { + "esbuild": "^0.25.2", "folktest": "git+https://git.kitsu.cafe/rowan/folktest.git" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz", + "integrity": "sha512-wCIboOL2yXZym2cgm6mlA742s9QeJ8DjGVaL39dLN4rRwrOgOyYSnOaFPhKZGLb2ngj4EyfAFjsNJwPXZvseag==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.2.tgz", + "integrity": "sha512-NQhH7jFstVY5x8CKbcfa166GoV0EFkaPkCKBQkdPJFvo5u+nGXLEH/ooniLb3QI8Fk58YAx7nsPLozUWfCBOJA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.2.tgz", + "integrity": "sha512-5ZAX5xOmTligeBaeNEPnPaeEuah53Id2tX4c2CVP3JaROTH+j4fnfHCkr1PjXMd78hMst+TlkfKcW/DlTq0i4w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.2.tgz", + "integrity": "sha512-Ffcx+nnma8Sge4jzddPHCZVRvIfQ0kMsUsCMcJRHkGJ1cDmhe4SsrYIjLUKn1xpHZybmOqCWwB0zQvsjdEHtkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.2.tgz", + "integrity": "sha512-MpM6LUVTXAzOvN4KbjzU/q5smzryuoNjlriAIx+06RpecwCkL9JpenNzpKd2YMzLJFOdPqBpuub6eVRP5IgiSA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.2.tgz", + "integrity": "sha512-5eRPrTX7wFyuWe8FqEFPG2cU0+butQQVNcT4sVipqjLYQjjh8a8+vUTfgBKM88ObB85ahsnTwF7PSIt6PG+QkA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.2.tgz", + "integrity": "sha512-mLwm4vXKiQ2UTSX4+ImyiPdiHjiZhIaE9QvC7sw0tZ6HoNMjYAqQpGyui5VRIi5sGd+uWq940gdCbY3VLvsO1w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.2.tgz", + "integrity": "sha512-6qyyn6TjayJSwGpm8J9QYYGQcRgc90nmfdUb0O7pp1s4lTY+9D0H9O02v5JqGApUyiHOtkz6+1hZNvNtEhbwRQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.2.tgz", + "integrity": "sha512-UHBRgJcmjJv5oeQF8EpTRZs/1knq6loLxTsjc3nxO9eXAPDLcWW55flrMVc97qFPbmZP31ta1AZVUKQzKTzb0g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.2.tgz", + "integrity": "sha512-gq/sjLsOyMT19I8obBISvhoYiZIAaGF8JpeXu1u8yPv8BE5HlWYobmlsfijFIZ9hIVGYkbdFhEqC0NvM4kNO0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.2.tgz", + "integrity": "sha512-bBYCv9obgW2cBP+2ZWfjYTU+f5cxRoGGQ5SeDbYdFCAZpYWrfjjfYwvUpP8MlKbP0nwZ5gyOU/0aUzZ5HWPuvQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.2.tgz", + "integrity": "sha512-SHNGiKtvnU2dBlM5D8CXRFdd+6etgZ9dXfaPCeJtz+37PIUlixvlIhI23L5khKXs3DIzAn9V8v+qb1TRKrgT5w==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.2.tgz", + "integrity": "sha512-hDDRlzE6rPeoj+5fsADqdUZl1OzqDYow4TB4Y/3PlKBD0ph1e6uPHzIQcv2Z65u2K0kpeByIyAjCmjn1hJgG0Q==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.2.tgz", + "integrity": "sha512-tsHu2RRSWzipmUi9UBDEzc0nLc4HtpZEI5Ba+Omms5456x5WaNuiG3u7xh5AO6sipnJ9r4cRWQB2tUjPyIkc6g==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.2.tgz", + "integrity": "sha512-k4LtpgV7NJQOml/10uPU0s4SAXGnowi5qBSjaLWMojNCUICNu7TshqHLAEbkBdAszL5TabfvQ48kK84hyFzjnw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.2.tgz", + "integrity": "sha512-GRa4IshOdvKY7M/rDpRR3gkiTNp34M0eLTaC1a08gNrh4u488aPhuZOCpkF6+2wl3zAN7L7XIpOFBhnaE3/Q8Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.2.tgz", + "integrity": "sha512-QInHERlqpTTZ4FRB0fROQWXcYRD64lAoiegezDunLpalZMjcUcld3YzZmVJ2H/Cp0wJRZ8Xtjtj0cEHhYc/uUg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.2.tgz", + "integrity": "sha512-talAIBoY5M8vHc6EeI2WW9d/CkiO9MQJ0IOWX8hrLhxGbro/vBXJvaQXefW2cP0z0nQVTdQ/eNyGFV1GSKrxfw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.2.tgz", + "integrity": "sha512-voZT9Z+tpOxrvfKFyfDYPc4DO4rk06qamv1a/fkuzHpiVBMOhpjK+vBmWM8J1eiB3OLSMFYNaOaBNLXGChf5tg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.2.tgz", + "integrity": "sha512-dcXYOC6NXOqcykeDlwId9kB6OkPUxOEqU+rkrYVqJbK2hagWOMrsTGsMr8+rW02M+d5Op5NNlgMmjzecaRf7Tg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.2.tgz", + "integrity": "sha512-t/TkWwahkH0Tsgoq1Ju7QfgGhArkGLkF1uYz8nQS/PPFlXbP5YgRpqQR3ARRiC2iXoLTWFxc6DJMSK10dVXluw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.2.tgz", + "integrity": "sha512-cfZH1co2+imVdWCjd+D1gf9NjkchVhhdpgb1q5y6Hcv9TP6Zi9ZG/beI3ig8TvwT9lH9dlxLq5MQBBgwuj4xvA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.2.tgz", + "integrity": "sha512-7Loyjh+D/Nx/sOTzV8vfbB3GJuHdOQyrOryFdZvPHLf42Tk9ivBU5Aedi7iyX+x6rbn2Mh68T4qq1SDqJBQO5Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.2.tgz", + "integrity": "sha512-WRJgsz9un0nqZJ4MfhabxaD9Ft8KioqU3JMinOTvobbX6MOSUigSBlogP8QB3uxpJDsFS6yN+3FDBdqE5lg9kg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.2.tgz", + "integrity": "sha512-kM3HKb16VIXZyIeVrM1ygYmZBKybX8N4p754bw390wGO3Tf2j4L2/WYL+4suWujpgf6GBYs3jv7TyUivdd05JA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/esbuild": { + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.2.tgz", + "integrity": "sha512-16854zccKPnC+toMywC+uKNeYSv+/eXkevRAfwRD/G9Cleq66m8XFIrigkbvauLLlCfDL45Q2cWegSg53gGBnQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.2", + "@esbuild/android-arm": "0.25.2", + "@esbuild/android-arm64": "0.25.2", + "@esbuild/android-x64": "0.25.2", + "@esbuild/darwin-arm64": "0.25.2", + "@esbuild/darwin-x64": "0.25.2", + "@esbuild/freebsd-arm64": "0.25.2", + "@esbuild/freebsd-x64": "0.25.2", + "@esbuild/linux-arm": "0.25.2", + "@esbuild/linux-arm64": "0.25.2", + "@esbuild/linux-ia32": "0.25.2", + "@esbuild/linux-loong64": "0.25.2", + "@esbuild/linux-mips64el": "0.25.2", + "@esbuild/linux-ppc64": "0.25.2", + "@esbuild/linux-riscv64": "0.25.2", + "@esbuild/linux-s390x": "0.25.2", + "@esbuild/linux-x64": "0.25.2", + "@esbuild/netbsd-arm64": "0.25.2", + "@esbuild/netbsd-x64": "0.25.2", + "@esbuild/openbsd-arm64": "0.25.2", + "@esbuild/openbsd-x64": "0.25.2", + "@esbuild/sunos-x64": "0.25.2", + "@esbuild/win32-arm64": "0.25.2", + "@esbuild/win32-ia32": "0.25.2", + "@esbuild/win32-x64": "0.25.2" + } + }, "node_modules/folktest": { "version": "1.0.0", "resolved": "git+https://git.kitsu.cafe/rowan/folktest.git#708d44f1215be33fcceba426029f44b4f963dbe5", "dev": true, "license": "GPL-3.0-or-later" + }, + "node_modules/izuna": { + "version": "1.0.0", + "resolved": "git+https://git.kitsu.cafe/rowan/izuna.git#e11a0870c27eeb5ea1a4ae3fedccca008eda15c2", + "license": "GPL-3.0-or-later" + }, + "node_modules/kojima": { + "version": "1.0.0", + "resolved": "git+https://git.kitsu.cafe/rowan/kojima.git#d6615248572d2e5c16661d8aab0650ae28aeb6c2", + "license": "GPL-3.0-or-later", + "dependencies": { + "typescript": "^5.8.2" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } } } } diff --git a/package.json b/package.json index 6a17f30..111365b 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,21 @@ "name": "kuebiko", "version": "1.0.0", "type": "module", - "main": "index.js", + "main": "./src/index.js", "author": "Rowan (https://kitsu.cafe)", "scripts": { - "test": "./tests/index.js" + "test": "./tests/index.js", + "build": "esbuild ./src/index.js --bundle --outfile=dist/index.js" }, "keywords": [], "license": "ISC", "description": "", "devDependencies": { + "esbuild": "^0.25.2", "folktest": "git+https://git.kitsu.cafe/rowan/folktest.git" + }, + "dependencies": { + "izuna": "git+https://git.kitsu.cafe/rowan/izuna.git", + "kojima": "git+https://git.kitsu.cafe/rowan/kojima.git" } } diff --git a/src/char.js b/src/char.js index 89f1f6c..79c66f7 100644 --- a/src/char.js +++ b/src/char.js @@ -3,7 +3,7 @@ import { any, anyOf, map } from './combinator.js' import { Alpha, Alphanumeric, Digits, LowerAlpha, UpperAlpha } from './const.js' import { fail, join, mapStr, next, succeed } from './fn.js' import { seq } from './seq.js' -import { curry } from '../vendor/izuna/src/curry.js' +import { curry } from 'izuna' /** @import { ParserState } from './state.js' */ diff --git a/src/combinator.js b/src/combinator.js index 1e519d3..87c3c84 100644 --- a/src/combinator.js +++ b/src/combinator.js @@ -1,6 +1,6 @@ import { char } from './char.js' import { clone, diff, fail, mapStr, succeed, Tuple } from './fn.js' -import { curry } from '../vendor/izuna/src/curry.js' +import { curry } from 'izuna' /** @import { ParserState } from './state.js' */ diff --git a/src/cond.js b/src/cond.js index ac6436a..aca738d 100644 --- a/src/cond.js +++ b/src/cond.js @@ -1,8 +1,8 @@ import { ParseError } from './state.js' import { clone, fail, fork, succeed } from './fn.js' import { anyChar } from './char.js' -import { ok } from '../vendor/kojima/src/index.js' -import { curry, pipe } from '../vendor/izuna/src/index.js' +import { ok } from 'kojima' +import { curry, pipe } from 'izuna' /** @import { Result } from '../vendor/kojima/src/index.js' */ /** @import { ParserState } from './state.js' */ diff --git a/src/fn.js b/src/fn.js index edd8bdd..b8c2390 100644 --- a/src/fn.js +++ b/src/fn.js @@ -1,7 +1,7 @@ import { ParseError } from './state.js' import { Iter } from './iter.js' -import { err, ok } from '../vendor/kojima/src/index.js' -import { curry } from '../vendor/izuna/src/index.js' +import { err, ok } from 'kojima' +import { curry } from 'izuna' /** @import { ParserState } from './state.js'* / diff --git a/src/seq.js b/src/seq.js index 04ef349..335d028 100644 --- a/src/seq.js +++ b/src/seq.js @@ -1,7 +1,7 @@ import { clone, diff, fail, succeed, Tuple } from './fn.js' -import { ok } from '../vendor/kojima/src/index.js' -import { curry } from '../vendor/izuna/src/curry.js' import { anyChar } from './char.js' +import { ok } from 'kojima' +import { curry } from 'izuna' /** @import { ParseError, ParserState } from './state.js' */ /** @import { Result } from '../vendor/kojima/src/index.js' */ diff --git a/src/state.js b/src/state.js index 04557b6..94c661b 100644 --- a/src/state.js +++ b/src/state.js @@ -1,8 +1,9 @@ import { Iter } from './iter.js' -import { curry, pipe } from '../vendor/izuna/src/index.js' import { seq } from './seq.js' import { until } from './cond.js' import { eof } from './combinator.js' +import { curry, pipe } from 'izuna' + /** * @typedef {Readonly<[any[], Iterator]>} ParserState */ diff --git a/vendor/izuna b/vendor/izuna deleted file mode 160000 index aa70427..0000000 --- a/vendor/izuna +++ /dev/null @@ -1 +0,0 @@ -Subproject commit aa70427c8c349bbfe4576cba878f5b44859007d4 diff --git a/vendor/kojima b/vendor/kojima deleted file mode 160000 index d661524..0000000 --- a/vendor/kojima +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d6615248572d2e5c16661d8aab0650ae28aeb6c2