{"version":3,"sources":["../src/index.ts","../src/Option.ts","../src/Either.ts","../src/Try.ts","../src/ExecutionContext.ts","../src/List.ts","../src/Map.ts","../src/Set.ts","../src/collections/Iterable.ts","../src/collections/AbstractSeq.ts","../src/collections/ArraySeq.ts","../src/collections/ArrayBuffer.ts","../src/lazylist/LazyList.ts","../src/vector/Vector.ts","../src/Match.ts","../src/ForComprehension.ts","../src/TypeClass.ts","../src/tuple/Tuple.ts","../src/ordering/Ordering.ts","../src/using/Using.ts","../src/monads/state/State.ts","../src/monads/writer/Writer.ts"],"sourcesContent":["/**\n * scats - Scala-like functional programming patterns for TypeScript\n *\n * This library brings Scala-inspired functional programming concepts to TypeScript,\n * providing a type-safe and ergonomic way to write functional code in TypeScript.\n */\n\n// Core data types\nexport {\n  Option, Some, None,\n  // We need to explicitly exclude these from Option.ts\n  // as they are forward declarations that conflict with Either.ts\n} from './Option';\n\nexport {\n  Either, Left, Right\n} from './Either';\n\nexport {\n  Try, Success, Failure, TryAsync\n} from './Try';\n\nexport {\n  ExecutionContext\n} from './ExecutionContext';\n\n// Collections\nexport { List } from './List';\nexport { Map } from './Map';\nexport { Set } from './Set';\nexport * from './collections/Iterable';\nexport type { Seq, LinearSeq, IndexedSeq, MutableIndexedSeq, Buffer } from './collections/Seq';\nexport { ArraySeq } from './collections/ArraySeq';\nexport { ArrayBuffer } from './collections/ArrayBuffer';\n\n// LazyList for infinite sequences and lazy evaluation\nexport { LazyList } from './LazyList';\n\n\n// Vector for efficient indexed sequences\nexport { Vector } from './vector';\n\n// Pattern matching\nexport {\n  match, when, otherwise, extract, value, object,\n  array, or, and, not, type\n} from './Match';\nexport type { Pattern } from './Match';\n\n// For-comprehensions\nexport {\n  For, ForComprehension, ForComprehensionBuilder\n} from './ForComprehension';\nexport type { Monad, Env } from './ForComprehension';\n\n// Type classes\nexport type { TypeClass } from './TypeClass';\nexport {\n  TypeClassRegistry, GlobalTypeClassRegistry,\n  register, extension, withContext\n} from './TypeClass';\n\n// Tuples\nexport * from './tuple';\n\n// Ordering\nexport * from './ordering';\n\n// Resource management\nexport * from './using';\n\n// Monads (including new Reader monad)\nexport * from './monads';\n","/**\n * Option<A> represents an optional value that may or may not be present.\n * It's a type-safe alternative to using null or undefined.\n * \n * @example\n * ```ts\n * import { Option, Some, None } from 'scats';\n * \n * // Creating options\n * const a = Some(42);\n * const b = None;\n * const c = Option.fromNullable(maybeNull);\n * \n * // Using options\n * const result = a\n *   .map(n => n * 2)\n *   .flatMap(n => n > 50 ? Some(n) : None)\n *   .getOrElse(0);\n * ```\n */\n\n/**\n * Option<A> interface that all option implementations must satisfy\n */\nexport interface Option<A> {\n  /**\n   * Returns true if the option is a Some, false otherwise\n   */\n  readonly isSome: boolean;\n\n  /**\n   * Returns true if the option is a None, false otherwise\n   */\n  readonly isNone: boolean;\n\n  /**\n   * Returns the value if this is a Some, otherwise throws an error\n   * @throws Error if the option is None\n   */\n  get(): A;\n\n  /**\n   * Returns the value if this is a Some, otherwise returns the provided default value\n   */\n  getOrElse<B>(defaultValue: B): A | B;\n\n  /**\n   * Returns the value if this is a Some, otherwise returns the result of the provided function\n   */\n  getOrCall<B>(f: () => B): A | B;\n\n  /**\n   * Returns the value if this is a Some, otherwise throws the provided error\n   */\n  getOrThrow(error: Error): A;\n\n  /**\n   * Maps the value if this is a Some, otherwise returns None\n   */\n  map<B>(f: (a: A) => B): Option<B>;\n\n  /**\n   * Maps the value if this is a Some, otherwise returns the provided default value wrapped in Some\n   */\n  mapOr<B>(defaultValue: B, f: (a: A) => B): Option<B>;\n\n  /**\n   * Returns the result of applying f if this is a Some, otherwise returns None\n   */\n  flatMap<B>(f: (a: A) => Option<B>): Option<B>;\n\n  /**\n   * Returns the option if it is a Some, otherwise returns the provided option\n   */\n  orElse<B>(alternative: Option<B>): Option<A | B>;\n\n  /**\n   * Returns the option if it is a Some, otherwise returns the result of the provided function\n   */\n  orCall<B>(f: () => Option<B>): Option<A | B>;\n\n  /**\n   * Returns None if the predicate is not satisfied, otherwise returns this option\n   */\n  filter(predicate: (a: A) => boolean): Option<A>;\n\n  /**\n   * Executes the provided function if this is a Some\n   */\n  forEach(f: (a: A) => void): void;\n\n  /**\n   * Converts the option to an array with the value if it's a Some, or an empty array if it's a None\n   */\n  toArray(): A[];\n\n  /**\n   * Converts this option to an Either with the provided left value if this is a None\n   */\n  toEither<E>(left: E): Either<E, A>;\n\n  /**\n   * Returns the result of applying the appropriate function\n   */\n  match<B>(patterns: { Some: (value: A) => B; None: () => B }): B;\n}\n\n/**\n * Some<A> represents an optional value that is present\n */\nexport class SomeImpl<A> implements Option<A> {\n  constructor(private readonly value: A) {\n    if (value === null || value === undefined) {\n      throw new Error(\"Cannot create Some with null or undefined value\");\n    }\n  }\n\n  get isSome(): boolean {\n    return true;\n  }\n\n  get isNone(): boolean {\n    return false;\n  }\n\n  get(): A {\n    return this.value;\n  }\n\n  getOrElse<B>(_defaultValue: B): A {\n    return this.value;\n  }\n\n  getOrCall<B>(_f: () => B): A {\n    return this.value;\n  }\n\n  getOrThrow(_error: Error): A {\n    return this.value;\n  }\n\n  map<B>(f: (a: A) => B): Option<B> {\n    return Some(f(this.value));\n  }\n\n  mapOr<B>(_defaultValue: B, f: (a: A) => B): Option<B> {\n    return Some(f(this.value));\n  }\n\n  flatMap<B>(f: (a: A) => Option<B>): Option<B> {\n    return f(this.value);\n  }\n\n  orElse<B>(_alternative: Option<B>): Option<A> {\n    return this;\n  }\n\n  orCall<B>(_f: () => Option<B>): Option<A> {\n    return this;\n  }\n\n  filter(predicate: (a: A) => boolean): Option<A> {\n    return predicate(this.value) ? this : None;\n  }\n\n  forEach(f: (a: A) => void): void {\n    f(this.value);\n  }\n\n  toArray(): A[] {\n    return [this.value];\n  }\n\n  toEither<E>(_left: E): Either<E, A> {\n    return Right(this.value) as any; // Forward reference to Either module\n  }\n\n  match<B>(patterns: { Some: (value: A) => B; None: () => B }): B {\n    return patterns.Some(this.value);\n  }\n\n  toString(): string {\n    return `Some(${this.value})`;\n  }\n}\n\n/**\n * None represents an optional value that is not present\n */\nexport class NoneImpl implements Option<never> {\n  get isSome(): boolean {\n    return false;\n  }\n\n  get isNone(): boolean {\n    return true;\n  }\n\n  get(): never {\n    throw new Error(\"Cannot get value from None\");\n  }\n\n  getOrElse<B>(defaultValue: B): B {\n    return defaultValue;\n  }\n\n  getOrCall<B>(f: () => B): B {\n    return f();\n  }\n\n  getOrThrow(error: Error): never {\n    throw error;\n  }\n\n  map<B>(_f: (a: never) => B): Option<B> {\n    return this as unknown as Option<B>;\n  }\n\n  mapOr<B>(defaultValue: B, _f: (a: never) => B): Option<B> {\n    return Some(defaultValue);\n  }\n\n  flatMap<B>(_f: (a: never) => Option<B>): Option<B> {\n    return this as unknown as Option<B>;\n  }\n\n  orElse<B>(alternative: Option<B>): Option<B> {\n    return alternative;\n  }\n\n  orCall<B>(f: () => Option<B>): Option<B> {\n    return f();\n  }\n\n  filter(_predicate: (a: never) => boolean): Option<never> {\n    return this;\n  }\n\n  forEach(_f: (a: never) => void): void {\n    // Do nothing\n  }\n\n  toArray(): never[] {\n    return [];\n  }\n\n  toEither<E>(left: E): Either<E, never> {\n    return Left(left) as any; // Forward reference to Either module\n  }\n\n  match<B>(patterns: { Some: (value: never) => B; None: () => B }): B {\n    return patterns.None();\n  }\n\n  toString(): string {\n    return \"None\";\n  }\n}\n\n// Singleton instance of None\nexport const None = new NoneImpl();\n\n// Constructor function for Some\nexport function Some<A>(value: A): Option<A> {\n  if (value === null || value === undefined) {\n    return None as Option<A>;\n  }\n  return new SomeImpl(value);\n}\n\n// Option namespace with utility functions\nexport namespace Option {\n  /**\n   * Creates an Option from a nullable value\n   */\n  export function fromNullable<A>(value: A | null | undefined): Option<A> {\n    return value === null || value === undefined ? None : Some(value);\n  }\n\n  /**\n   * Creates an Option from a function that might throw\n   */\n  export function tryCatch<A>(f: () => A): Option<A> {\n    try {\n      return Some(f());\n    } catch (e) {\n      return None;\n    }\n  }\n\n  /**\n   * Returns the first Some in the list, or None if all are None\n   */\n  export function firstSome<A>(...options: Option<A>[]): Option<A> {\n    for (const option of options) {\n      if (option.isSome) return option;\n    }\n    return None;\n  }\n\n  /**\n   * Returns a Some containing an array of all values if all options are Some, None otherwise\n   */\n  export function sequence<A>(options: Option<A>[]): Option<A[]> {\n    const values: A[] = [];\n    for (const option of options) {\n      if (option.isNone) return None;\n      values.push(option.get());\n    }\n    return Some(values);\n  }\n\n  /**\n   * Maps an array of values using a function that returns an Option, then sequences the result\n   */\n  export function traverse<A, B>(\n    values: A[],\n    f: (a: A) => Option<B>\n  ): Option<B[]> {\n    return sequence(values.map(f));\n  }\n}\n\n// Forward references to Either types - removing unused type parameters\nexport interface Either<E, A> {\n  isLeft: boolean;\n  isRight: boolean;\n  get(): A;\n  getLeft(): E;\n  // More definitions in Either.ts\n}\n\nexport function Left<E>(left: E): Either<E, never> {\n  return {\n    isLeft: true,\n    isRight: false,\n    get: () => { throw new Error(\"Cannot get value from Left\"); },\n    getLeft: () => left\n  } as any; // Simplified for forward reference\n}\n\nexport function Right<A>(right: A): Either<never, A> {\n  return {\n    isLeft: false,\n    isRight: true,\n    get: () => right,\n    getLeft: () => { throw new Error(\"Cannot get left from Right\"); }\n  } as any; // Simplified for forward reference\n} ","/**\n * Either<E, A> represents a value of one of two possible types: Left (E) or Right (A).\n * Left is conventionally used for errors, while Right is used for success.\n * \n * @example\n * ```ts\n * import { Either, Left, Right } from 'scats';\n * \n * // Creating eithers\n * const success = Right(42);\n * const failure = Left(new Error(\"Something went wrong\"));\n * \n * // Using eithers\n * const result = success\n *   .map(n => n * 2)\n *   .flatMap(n => n > 50 ? Right(n) : Left(\"Value too small\"))\n *   .getOrElse(0);\n * ```\n */\n\nimport { Option, Some, None } from './Option';\n\n/**\n * Either<E, A> interface that all Either implementations must satisfy\n */\nexport interface Either<E, A> {\n  /**\n   * Returns true if this is a Left, false otherwise\n   */\n  readonly isLeft: boolean;\n\n  /**\n   * Returns true if this is a Right, false otherwise\n   */\n  readonly isRight: boolean;\n\n  /**\n   * Returns the value from this Right, or throws an error if this is a Left\n   * @throws Error if this is a Left\n   */\n  get(): A;\n\n  /**\n   * Returns the left value if this is a Left, or throws an error if this is a Right\n   * @throws Error if this is a Right\n   */\n  getLeft(): E;\n\n  /**\n   * Returns the value from this Right, or returns the provided default value if this is a Left\n   */\n  getOrElse<B>(defaultValue: B): A | B;\n\n  /**\n   * Returns the value from this Right, or returns the result of the provided function if this is a Left\n   */\n  getOrCall<B>(f: (e: E) => B): A | B;\n\n  /**\n   * Returns the value from this Right, or throws the provided error if this is a Left\n   */\n  getOrThrow(error: Error): A;\n\n  /**\n   * Maps the Right value if this is a Right, otherwise returns this Left unchanged\n   */\n  map<B>(f: (a: A) => B): Either<E, B>;\n\n  /**\n   * Maps the Left value if this is a Left, otherwise returns this Right unchanged\n   */\n  mapLeft<F>(f: (e: E) => F): Either<F, A>;\n\n  /**\n   * Returns the result of applying f if this is a Right, otherwise returns this Left unchanged\n   */\n  flatMap<B>(f: (a: A) => Either<E, B>): Either<E, B>;\n\n  /**\n   * Returns this Right if this is a Right, otherwise returns the provided alternative\n   */\n  orElse<F, B>(alternative: Either<F, B>): Either<E | F, A | B>;\n\n  /**\n   * Returns this Right if this is a Right, otherwise returns the result of the provided function\n   */\n  orCall<F, B>(f: (e: E) => Either<F, B>): Either<E | F, A | B>;\n\n  /**\n   * Executes one of the provided functions based on whether this is a Left or a Right\n   */\n  fold<B>(onLeft: (e: E) => B, onRight: (a: A) => B): B;\n\n  /**\n   * Executes the provided function if this is a Right\n   */\n  forEach(f: (a: A) => void): void;\n\n  /**\n   * Executes the provided function if this is a Left\n   */\n  forEachLeft(f: (e: E) => void): void;\n\n  /**\n   * Converts this Either to an Option, discarding the Left value if this is a Left\n   */\n  toOption(): Option<A>;\n\n  /**\n   * Swaps the Left and Right values of this Either\n   */\n  swap(): Either<A, E>;\n\n  /**\n   * Returns the result of applying the appropriate function\n   */\n  match<B>(patterns: { Left: (value: E) => B; Right: (value: A) => B }): B;\n}\n\n/**\n * Left<E, A> represents the Left case of an Either\n */\nexport class LeftImpl<E, A = never> implements Either<E, A> {\n  constructor(private readonly value: E) {\n    if (value === null || value === undefined) {\n      throw new Error(\"Cannot create Left with null or undefined value\");\n    }\n  }\n\n  get isLeft(): boolean {\n    return true;\n  }\n\n  get isRight(): boolean {\n    return false;\n  }\n\n  get(): A {\n    throw new Error(\"Cannot get Right value from Left\");\n  }\n\n  getLeft(): E {\n    return this.value;\n  }\n\n  getOrElse<B>(defaultValue: B): B {\n    return defaultValue;\n  }\n\n  getOrCall<B>(f: (e: E) => B): B {\n    return f(this.value);\n  }\n\n  getOrThrow(error: Error): A {\n    throw error;\n  }\n\n  map<B>(_f: (a: A) => B): Either<E, B> {\n    return this as unknown as Either<E, B>;\n  }\n\n  mapLeft<F>(f: (e: E) => F): Either<F, A> {\n    return Left(f(this.value));\n  }\n\n  flatMap<B>(_f: (a: A) => Either<E, B>): Either<E, B> {\n    return this as unknown as Either<E, B>;\n  }\n\n  orElse<F, B>(alternative: Either<F, B>): Either<F, B> {\n    return alternative;\n  }\n\n  orCall<F, B>(f: (e: E) => Either<F, B>): Either<F, B> {\n    return f(this.value);\n  }\n\n  fold<B>(onLeft: (e: E) => B, _onRight: (a: A) => B): B {\n    return onLeft(this.value);\n  }\n\n  forEach(_f: (a: A) => void): void {\n    // Do nothing\n  }\n\n  forEachLeft(f: (e: E) => void): void {\n    f(this.value);\n  }\n\n  toOption(): Option<A> {\n    return None;\n  }\n\n  swap(): Either<A, E> {\n    return Right(this.value) as Either<A, E>;\n  }\n\n  match<B>(patterns: { Left: (value: E) => B; Right: (value: A) => B }): B {\n    return patterns.Left(this.value);\n  }\n\n  toString(): string {\n    return `Left(${this.value})`;\n  }\n}\n\n/**\n * Right<E, A> represents the Right case of an Either\n */\nexport class RightImpl<E, A> implements Either<E, A> {\n  constructor(private readonly value: A) {\n    if (value === null || value === undefined) {\n      throw new Error(\"Cannot create Right with null or undefined value\");\n    }\n  }\n\n  get isLeft(): boolean {\n    return false;\n  }\n\n  get isRight(): boolean {\n    return true;\n  }\n\n  get(): A {\n    return this.value;\n  }\n\n  getLeft(): E {\n    throw new Error(\"Cannot get Left value from Right\");\n  }\n\n  getOrElse<B>(_defaultValue: B): A {\n    return this.value;\n  }\n\n  getOrCall<B>(_f: (e: E) => B): A {\n    return this.value;\n  }\n\n  getOrThrow(_error: Error): A {\n    return this.value;\n  }\n\n  map<B>(f: (a: A) => B): Either<E, B> {\n    return Right(f(this.value));\n  }\n\n  mapLeft<F>(_f: (e: E) => F): Either<F, A> {\n    return this as unknown as Either<F, A>;\n  }\n\n  flatMap<B>(f: (a: A) => Either<E, B>): Either<E, B> {\n    return f(this.value);\n  }\n\n  orElse<F, B>(_alternative: Either<F, B>): Either<E | F, A | B> {\n    return this as unknown as Either<E | F, A | B>;\n  }\n\n  orCall<F, B>(_f: (e: E) => Either<F, B>): Either<E | F, A | B> {\n    return this as unknown as Either<E | F, A | B>;\n  }\n\n  fold<B>(_onLeft: (e: E) => B, onRight: (a: A) => B): B {\n    return onRight(this.value);\n  }\n\n  forEach(f: (a: A) => void): void {\n    f(this.value);\n  }\n\n  forEachLeft(_f: (e: E) => void): void {\n    // Do nothing\n  }\n\n  toOption(): Option<A> {\n    return Some(this.value);\n  }\n\n  swap(): Either<A, E> {\n    return Left(this.value) as unknown as Either<A, E>;\n  }\n\n  match<B>(patterns: { Left: (value: E) => B; Right: (value: A) => B }): B {\n    return patterns.Right(this.value);\n  }\n\n  toString(): string {\n    return `Right(${this.value})`;\n  }\n}\n\n/**\n * Creates a Left instance\n */\nexport function Left<E, A = never>(left: E): Either<E, A> {\n  if (left === null || left === undefined) {\n    throw new Error(\"Cannot create Left with null or undefined value\");\n  }\n  return new LeftImpl(left);\n}\n\n/**\n * Creates a Right instance\n */\nexport function Right<A, E = never>(right: A): Either<E, A> {\n  if (right === null || right === undefined) {\n    throw new Error(\"Cannot create Right with null or undefined value\");\n  }\n  return new RightImpl<E, A>(right);\n}\n\n/**\n * Either namespace containing utility functions\n */\nexport namespace Either {\n  /**\n   * Creates an Either from a function that might throw, capturing the error in the Left\n   */\n  export function tryCatch<A>(f: () => A): Either<unknown, A> {\n    try {\n      return Right(f());\n    } catch (e) {\n      return Left(e);\n    }\n  }\n\n  /**\n   * Returns a Right containing an array of all values if all inputs are Right, otherwise returns the first Left\n   */\n  export function sequence<E, A>(eithers: Either<E, A>[]): Either<E, A[]> {\n    const values: A[] = [];\n    for (const either of eithers) {\n      if (either.isLeft) return either as Either<E, A[]>;\n      values.push(either.get());\n    }\n    return Right(values);\n  }\n\n  /**\n   * Maps an array of values using a function that returns an Either, then sequences the result\n   */\n  export function traverse<E, A, B>(\n    values: A[],\n    f: (a: A) => Either<E, B>\n  ): Either<E, B[]> {\n    return sequence(values.map(f));\n  }\n} ","/**\n * Try<A> represents a computation that may either result in a value of type A\n * or an exception. It's similar to Either<Error, A> but specifically for handling exceptions.\n * \n * @example\n * ```ts\n * import { Try, Success, Failure, TryAsync } from 'scats';\n * \n * // Creating instances\n * const a = Try.of(() => JSON.parse('{\"valid\": \"json\"}'));\n * const b = Try.of(() => JSON.parse('invalid json'));\n * \n * // Using Try\n * const result = a\n *   .map(obj => obj.valid)\n *   .flatMap(str => Try.of(() => str.toUpperCase()))\n *   .getOrElse(\"default\");\n * \n * // Async version\n * const asyncResult = await TryAsync.of(async () => {\n *   const response = await fetch('https://api.example.com');\n *   return response.json();\n * }).map(data => data.value).toPromise();\n * ```\n */\n\nimport { Either, Left, Right } from './Either';\nimport { Option, Some, None } from './Option';\n\n/**\n * Try<A> interface that all Try implementations must satisfy\n */\nexport interface Try<A> {\n  /**\n   * Returns true if this is a Success, false otherwise\n   */\n  readonly isSuccess: boolean;\n\n  /**\n   * Returns true if this is a Failure, false otherwise\n   */\n  readonly isFailure: boolean;\n\n  /**\n   * Returns the value if this is a Success, or throws the error if this is a Failure\n   * @throws Error if this is a Failure\n   */\n  get(): A;\n\n  /**\n   * Returns the value if this is a Success, or returns the provided default value if this is a Failure\n   */\n  getOrElse<B>(defaultValue: B): A | B;\n\n  /**\n   * Returns the error if this is a Failure, or throws if this is a Success\n   * @throws Error if this is a Success\n   */\n  getError(): Error;\n\n  /**\n   * Returns a Try containing the exception if this is a Failure, or a Failure if this is a Success\n   */\n  failed(): Try<Error>;\n\n  /**\n   * Maps the value if this is a Success, otherwise returns this Failure unchanged\n   */\n  map<B>(f: (a: A) => B): Try<B>;\n\n  /**\n   * Returns the result of applying f if this is a Success, otherwise returns this Failure unchanged\n   */\n  flatMap<B>(f: (a: A) => Try<B>): Try<B>;\n\n  /**\n   * Recovers from a failure by returning the result of the provided function\n   */\n  recover<B>(f: (error: Error) => B): Try<A | B>;\n\n  /**\n   * Recovers from a failure by returning the result of the provided function\n   */\n  recoverWith<B>(f: (error: Error) => Try<B>): Try<A | B>;\n\n  /**\n   * Transforms this Try to another Try using the provided functions\n   */\n  transform<B>(s: (a: A) => Try<B>, f: (error: Error) => Try<B>): Try<B>;\n\n  /**\n   * Converts this Try to an Option, discarding the error if this is a Failure\n   */\n  toOption(): Option<A>;\n\n  /**\n   * Converts this Try to an Either with the error as Left and value as Right\n   */\n  toEither(): Either<Error, A>;\n\n  /**\n   * Executes one of the provided functions based on whether this is a Success or a Failure\n   */\n  fold<B>(onFailure: (error: Error) => B, onSuccess: (value: A) => B): B;\n\n  /**\n   * Returns the result of applying the appropriate function\n   */\n  match<B>(patterns: { Success: (value: A) => B; Failure: (error: Error) => B }): B;\n}\n\n/**\n * Success<A> represents a successful computation with a value\n */\nexport class SuccessImpl<A> implements Try<A> {\n  constructor(private readonly value: A) { }\n\n  get isSuccess(): boolean {\n    return true;\n  }\n\n  get isFailure(): boolean {\n    return false;\n  }\n\n  get(): A {\n    return this.value;\n  }\n\n  getOrElse<B>(_defaultValue: B): A {\n    return this.value;\n  }\n\n  getError(): Error {\n    throw new Error(\"Cannot get error from Success\");\n  }\n\n  failed(): Try<Error> {\n    return new FailureImpl(new Error(\"Success has no failure\"));\n  }\n\n  map<B>(f: (a: A) => B): Try<B> {\n    try {\n      return new SuccessImpl(f(this.value));\n    } catch (e) {\n      return new FailureImpl(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  flatMap<B>(f: (a: A) => Try<B>): Try<B> {\n    try {\n      return f(this.value);\n    } catch (e) {\n      return new FailureImpl(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  recover<B>(_f: (error: Error) => B): Try<A> {\n    return this;\n  }\n\n  recoverWith<B>(_f: (error: Error) => Try<B>): Try<A> {\n    return this;\n  }\n\n  transform<B>(s: (a: A) => Try<B>, _f: (error: Error) => Try<B>): Try<B> {\n    try {\n      return s(this.value);\n    } catch (e) {\n      return new FailureImpl(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  toOption(): Option<A> {\n    return Some(this.value);\n  }\n\n  toEither(): Either<Error, A> {\n    return Right(this.value);\n  }\n\n  fold<B>(_onFailure: (error: Error) => B, onSuccess: (value: A) => B): B {\n    return onSuccess(this.value);\n  }\n\n  match<B>(patterns: { Success: (value: A) => B; Failure: (error: Error) => B }): B {\n    return patterns.Success(this.value);\n  }\n\n  toString(): string {\n    return `Success(${this.value})`;\n  }\n}\n\n/**\n * Failure<A> represents a failed computation with an error\n */\nexport class FailureImpl<A> implements Try<A> {\n  constructor(private readonly error: Error) { }\n\n  get isSuccess(): boolean {\n    return false;\n  }\n\n  get isFailure(): boolean {\n    return true;\n  }\n\n  get(): A {\n    throw this.error;\n  }\n\n  getOrElse<B>(defaultValue: B): B {\n    return defaultValue;\n  }\n\n  getError(): Error {\n    return this.error;\n  }\n\n  failed(): Try<Error> {\n    return new SuccessImpl(this.error);\n  }\n\n  map<B>(_f: (a: A) => B): Try<B> {\n    return this as unknown as Try<B>;\n  }\n\n  flatMap<B>(_f: (a: A) => Try<B>): Try<B> {\n    return this as unknown as Try<B>;\n  }\n\n  recover<B>(f: (error: Error) => B): Try<B> {\n    try {\n      return new SuccessImpl(f(this.error));\n    } catch (e) {\n      return new FailureImpl(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  recoverWith<B>(f: (error: Error) => Try<B>): Try<B> {\n    try {\n      return f(this.error);\n    } catch (e) {\n      return new FailureImpl(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  transform<B>(_s: (a: A) => Try<B>, f: (error: Error) => Try<B>): Try<B> {\n    try {\n      return f(this.error);\n    } catch (e) {\n      return new FailureImpl(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  toOption(): Option<A> {\n    return None;\n  }\n\n  toEither(): Either<Error, A> {\n    return Left(this.error);\n  }\n\n  fold<B>(onFailure: (error: Error) => B, _onSuccess: (value: A) => B): B {\n    return onFailure(this.error);\n  }\n\n  match<B>(patterns: { Success: (value: A) => B; Failure: (error: Error) => B }): B {\n    return patterns.Failure(this.error);\n  }\n\n  toString(): string {\n    return `Failure(${this.error})`;\n  }\n}\n\n/**\n * Creates a Success instance\n */\nexport function Success<A>(value: A): Try<A> {\n  return new SuccessImpl(value);\n}\n\n/**\n * Creates a Failure instance\n */\nexport function Failure<A>(error: Error): Try<A> {\n  return new FailureImpl(error);\n}\n\n/**\n * Try namespace containing utility functions\n */\nexport namespace Try {\n  /**\n   * Creates a Try from a function that might throw\n   */\n  export function of<A>(f: () => A): Try<A> {\n    try {\n      return Success(f());\n    } catch (e) {\n      return Failure(e instanceof Error ? e : new Error(String(e)));\n    }\n  }\n\n  /**\n   * Returns a Success containing an array of all values if all tries are Success, otherwise returns the first Failure\n   */\n  export function sequence<A>(tries: Try<A>[]): Try<A[]> {\n    const values: A[] = [];\n    for (const t of tries) {\n      if (t.isFailure) return t as Try<A[]>;\n      values.push(t.get());\n    }\n    return Success(values);\n  }\n\n  /**\n   * Maps an array of values using a function that returns a Try, then sequences the result\n   */\n  export function traverse<A, B>(\n    values: A[],\n    f: (a: A) => Try<B>\n  ): Try<B[]> {\n    return sequence(values.map(f));\n  }\n}\n\n/**\n * TryAsync<A> represents an asynchronous computation that may either result in a value of type A\n * or an exception. It's the asynchronous counterpart to Try<A>.\n */\nexport interface TryAsync<A> {\n  /**\n   * Maps the value if this is a Success, otherwise returns this Failure unchanged\n   */\n  map<B>(f: (a: A) => B | Promise<B>): TryAsync<B>;\n\n  /**\n   * Returns the result of applying f if this is a Success, otherwise returns this Failure unchanged\n   */\n  flatMap<B>(f: (a: A) => TryAsync<B> | Promise<TryAsync<B>>): TryAsync<B>;\n\n  /**\n   * Recovers from a failure by returning the result of the provided function\n   */\n  recover<B>(f: (error: Error) => B | Promise<B>): TryAsync<A | B>;\n\n  /**\n   * Recovers from a failure by returning the result of the provided function\n   */\n  recoverWith<B>(f: (error: Error) => TryAsync<B> | Promise<TryAsync<B>>): TryAsync<A | B>;\n\n  /**\n   * Converts this async Try to a Promise\n   */\n  toPromise(): Promise<A>;\n}\n\nclass TryAsyncImpl<A> implements TryAsync<A> {\n  constructor(private readonly promise: Promise<Try<A>>) { }\n\n  map<B>(f: (a: A) => B | Promise<B>): TryAsync<B> {\n    return new TryAsyncImpl<B>(\n      this.promise.then(async (result) => {\n        if (result.isFailure) return result as unknown as Try<B>;\n        try {\n          const value = await f(result.get());\n          return Success(value);\n        } catch (e) {\n          return Failure(e instanceof Error ? e : new Error(String(e)));\n        }\n      })\n    );\n  }\n\n  flatMap<B>(f: (a: A) => TryAsync<B> | Promise<TryAsync<B>>): TryAsync<B> {\n    return new TryAsyncImpl<B>(\n      this.promise.then(async (result) => {\n        if (result.isFailure) return result as unknown as Try<B>;\n        try {\n          const tryAsync = await f(result.get());\n          return await tryAsync.toPromise().then(Success).catch(e =>\n            Failure(e instanceof Error ? e : new Error(String(e)))\n          );\n        } catch (e) {\n          return Failure(e instanceof Error ? e : new Error(String(e)));\n        }\n      })\n    );\n  }\n\n  recover<B>(f: (error: Error) => B | Promise<B>): TryAsync<A | B> {\n    return new TryAsyncImpl<A | B>(\n      this.promise.then(async (result) => {\n        if (result.isSuccess) return result as Try<A | B>;\n        try {\n          const value = await f(result.getError());\n          return Success<A | B>(value);\n        } catch (e) {\n          return Failure<A | B>(e instanceof Error ? e : new Error(String(e)));\n        }\n      })\n    );\n  }\n\n  recoverWith<B>(f: (error: Error) => TryAsync<B> | Promise<TryAsync<B>>): TryAsync<A | B> {\n    return new TryAsyncImpl<A | B>(\n      this.promise.then(async (result) => {\n        if (result.isSuccess) return result as Try<A | B>;\n        try {\n          const tryAsync = await f(result.getError());\n          return await tryAsync.toPromise().then(value =>\n            Success<A | B>(value)\n          ).catch(e =>\n            Failure<A | B>(e instanceof Error ? e : new Error(String(e)))\n          );\n        } catch (e) {\n          return Failure<A | B>(e instanceof Error ? e : new Error(String(e)));\n        }\n      })\n    );\n  }\n\n  async toPromise(): Promise<A> {\n    const result = await this.promise;\n    if (result.isSuccess) {\n      return result.get();\n    } else {\n      throw result.getError();\n    }\n  }\n}\n\n/**\n * TryAsync namespace containing utility functions\n */\nexport namespace TryAsync {\n  /**\n   * Creates a TryAsync from a function that returns a Promise\n   */\n  export function of<A>(f: () => Promise<A>): TryAsync<A> {\n    return new TryAsyncImpl(\n      Promise.resolve().then(async () => {\n        try {\n          const value = await f();\n          return Success(value);\n        } catch (e) {\n          return Failure(e instanceof Error ? e : new Error(String(e)));\n        }\n      })\n    );\n  }\n\n  /**\n   * Creates a successful TryAsync\n   */\n  export function success<A>(value: A): TryAsync<A> {\n    return new TryAsyncImpl(Promise.resolve(Success(value)));\n  }\n\n  /**\n   * Creates a failed TryAsync\n   */\n  export function failure<A>(error: Error): TryAsync<A> {\n    return new TryAsyncImpl(Promise.resolve(Failure(error)));\n  }\n\n  /**\n   * Converts a Promise to a TryAsync\n   */\n  export function fromPromise<A>(promise: Promise<A>): TryAsync<A> {\n    return of(() => promise);\n  }\n} ","/**\n * The execution context is the environment where a computation runs.\n */\nexport interface ExecutionContext {\n  /**\n   * Executes a task in this execution context.\n   */\n  execute(task: () => void): void;\n\n  /**\n   * Reports an exception that occurred during execution.\n   */\n  reportFailure(cause: Error): void;\n}\n\n/**\n * A default global execution context backed by the JavaScript event loop.\n */\nclass GlobalExecutionContext implements ExecutionContext {\n  /**\n   * Executes a task asynchronously.\n   */\n  execute(task: () => void): void {\n    setTimeout(task, 0);\n  }\n\n  /**\n   * Reports a failure to the console.\n   */\n  reportFailure(cause: Error): void {\n    console.error(\"Execution context failure:\", cause);\n  }\n}\n\n/**\n * An execution context that executes tasks synchronously in the current thread.\n * This is mainly for testing and should be avoided in production.\n */\nclass SynchronousExecutionContext implements ExecutionContext {\n  /**\n   * Executes a task immediately in the current thread.\n   */\n  execute(task: () => void): void {\n    task();\n  }\n\n  /**\n   * Reports a failure to the console.\n   */\n  reportFailure(cause: Error): void {\n    console.error(\"Execution context failure:\", cause);\n  }\n}\n\n/**\n * Execution context utility methods.\n */\nexport const ExecutionContext = {\n  /**\n   * The global execution context.\n   */\n  global: new GlobalExecutionContext(),\n\n  /**\n   * A synchronous execution context for testing.\n   */\n  synchronous: new SynchronousExecutionContext(),\n\n  /**\n   * Creates an execution context from a function that executes tasks.\n   */\n  fromExecutor(executor: (task: () => void) => void, reporter: (cause: Error) => void = console.error): ExecutionContext {\n    return {\n      execute: executor,\n      reportFailure: reporter\n    };\n  }\n}; ","/**\n * List<A> represents an immutable linked list structure.\n * It's a singly-linked list that supports efficient prepend operations.\n * \n * @example\n * ```ts\n * import { List } from 'scats';\n * \n * // Creating lists\n * const a = List.of(1, 2, 3);\n * const b = List.empty<number>();\n * const c = a.prepend(0);\n * \n * // Using lists\n * const doubled = a.map(n => n * 2);\n * const summed = a.foldLeft(0, (acc, n) => acc + n);\n * const filtered = a.filter(n => n % 2 === 0);\n * ```\n */\n\nimport { Option, Some, None } from './Option';\n\n/**\n * List<A> interface that all List implementations must satisfy\n */\nexport interface List<A> extends Iterable<A> {\n  /**\n   * Returns true if this list is empty, false otherwise\n   */\n  readonly isEmpty: boolean;\n\n  /**\n   * Returns the number of elements in this list\n   */\n  readonly size: number;\n\n  /**\n   * Returns the first element of this list, or throws an error if the list is empty\n   * @throws Error if the list is empty\n   */\n  head(): A;\n\n  /**\n   * Returns the rest of this list (all elements except the head), or throws an error if the list is empty\n   * @throws Error if the list is empty\n   */\n  tail(): List<A>;\n\n  /**\n   * Returns the first element of this list as an Option, or None if the list is empty\n   */\n  headOption(): Option<A>;\n\n  /**\n   * Returns the rest of this list as an Option, or None if the list is empty\n   */\n  tailOption(): Option<List<A>>;\n\n  /**\n   * Returns a new list with the provided element prepended to this list\n   */\n  prepend(element: A): List<A>;\n\n  /**\n   * Returns a new list with the provided elements appended to this list\n   */\n  append(element: A): List<A>;\n\n  /**\n   * Returns a new list that is the result of concatenating this list with the provided list\n   */\n  concat(that: List<A>): List<A>;\n\n  /**\n   * Returns a new list that is the result of applying the provided function to each element\n   */\n  map<B>(f: (a: A) => B): List<B>;\n\n  /**\n   * Returns a new list that is the result of applying the provided function to each element\n   * and flattening the results\n   */\n  flatMap<B>(f: (a: A) => List<B>): List<B>;\n\n  /**\n   * Returns a new list containing only the elements that satisfy the provided predicate\n   */\n  filter(predicate: (a: A) => boolean): List<A>;\n\n  /**\n   * Returns a tuple of two lists, where the first list contains all elements that satisfy\n   * the provided predicate, and the second list contains all elements that don't satisfy the predicate\n   */\n  partition(predicate: (a: A) => boolean): [List<A>, List<A>];\n\n  /**\n   * Returns true if any element in this list satisfies the provided predicate, false otherwise\n   */\n  exists(predicate: (a: A) => boolean): boolean;\n\n  /**\n   * Returns true if all elements in this list satisfy the provided predicate, false otherwise\n   */\n  forAll(predicate: (a: A) => boolean): boolean;\n\n  /**\n   * Returns the result of applying the provided function to each element, starting with the provided initial value\n   */\n  foldLeft<B>(initial: B, f: (acc: B, a: A) => B): B;\n\n  /**\n   * Returns the result of applying the provided function to each element, starting with the provided initial value,\n   * working from right to left\n   */\n  foldRight<B>(initial: B, f: (a: A, acc: B) => B): B;\n\n  /**\n   * Executes the provided function for each element in this list\n   */\n  forEach(f: (a: A) => void): void;\n\n  /**\n   * Returns a new list containing the elements at the specified indices\n   */\n  slice(start: number, end?: number): List<A>;\n\n  /**\n   * Returns a new list with the first n elements\n   */\n  take(n: number): List<A>;\n\n  /**\n   * Returns a new list with all elements except the first n\n   */\n  drop(n: number): List<A>;\n\n  /**\n   * Returns a new list with elements while the predicate is satisfied\n   */\n  takeWhile(predicate: (a: A) => boolean): List<A>;\n\n  /**\n   * Returns a new list without elements while the predicate is satisfied\n   */\n  dropWhile(predicate: (a: A) => boolean): List<A>;\n\n  /**\n   * Returns the element at the specified index, or throws an error if the index is out of bounds\n   * @throws Error if the index is out of bounds\n   */\n  get(index: number): A;\n\n  /**\n   * Returns the element at the specified index as an Option, or None if the index is out of bounds\n   */\n  getOption(index: number): Option<A>;\n\n  /**\n   * Returns a new list with the element at the specified index replaced with the provided element,\n   * or the same list if the index is out of bounds\n   */\n  updateAt(index: number, element: A): List<A>;\n\n  /**\n   * Returns the index of the first occurrence of the specified element, or -1 if the element is not found\n   */\n  indexOf(element: A): number;\n\n  /**\n   * Returns true if this list contains the specified element, false otherwise\n   */\n  contains(element: A): boolean;\n\n  /**\n   * Returns a new list with distinct elements (removes duplicates)\n   */\n  distinct(): List<A>;\n\n  /**\n   * Returns a new list with the elements in reverse order\n   */\n  reverse(): List<A>;\n\n  /**\n   * Returns a new list sorted according to the natural ordering of the elements\n   */\n  sorted(compareFn?: (a: A, b: A) => number): List<A>;\n\n  /**\n   * Converts this list to an array\n   */\n  toArray(): A[];\n\n  /**\n   * Returns a string representation of this list\n   */\n  toString(): string;\n}\n\n/**\n * Empty list implementation\n */\nclass EmptyList<A> implements List<A> {\n  get isEmpty(): boolean {\n    return true;\n  }\n\n  get size(): number {\n    return 0;\n  }\n\n  head(): never {\n    throw new Error(\"Cannot get head of empty list\");\n  }\n\n  tail(): never {\n    throw new Error(\"Cannot get tail of empty list\");\n  }\n\n  headOption(): Option<A> {\n    return None;\n  }\n\n  tailOption(): Option<List<A>> {\n    return None;\n  }\n\n  prepend(element: A): List<A> {\n    return new ConsImpl(element, this);\n  }\n\n  append(element: A): List<A> {\n    return new ConsImpl(element, this);\n  }\n\n  concat(that: List<A>): List<A> {\n    return that;\n  }\n\n  map<B>(_f: (a: A) => B): List<B> {\n    return empty<B>();\n  }\n\n  flatMap<B>(_f: (a: A) => List<B>): List<B> {\n    return empty<B>();\n  }\n\n  filter(_predicate: (a: A) => boolean): List<A> {\n    return this;\n  }\n\n  partition(_predicate: (a: A) => boolean): [List<A>, List<A>] {\n    return [this, this];\n  }\n\n  exists(_predicate: (a: A) => boolean): boolean {\n    return false;\n  }\n\n  forAll(_predicate: (a: A) => boolean): boolean {\n    return true;\n  }\n\n  foldLeft<B>(initial: B, _f: (acc: B, a: A) => B): B {\n    return initial;\n  }\n\n  foldRight<B>(initial: B, _f: (a: A, acc: B) => B): B {\n    return initial;\n  }\n\n  forEach(_f: (a: A) => void): void {\n    // Do nothing for empty list\n  }\n\n  slice(_start: number, _end?: number): List<A> {\n    return this;\n  }\n\n  take(_n: number): List<A> {\n    return this;\n  }\n\n  drop(_n: number): List<A> {\n    return this;\n  }\n\n  takeWhile(_predicate: (a: A) => boolean): List<A> {\n    return this;\n  }\n\n  dropWhile(_predicate: (a: A) => boolean): List<A> {\n    return this;\n  }\n\n  get(_index: number): never {\n    throw new Error(\"Index out of bounds\");\n  }\n\n  getOption(_index: number): Option<A> {\n    return None;\n  }\n\n  updateAt(_index: number, _element: A): List<A> {\n    return this;\n  }\n\n  indexOf(_element: A): number {\n    return -1;\n  }\n\n  contains(_element: A): boolean {\n    return false;\n  }\n\n  distinct(): List<A> {\n    return this;\n  }\n\n  reverse(): List<A> {\n    return this;\n  }\n\n  sorted(_compareFn?: (a: A, b: A) => number): List<A> {\n    return this;\n  }\n\n  toArray(): A[] {\n    return [];\n  }\n\n  toString(): string {\n    return \"List()\";\n  }\n\n  *[Symbol.iterator](): Iterator<A> {\n    // Empty iterator\n  }\n}\n\n/**\n * Non-empty list implementation\n */\nclass ConsImpl<A> implements List<A> {\n  constructor(private readonly _head: A, private readonly _tail: List<A>) { }\n\n  get isEmpty(): boolean {\n    return false;\n  }\n\n  get size(): number {\n    let size = 1;\n    let current: List<A> = this._tail;\n    while (!current.isEmpty) {\n      size += 1;\n      current = current.tail();\n    }\n    return size;\n  }\n\n  head(): A {\n    return this._head;\n  }\n\n  tail(): List<A> {\n    return this._tail;\n  }\n\n  headOption(): Option<A> {\n    return Some(this._head);\n  }\n\n  tailOption(): Option<List<A>> {\n    return Some(this._tail);\n  }\n\n  prepend(element: A): List<A> {\n    return new ConsImpl(element, this);\n  }\n\n  append(element: A): List<A> {\n    // Inefficient for large lists, but we're keeping the API\n    return this.concat(List.of(element));\n  }\n\n  concat(that: List<A>): List<A> {\n    // Using a more efficient implementation than naively recursing\n    if (that.isEmpty) return this;\n\n    // Build up a reversed version of this list\n    let reversed = empty<A>();\n    let current: List<A> = this;\n    while (!current.isEmpty) {\n      reversed = reversed.prepend(current.head());\n      current = current.tail();\n    }\n\n    // Build the result by prepending the reversed elements onto 'that'\n    let result = that;\n    current = reversed;\n    while (!current.isEmpty) {\n      result = result.prepend(current.head());\n      current = current.tail();\n    }\n\n    return result;\n  }\n\n  map<B>(f: (a: A) => B): List<B> {\n    // Avoid stack overflow by iterative implementation\n    const result: B[] = [];\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      result.push(f(current.head()));\n      current = current.tail();\n    }\n\n    // Build the list in reverse\n    let listResult = empty<B>();\n    for (let i = result.length - 1; i >= 0; i--) {\n      listResult = listResult.prepend(result[i]);\n    }\n\n    return listResult;\n  }\n\n  flatMap<B>(f: (a: A) => List<B>): List<B> {\n    // Iterative to avoid stack overflow\n    let result = empty<B>();\n    const elements: List<B>[] = [];\n    let current: List<A> = this;\n\n    // Collect all mapped lists\n    while (!current.isEmpty) {\n      elements.push(f(current.head()));\n      current = current.tail();\n    }\n\n    // Concatenate in reverse order\n    for (let i = elements.length - 1; i >= 0; i--) {\n      result = elements[i].concat(result);\n    }\n\n    return result;\n  }\n\n  filter(predicate: (a: A) => boolean): List<A> {\n    // Iterative to avoid stack overflow\n    const result: A[] = [];\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      const head = current.head();\n      if (predicate(head)) {\n        result.push(head);\n      }\n      current = current.tail();\n    }\n\n    // Build the list in reverse\n    let listResult = empty<A>();\n    for (let i = result.length - 1; i >= 0; i--) {\n      listResult = listResult.prepend(result[i]);\n    }\n\n    return listResult;\n  }\n\n  partition(predicate: (a: A) => boolean): [List<A>, List<A>] {\n    // Iterative to avoid stack overflow\n    const trueResults: A[] = [];\n    const falseResults: A[] = [];\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      const head = current.head();\n      if (predicate(head)) {\n        trueResults.push(head);\n      } else {\n        falseResults.push(head);\n      }\n      current = current.tail();\n    }\n\n    // Build the lists in reverse\n    let trueList = empty<A>();\n    for (let i = trueResults.length - 1; i >= 0; i--) {\n      trueList = trueList.prepend(trueResults[i]);\n    }\n\n    let falseList = empty<A>();\n    for (let i = falseResults.length - 1; i >= 0; i--) {\n      falseList = falseList.prepend(falseResults[i]);\n    }\n\n    return [trueList, falseList];\n  }\n\n  exists(predicate: (a: A) => boolean): boolean {\n    let current: List<A> = this;\n    while (!current.isEmpty) {\n      if (predicate(current.head())) {\n        return true;\n      }\n      current = current.tail();\n    }\n    return false;\n  }\n\n  forAll(predicate: (a: A) => boolean): boolean {\n    let current: List<A> = this;\n    while (!current.isEmpty) {\n      if (!predicate(current.head())) {\n        return false;\n      }\n      current = current.tail();\n    }\n    return true;\n  }\n\n  foldLeft<B>(initial: B, f: (acc: B, a: A) => B): B {\n    let result = initial;\n    let current: List<A> = this;\n    while (!current.isEmpty) {\n      result = f(result, current.head());\n      current = current.tail();\n    }\n    return result;\n  }\n\n  foldRight<B>(initial: B, f: (a: A, acc: B) => B): B {\n    // To avoid stack overflow, we reverse the list and then do foldLeft\n    const reversed = this.reverse();\n    return reversed.foldLeft(initial, (acc, a) => f(a, acc));\n  }\n\n  forEach(f: (a: A) => void): void {\n    let current: List<A> = this;\n    while (!current.isEmpty) {\n      f(current.head());\n      current = current.tail();\n    }\n  }\n\n  slice(start: number, end?: number): List<A> {\n    const endIndex = end === undefined ? this.size : end;\n    return this.take(endIndex).drop(start);\n  }\n\n  take(n: number): List<A> {\n    if (n <= 0) return empty<A>();\n\n    const result: A[] = [];\n    let current: List<A> = this;\n    let count = 0;\n\n    while (!current.isEmpty && count < n) {\n      result.push(current.head());\n      current = current.tail();\n      count += 1;\n    }\n\n    // Build the list in reverse\n    let listResult = empty<A>();\n    for (let i = result.length - 1; i >= 0; i--) {\n      listResult = listResult.prepend(result[i]);\n    }\n\n    return listResult;\n  }\n\n  drop(n: number): List<A> {\n    if (n <= 0) return this;\n\n    let current: List<A> = this;\n    let count = 0;\n\n    while (!current.isEmpty && count < n) {\n      current = current.tail();\n      count += 1;\n    }\n\n    return current;\n  }\n\n  takeWhile(predicate: (a: A) => boolean): List<A> {\n    const result: A[] = [];\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      const head = current.head();\n      if (!predicate(head)) break;\n      result.push(head);\n      current = current.tail();\n    }\n\n    // Build the list in reverse\n    let listResult = empty<A>();\n    for (let i = result.length - 1; i >= 0; i--) {\n      listResult = listResult.prepend(result[i]);\n    }\n\n    return listResult;\n  }\n\n  dropWhile(predicate: (a: A) => boolean): List<A> {\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      if (!predicate(current.head())) {\n        return current;\n      }\n      current = current.tail();\n    }\n\n    return empty<A>();\n  }\n\n  get(index: number): A {\n    if (index < 0) {\n      throw new Error(\"Index out of bounds\");\n    }\n\n    let current: List<A> = this;\n    let currentIndex = 0;\n\n    while (!current.isEmpty) {\n      if (currentIndex === index) {\n        return current.head();\n      }\n      current = current.tail();\n      currentIndex += 1;\n    }\n\n    throw new Error(\"Index out of bounds\");\n  }\n\n  getOption(index: number): Option<A> {\n    if (index < 0) {\n      return None;\n    }\n\n    let current: List<A> = this;\n    let currentIndex = 0;\n\n    while (!current.isEmpty) {\n      if (currentIndex === index) {\n        return Some(current.head());\n      }\n      current = current.tail();\n      currentIndex += 1;\n    }\n\n    return None;\n  }\n\n  updateAt(index: number, element: A): List<A> {\n    if (index < 0) {\n      return this;\n    }\n\n    const result: A[] = [];\n    let current: List<A> = this;\n    let currentIndex = 0;\n    let found = false;\n\n    while (!current.isEmpty) {\n      if (currentIndex === index) {\n        result.push(element);\n        found = true;\n      } else {\n        result.push(current.head());\n      }\n      current = current.tail();\n      currentIndex += 1;\n    }\n\n    if (!found) {\n      return this;\n    }\n\n    // Build the list in reverse\n    let listResult = empty<A>();\n    for (let i = result.length - 1; i >= 0; i--) {\n      listResult = listResult.prepend(result[i]);\n    }\n\n    return listResult;\n  }\n\n  indexOf(element: A): number {\n    let current: List<A> = this;\n    let currentIndex = 0;\n\n    while (!current.isEmpty) {\n      if (current.head() === element) {\n        return currentIndex;\n      }\n      current = current.tail();\n      currentIndex += 1;\n    }\n\n    return -1;\n  }\n\n  contains(element: A): boolean {\n    return this.indexOf(element) !== -1;\n  }\n\n  distinct(): List<A> {\n    const seen = new Set<A>();\n    const result: A[] = [];\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      const head = current.head();\n      if (!seen.has(head)) {\n        seen.add(head);\n        result.push(head);\n      }\n      current = current.tail();\n    }\n\n    // Build the list in reverse\n    let listResult = empty<A>();\n    for (let i = result.length - 1; i >= 0; i--) {\n      listResult = listResult.prepend(result[i]);\n    }\n\n    return listResult;\n  }\n\n  reverse(): List<A> {\n    let result = empty<A>();\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      result = result.prepend(current.head());\n      current = current.tail();\n    }\n\n    return result;\n  }\n\n  sorted(compareFn?: (a: A, b: A) => number): List<A> {\n    const array = this.toArray();\n    array.sort(compareFn);\n\n    // Build the list in reverse\n    let result = empty<A>();\n    for (let i = array.length - 1; i >= 0; i--) {\n      result = result.prepend(array[i]);\n    }\n\n    return result;\n  }\n\n  toArray(): A[] {\n    const result: A[] = [];\n    let current: List<A> = this;\n\n    while (!current.isEmpty) {\n      result.push(current.head());\n      current = current.tail();\n    }\n\n    return result;\n  }\n\n  toString(): string {\n    return `List(${this.toArray().join(\", \")})`;\n  }\n\n  *[Symbol.iterator](): Iterator<A> {\n    let current: List<A> = this;\n    while (!current.isEmpty) {\n      yield current.head();\n      current = current.tail();\n    }\n  }\n}\n\n/**\n * Creates an empty list\n */\nexport function empty<A>(): List<A> {\n  return new EmptyList<A>();\n}\n\n/**\n * List namespace containing utility functions\n */\nexport namespace List {\n  /**\n   * Creates a list containing the provided elements\n   */\n  export function of<A>(...elements: A[]): List<A> {\n    let result = empty<A>();\n    for (let i = elements.length - 1; i >= 0; i--) {\n      result = result.prepend(elements[i]);\n    }\n    return result;\n  }\n\n  /**\n   * Creates a list from an array\n   */\n  export function fromArray<A>(array: A[]): List<A> {\n    return of(...array);\n  }\n\n  /**\n   * Creates a list from an iterable\n   */\n  export function fromIterable<A>(iterable: Iterable<A>): List<A> {\n    return fromArray([...iterable]);\n  }\n\n  /**\n   * Creates an empty list\n   */\n  export function empty<A>(): List<A> {\n    return new EmptyList<A>();\n  }\n\n  /**\n   * Creates a list with elements produced by the specified function\n   */\n  export function fill<A>(n: number, f: (index: number) => A): List<A> {\n    const array = Array(n).fill(null).map((_, i) => f(i));\n    return fromArray(array);\n  }\n\n  /**\n   * Creates a list with the specified element repeated n times\n   */\n  export function repeat<A>(element: A, n: number): List<A> {\n    return fill(n, () => element);\n  }\n\n  /**\n   * Creates a list with numbers from start (inclusive) to end (exclusive)\n   */\n  export function range(start: number, end: number, step = 1): List<number> {\n    if (step === 0) {\n      throw new Error(\"Step cannot be 0\");\n    }\n    const array: number[] = [];\n    if (step > 0) {\n      for (let i = start; i < end; i += step) {\n        array.push(i);\n      }\n    } else {\n      for (let i = start; i > end; i += step) {\n        array.push(i);\n      }\n    }\n    return fromArray(array);\n  }\n\n  /**\n   * Zips two lists together, element by element\n   */\n  export function zip<A, B>(as: List<A>, bs: List<B>): List<[A, B]> {\n    const result: [A, B][] = [];\n    let currA: List<A> = as;\n    let currB: List<B> = bs;\n\n    while (!currA.isEmpty && !currB.isEmpty) {\n      result.push([currA.head(), currB.head()]);\n      currA = currA.tail();\n      currB = currB.tail();\n    }\n\n    return fromArray(result);\n  }\n\n  /**\n   * Maps two lists with the provided function\n   */\n  export function map2<A, B, C>(\n    as: List<A>,\n    bs: List<B>,\n    f: (a: A, b: B) => C\n  ): List<C> {\n    return zip(as, bs).map(([a, b]) => f(a, b));\n  }\n} ","/**\n * Map<K, V> represents an immutable key-value map.\n * It's implemented as a balanced binary search tree for efficient operations.\n * \n * @example\n * ```ts\n * import { Map } from 'scats';\n * \n * // Creating maps\n * const a = Map.of([[\"a\", 1], [\"b\", 2], [\"c\", 3]]);\n * const b = Map.empty<string, number>();\n * const c = a.set(\"d\", 4);\n * \n * // Using maps\n * const value = a.get(\"a\"); // Some(1)\n * const notFound = a.get(\"z\"); // None\n * const updated = a.update(\"a\", n => n * 2); // Map([\"a\", 2], [\"b\", 2], [\"c\", 3])\n * ```\n */\n\nimport { Option, Some, None } from './Option';\nimport { List } from './List';\n\n/**\n * Map<K, V> interface that all Map implementations must satisfy\n */\nexport interface Map<K, V> {\n  /**\n   * Returns true if this map is empty, false otherwise\n   */\n  readonly isEmpty: boolean;\n\n  /**\n   * Returns the number of key-value pairs in this map\n   */\n  readonly size: number;\n\n  /**\n   * Returns the keys in this map\n   */\n  readonly keys: List<K>;\n\n  /**\n   * Returns the values in this map\n   */\n  readonly values: List<V>;\n\n  /**\n   * Returns the key-value pairs in this map\n   */\n  readonly entries: List<[K, V]>;\n\n  /**\n   * Returns the value associated with the specified key as an Option, or None if the key is not found\n   */\n  get(key: K): Option<V>;\n\n  /**\n   * Returns the value associated with the specified key, or the provided default value if the key is not found\n   */\n  getOrElse<U>(key: K, defaultValue: U): V | U;\n\n  /**\n   * Returns a new map with the specified key-value pair added or updated\n   */\n  set(key: K, value: V): Map<K, V>;\n\n  /**\n   * Returns a new map with the specified key-value pairs added or updated\n   */\n  setAll(entries: Iterable<[K, V]>): Map<K, V>;\n\n  /**\n   * Returns a new map with the specified key-value pair removed\n   */\n  remove(key: K): Map<K, V>;\n\n  /**\n   * Returns a new map with the specified keys removed\n   */\n  removeAll(keys: Iterable<K>): Map<K, V>;\n\n  /**\n   * Returns a new map with the value associated with the specified key updated by applying the provided function,\n   * or the same map if the key is not found\n   */\n  update(key: K, f: (value: V) => V): Map<K, V>;\n\n  /**\n   * Returns a new map with the value associated with the specified key updated by applying the provided function,\n   * or a new map with the specified key-value pair added if the key is not found\n   */\n  updateOrSet(key: K, f: (value: Option<V>) => V): Map<K, V>;\n\n  /**\n   * Returns a new map that is the result of merging this map with the specified map\n   */\n  merge(that: Map<K, V>): Map<K, V>;\n\n  /**\n   * Returns a new map that is the result of applying the provided function to each key-value pair\n   */\n  map<W>(f: (value: V, key: K) => W): Map<K, W>;\n\n  /**\n   * Returns a new map containing only the key-value pairs that satisfy the provided predicate\n   */\n  filter(predicate: (value: V, key: K) => boolean): Map<K, V>;\n\n  /**\n   * Returns true if any key-value pair in this map satisfies the provided predicate, false otherwise\n   */\n  exists(predicate: (value: V, key: K) => boolean): boolean;\n\n  /**\n   * Returns true if all key-value pairs in this map satisfy the provided predicate, false otherwise\n   */\n  forAll(predicate: (value: V, key: K) => boolean): boolean;\n\n  /**\n   * Returns the result of applying the provided function to each key-value pair, starting with the provided initial value\n   */\n  foldLeft<U>(initial: U, f: (acc: U, value: V, key: K) => U): U;\n\n  /**\n   * Executes the provided function for each key-value pair in this map\n   */\n  forEach(f: (value: V, key: K) => void): void;\n\n  /**\n   * Returns true if this map contains the specified key, false otherwise\n   */\n  has(key: K): boolean;\n\n  /**\n   * Returns a native JavaScript Map containing the same key-value pairs as this map\n   */\n  toNativeMap(): globalThis.Map<K, V>;\n\n  /**\n   * Returns a string representation of this map\n   */\n  toString(): string;\n}\n\n// Simple implementation that uses a JavaScript Map under the hood\n// A production implementation would use a balanced tree like Red-Black Tree or AVL Tree\nclass MapImpl<K, V> implements Map<K, V> {\n  // Using a native Map for internal storage\n  private readonly _map: globalThis.Map<K, V>;\n\n  constructor(entries?: Iterable<[K, V]>) {\n    this._map = new globalThis.Map(entries);\n  }\n\n  get isEmpty(): boolean {\n    return this._map.size === 0;\n  }\n\n  get size(): number {\n    return this._map.size;\n  }\n\n  get keys(): List<K> {\n    return List.fromIterable(this._map.keys());\n  }\n\n  get values(): List<V> {\n    return List.fromIterable(this._map.values());\n  }\n\n  get entries(): List<[K, V]> {\n    return List.fromIterable(this._map.entries());\n  }\n\n  get(key: K): Option<V> {\n    return this._map.has(key) ? Some(this._map.get(key)!) : None;\n  }\n\n  getOrElse<U>(key: K, defaultValue: U): V | U {\n    return this._map.has(key) ? this._map.get(key)! : defaultValue;\n  }\n\n  set(key: K, value: V): Map<K, V> {\n    const newMap = new globalThis.Map(this._map);\n    newMap.set(key, value);\n    return new MapImpl(newMap);\n  }\n\n  setAll(entries: Iterable<[K, V]>): Map<K, V> {\n    const newMap = new globalThis.Map(this._map);\n    for (const [key, value] of entries) {\n      newMap.set(key, value);\n    }\n    return new MapImpl(newMap);\n  }\n\n  remove(key: K): Map<K, V> {\n    if (!this._map.has(key)) {\n      return this;\n    }\n    const newMap = new globalThis.Map(this._map);\n    newMap.delete(key);\n    return new MapImpl(newMap);\n  }\n\n  removeAll(keys: Iterable<K>): Map<K, V> {\n    const newMap = new globalThis.Map(this._map);\n    for (const key of keys) {\n      newMap.delete(key);\n    }\n    return new MapImpl(newMap);\n  }\n\n  update(key: K, f: (value: V) => V): Map<K, V> {\n    if (!this._map.has(key)) {\n      return this;\n    }\n    const newMap = new globalThis.Map(this._map);\n    newMap.set(key, f(this._map.get(key)!));\n    return new MapImpl(newMap);\n  }\n\n  updateOrSet(key: K, f: (value: Option<V>) => V): Map<K, V> {\n    const newMap = new globalThis.Map(this._map);\n    const currentValue = this._map.has(key) ? Some(this._map.get(key)!) : None;\n    newMap.set(key, f(currentValue));\n    return new MapImpl(newMap);\n  }\n\n  merge(that: Map<K, V>): Map<K, V> {\n    return this.setAll(that.entries.toArray());\n  }\n\n  map<W>(f: (value: V, key: K) => W): Map<K, W> {\n    const newEntries: [K, W][] = [];\n    this._map.forEach((value, key) => {\n      newEntries.push([key, f(value, key)]);\n    });\n    return new MapImpl(newEntries);\n  }\n\n  filter(predicate: (value: V, key: K) => boolean): Map<K, V> {\n    const newEntries: [K, V][] = [];\n    this._map.forEach((value, key) => {\n      if (predicate(value, key)) {\n        newEntries.push([key, value]);\n      }\n    });\n    return new MapImpl(newEntries);\n  }\n\n  exists(predicate: (value: V, key: K) => boolean): boolean {\n    for (const [key, value] of this._map.entries()) {\n      if (predicate(value, key)) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  forAll(predicate: (value: V, key: K) => boolean): boolean {\n    for (const [key, value] of this._map.entries()) {\n      if (!predicate(value, key)) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  foldLeft<U>(initial: U, f: (acc: U, value: V, key: K) => U): U {\n    let result = initial;\n    this._map.forEach((value, key) => {\n      result = f(result, value, key);\n    });\n    return result;\n  }\n\n  forEach(f: (value: V, key: K) => void): void {\n    this._map.forEach((value, key) => {\n      f(value, key);\n    });\n  }\n\n  has(key: K): boolean {\n    return this._map.has(key);\n  }\n\n  toNativeMap(): globalThis.Map<K, V> {\n    return new globalThis.Map(this._map);\n  }\n\n  toString(): string {\n    if (this.isEmpty) {\n      return \"Map()\";\n    }\n    const entries = Array.from(this._map.entries())\n      .map(([key, value]) => `[${String(key)}, ${String(value)}]`)\n      .join(\", \");\n    return `Map(${entries})`;\n  }\n}\n\n/**\n * Creates an empty map\n */\nexport function empty<K, V>(): Map<K, V> {\n  return new MapImpl<K, V>();\n}\n\n/**\n * Map namespace containing utility functions\n */\nexport namespace Map {\n  /**\n   * Creates a map from the provided entries\n   */\n  export function of<K, V>(entries: Iterable<[K, V]>): Map<K, V> {\n    return new MapImpl(entries);\n  }\n\n  /**\n   * Creates a map from a list of key-value pairs\n   */\n  export function fromList<K, V>(entries: List<[K, V]>): Map<K, V> {\n    return of(entries.toArray());\n  }\n\n  /**\n   * Creates a map from a native JavaScript Map\n   */\n  export function fromNativeMap<K, V>(map: globalThis.Map<K, V>): Map<K, V> {\n    return of(map.entries());\n  }\n\n  /**\n   * Creates an empty map\n   */\n  export function empty<K, V>(): Map<K, V> {\n    return new MapImpl<K, V>();\n  }\n\n  /**\n   * Creates a map from a list of keys and a function that computes values\n   */\n  export function fromKeys<K, V>(keys: List<K>, f: (key: K) => V): Map<K, V> {\n    return fromList(keys.map(key => [key, f(key)]));\n  }\n\n  /**\n   * Creates a map from a list of values and a function that computes keys\n   */\n  export function fromValues<K, V>(values: List<V>, f: (value: V) => K): Map<K, V> {\n    return fromList(values.map(value => [f(value), value]));\n  }\n} ","/**\n * Set<A> represents an immutable set of unique values.\n * It's a collection of unique elements with efficient add, remove, and contains operations.\n * \n * @example\n * ```ts\n * import { Set } from 'scats';\n * \n * // Creating sets\n * const a = Set.of(1, 2, 3);\n * const b = Set.empty<number>();\n * const c = a.add(4);\n * \n * // Using sets\n * const union = a.union(Set.of(3, 4, 5)); // Set(1, 2, 3, 4, 5)\n * const intersection = a.intersection(Set.of(2, 3, 4)); // Set(2, 3)\n * const difference = a.difference(Set.of(2, 3)); // Set(1)\n * ```\n */\n\nimport { List } from './List';\n\n/**\n * Set<A> interface that all Set implementations must satisfy\n */\nexport interface Set<A> {\n  /**\n   * Returns true if this set is empty, false otherwise\n   */\n  readonly isEmpty: boolean;\n\n  /**\n   * Returns the number of elements in this set\n   */\n  readonly size: number;\n\n  /**\n   * Returns the elements in this set\n   */\n  readonly values: List<A>;\n\n  /**\n   * Returns true if this set contains the specified element, false otherwise\n   */\n  contains(element: A): boolean;\n\n  /**\n   * Returns a new set with the specified element added\n   */\n  add(element: A): Set<A>;\n\n  /**\n   * Returns a new set with the specified elements added\n   */\n  addAll(elements: Iterable<A>): Set<A>;\n\n  /**\n   * Returns a new set with the specified element removed\n   */\n  remove(element: A): Set<A>;\n\n  /**\n   * Returns a new set with the specified elements removed\n   */\n  removeAll(elements: Iterable<A>): Set<A>;\n\n  /**\n   * Returns a new set that is the union of this set and the specified set\n   */\n  union(that: Set<A>): Set<A>;\n\n  /**\n   * Returns a new set that is the intersection of this set and the specified set\n   */\n  intersection(that: Set<A>): Set<A>;\n\n  /**\n   * Returns a new set that is the difference of this set and the specified set\n   */\n  difference(that: Set<A>): Set<A>;\n\n  /**\n   * Returns true if this set is a subset of the specified set, false otherwise\n   */\n  isSubsetOf(that: Set<A>): boolean;\n\n  /**\n   * Returns true if this set is a proper subset of the specified set, false otherwise\n   */\n  isProperSubsetOf(that: Set<A>): boolean;\n\n  /**\n   * Returns true if this set is a superset of the specified set, false otherwise\n   */\n  isSupersetOf(that: Set<A>): boolean;\n\n  /**\n   * Returns true if this set is a proper superset of the specified set, false otherwise\n   */\n  isProperSupersetOf(that: Set<A>): boolean;\n\n  /**\n   * Returns a new set that is the result of applying the provided function to each element\n   */\n  map<B>(f: (a: A) => B): Set<B>;\n\n  /**\n   * Returns a new set containing only the elements that satisfy the provided predicate\n   */\n  filter(predicate: (a: A) => boolean): Set<A>;\n\n  /**\n   * Returns true if any element in this set satisfies the provided predicate, false otherwise\n   */\n  exists(predicate: (a: A) => boolean): boolean;\n\n  /**\n   * Returns true if all elements in this set satisfy the provided predicate, false otherwise\n   */\n  forAll(predicate: (a: A) => boolean): boolean;\n\n  /**\n   * Returns the result of applying the provided function to each element, starting with the provided initial value\n   */\n  foldLeft<B>(initial: B, f: (acc: B, a: A) => B): B;\n\n  /**\n   * Executes the provided function for each element in this set\n   */\n  forEach(f: (a: A) => void): void;\n\n  /**\n   * Partitions this set into two sets according to the provided predicate\n   */\n  partition(predicate: (a: A) => boolean): [Set<A>, Set<A>];\n\n  /**\n   * Converts this set to a native JavaScript Set\n   */\n  toNativeSet(): globalThis.Set<A>;\n\n  /**\n   * Converts this set to an array\n   */\n  toArray(): A[];\n\n  /**\n   * Returns a string representation of this set\n   */\n  toString(): string;\n}\n\n// Simple implementation that uses a JavaScript Set under the hood\n// A production implementation might use a more efficient data structure\nclass SetImpl<A> implements Set<A> {\n  // Using a native Set for internal storage\n  private readonly _set: globalThis.Set<A>;\n\n  constructor(elements?: Iterable<A>) {\n    this._set = new globalThis.Set(elements);\n  }\n\n  get isEmpty(): boolean {\n    return this._set.size === 0;\n  }\n\n  get size(): number {\n    return this._set.size;\n  }\n\n  get values(): List<A> {\n    return List.fromIterable(this._set.values());\n  }\n\n  contains(element: A): boolean {\n    return this._set.has(element);\n  }\n\n  add(element: A): Set<A> {\n    if (this._set.has(element)) {\n      return this;\n    }\n    const newSet = new globalThis.Set(this._set);\n    newSet.add(element);\n    return new SetImpl(newSet);\n  }\n\n  addAll(elements: Iterable<A>): Set<A> {\n    const newSet = new globalThis.Set(this._set);\n    let changed = false;\n    for (const element of elements) {\n      if (!this._set.has(element)) {\n        newSet.add(element);\n        changed = true;\n      }\n    }\n    return changed ? new SetImpl(newSet) : this;\n  }\n\n  remove(element: A): Set<A> {\n    if (!this._set.has(element)) {\n      return this;\n    }\n    const newSet = new globalThis.Set(this._set);\n    newSet.delete(element);\n    return new SetImpl(newSet);\n  }\n\n  removeAll(elements: Iterable<A>): Set<A> {\n    const newSet = new globalThis.Set(this._set);\n    let changed = false;\n    for (const element of elements) {\n      if (this._set.has(element)) {\n        newSet.delete(element);\n        changed = true;\n      }\n    }\n    return changed ? new SetImpl(newSet) : this;\n  }\n\n  union(that: Set<A>): Set<A> {\n    if (that.isEmpty) {\n      return this;\n    }\n    if (this.isEmpty) {\n      return that;\n    }\n    return this.addAll(that.toArray());\n  }\n\n  intersection(that: Set<A>): Set<A> {\n    if (this.isEmpty || that.isEmpty) {\n      return empty<A>();\n    }\n\n    const newSet = new globalThis.Set<A>();\n    for (const element of this._set) {\n      if (that.contains(element)) {\n        newSet.add(element);\n      }\n    }\n    return new SetImpl(newSet);\n  }\n\n  difference(that: Set<A>): Set<A> {\n    if (this.isEmpty) {\n      return empty<A>();\n    }\n    if (that.isEmpty) {\n      return this;\n    }\n    return this.removeAll(that.toArray());\n  }\n\n  isSubsetOf(that: Set<A>): boolean {\n    if (this.isEmpty) {\n      return true;\n    }\n    if (this.size > that.size) {\n      return false;\n    }\n    return this.forAll(element => that.contains(element));\n  }\n\n  isProperSubsetOf(that: Set<A>): boolean {\n    return this.size < that.size && this.isSubsetOf(that);\n  }\n\n  isSupersetOf(that: Set<A>): boolean {\n    return that.isSubsetOf(this);\n  }\n\n  isProperSupersetOf(that: Set<A>): boolean {\n    return that.isProperSubsetOf(this);\n  }\n\n  map<B>(f: (a: A) => B): Set<B> {\n    const newSet = new globalThis.Set<B>();\n    this._set.forEach(element => {\n      newSet.add(f(element));\n    });\n    return new SetImpl(newSet);\n  }\n\n  filter(predicate: (a: A) => boolean): Set<A> {\n    const newSet = new globalThis.Set<A>();\n    this._set.forEach(element => {\n      if (predicate(element)) {\n        newSet.add(element);\n      }\n    });\n    return new SetImpl(newSet);\n  }\n\n  exists(predicate: (a: A) => boolean): boolean {\n    for (const element of this._set) {\n      if (predicate(element)) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  forAll(predicate: (a: A) => boolean): boolean {\n    for (const element of this._set) {\n      if (!predicate(element)) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  foldLeft<B>(initial: B, f: (acc: B, a: A) => B): B {\n    let result = initial;\n    this._set.forEach(element => {\n      result = f(result, element);\n    });\n    return result;\n  }\n\n  forEach(f: (a: A) => void): void {\n    this._set.forEach(element => {\n      f(element);\n    });\n  }\n\n  partition(predicate: (a: A) => boolean): [Set<A>, Set<A>] {\n    const trueSet = new globalThis.Set<A>();\n    const falseSet = new globalThis.Set<A>();\n    this._set.forEach(element => {\n      if (predicate(element)) {\n        trueSet.add(element);\n      } else {\n        falseSet.add(element);\n      }\n    });\n    return [new SetImpl(trueSet), new SetImpl(falseSet)];\n  }\n\n  toNativeSet(): globalThis.Set<A> {\n    return new globalThis.Set(this._set);\n  }\n\n  toArray(): A[] {\n    return Array.from(this._set);\n  }\n\n  toString(): string {\n    if (this.isEmpty) {\n      return \"Set()\";\n    }\n    return `Set(${this.toArray().join(\", \")})`;\n  }\n}\n\n/**\n * Creates an empty set\n */\nexport function empty<A>(): Set<A> {\n  return new SetImpl<A>();\n}\n\n/**\n * Set namespace containing utility functions\n */\nexport namespace Set {\n  /**\n   * Creates a set containing the provided elements\n   */\n  export function of<A>(...elements: A[]): Set<A> {\n    return new SetImpl(elements);\n  }\n\n  /**\n   * Creates a set from the provided iterable\n   */\n  export function fromIterable<A>(iterable: Iterable<A>): Set<A> {\n    return new SetImpl(iterable);\n  }\n\n  /**\n   * Creates a set from a native JavaScript Set\n   */\n  export function fromNativeSet<A>(set: globalThis.Set<A>): Set<A> {\n    return new SetImpl(set);\n  }\n\n  /**\n   * Creates an empty set\n   */\n  export function empty<A>(): Set<A> {\n    return new SetImpl<A>();\n  }\n} ","import { Option, Some, None } from '../Option';\nimport { List as ScatsList } from '../List';\nimport { Set as ScatsSet } from '../Set';\nimport { Map as ScatsMap } from '../Map';\n\n/**\n * Represents a collection of elements that can be iterated over.\n * This trait is the base for all collection types in the library.\n */\nexport interface Iterable<A> {\n  /**\n   * Returns an iterator that yields every element in the collection.\n   */\n  iterator(): Iterator<A>;\n\n  /**\n   * Implements the iterable protocol for for...of loops\n   */\n  [Symbol.iterator](): Iterator<A>;\n\n  /**\n   * Executes a function for each element in the collection.\n   */\n  forEach(f: (a: A) => void): void;\n\n  /**\n   * Returns a new collection containing the results of applying the given function\n   * to each element of this collection.\n   */\n  map<B>(f: (a: A) => B): Iterable<B>;\n\n  /**\n   * Returns a new collection containing the results of applying the given collection-valued function\n   * to each element of this collection and concatenating the results.\n   */\n  flatMap<B>(f: (a: A) => Iterable<B>): Iterable<B>;\n\n  /**\n   * Returns a new collection containing the results of applying the given partial function\n   * to each element of this collection for which it is defined and collecting the results.\n   */\n  collect<B>(f: (a: A) => Option<B>): Iterable<B>;\n\n  /**\n   * Returns a new collection consisting of the elements of both this collection and the other collection.\n   */\n  concat(other: Iterable<A>): Iterable<A>;\n\n  /**\n   * Returns a new collection consisting of those elements of this collection that satisfy the predicate.\n   */\n  filter(p: (a: A) => boolean): Iterable<A>;\n\n  /**\n   * Returns a new collection consisting of those elements of this collection that do not satisfy the predicate.\n   */\n  filterNot(p: (a: A) => boolean): Iterable<A>;\n\n  /**\n   * Returns a non-strict filter of this collection.\n   * Subsequent calls to map, flatMap, foreach, and withFilter will only apply to those elements\n   * of this collection for which the condition p is true.\n   */\n  withFilter(p: (a: A) => boolean): Iterable<A>;\n\n  /**\n   * Returns the first element of this collection.\n   * @throws Error if the collection is empty\n   */\n  head(): A;\n\n  /**\n   * Returns the first element of this collection in an option value, or None if the collection is empty.\n   */\n  headOption(): Option<A>;\n\n  /**\n   * Returns the last element of this collection.\n   * @throws Error if the collection is empty\n   */\n  last(): A;\n\n  /**\n   * Returns the last element of this collection in an option value, or None if the collection is empty.\n   */\n  lastOption(): Option<A>;\n\n  /**\n   * Returns an option containing the first element in this collection that satisfies the predicate,\n   * or None if no element qualifies.\n   */\n  find(p: (a: A) => boolean): Option<A>;\n\n  /**\n   * Returns the rest of the collection except the first element.\n   * @throws Error if the collection is empty\n   */\n  tail(): Iterable<A>;\n\n  /**\n   * Returns the rest of the collection except the last element.\n   * @throws Error if the collection is empty\n   */\n  init(): Iterable<A>;\n\n  /**\n   * Returns a collection consisting of elements in some index range of this collection.\n   */\n  slice(from: number, to: number): Iterable<A>;\n\n  /**\n   * Returns a collection consisting of the first n elements of this collection.\n   */\n  take(n: number): Iterable<A>;\n\n  /**\n   * Returns the rest of the collection except the first n elements.\n   */\n  drop(n: number): Iterable<A>;\n\n  /**\n   * Returns the longest prefix of elements in the collection that all satisfy the predicate.\n   */\n  takeWhile(p: (a: A) => boolean): Iterable<A>;\n\n  /**\n   * Returns the collection without the longest prefix of elements that all satisfy the predicate.\n   */\n  dropWhile(p: (a: A) => boolean): Iterable<A>;\n\n  /**\n   * Returns a collection consisting of the last n elements of this collection.\n   */\n  takeRight(n: number): Iterable<A>;\n\n  /**\n   * Returns the rest of the collection except the last n elements.\n   */\n  dropRight(n: number): Iterable<A>;\n\n  /**\n   * Split this collection at a position, giving the pair of collections (take n, drop n).\n   */\n  splitAt(n: number): [Iterable<A>, Iterable<A>];\n\n  /**\n   * Split this collection according to a predicate, giving the pair of collections\n   * (takeWhile p, dropWhile p).\n   */\n  span(p: (a: A) => boolean): [Iterable<A>, Iterable<A>];\n\n  /**\n   * Split this collection into a pair of collections; one with elements that satisfy the predicate,\n   * the other with elements that do not.\n   */\n  partition(p: (a: A) => boolean): [Iterable<A>, Iterable<A>];\n\n  /**\n   * Partition this collection into a map of collections according to a discriminator function.\n   */\n  groupBy<K>(f: (a: A) => K): globalThis.Map<K, Iterable<A>>;\n\n  /**\n   * Tests whether the predicate holds for all elements of this collection.\n   */\n  forall(p: (a: A) => boolean): boolean;\n\n  /**\n   * Tests whether the predicate holds for some element of this collection.\n   */\n  exists(p: (a: A) => boolean): boolean;\n\n  /**\n   * Returns the number of elements in this collection that satisfy the predicate.\n   */\n  count(p: (a: A) => boolean): number;\n\n  /**\n   * Apply binary operation op between successive elements of this collection,\n   * going left to right and starting with z.\n   */\n  foldLeft<B>(z: B, op: (b: B, a: A) => B): B;\n\n  /**\n   * Apply binary operation op between successive elements of this collection,\n   * going right to left and starting with z.\n   */\n  foldRight<B>(z: B, op: (a: A, b: B) => B): B;\n\n  /**\n   * Apply binary operation op between successive elements of non-empty collection,\n   * going left to right.\n   * @throws Error if the collection is empty\n   */\n  reduceLeft(op: (a: A, b: A) => A): A;\n\n  /**\n   * Apply binary operation op between successive elements of non-empty collection,\n   * going right to left.\n   * @throws Error if the collection is empty\n   */\n  reduceRight(op: (a: A, b: A) => A): A;\n\n  /**\n   * Returns the sum of the numeric element values of this collection.\n   * @throws Error if the collection is empty or contains non-numeric values\n   */\n  sum(): number;\n\n  /**\n   * Returns the product of the numeric element values of this collection.\n   * @throws Error if the collection is empty or contains non-numeric values\n   */\n  product(): number;\n\n  /**\n   * Returns the minimum of the ordered element values of this collection.\n   * @throws Error if the collection is empty\n   */\n  min(): A;\n\n  /**\n   * Returns the maximum of the ordered element values of this collection.\n   * @throws Error if the collection is empty\n   */\n  max(): A;\n\n  /**\n   * Like min but returns None if the collection is empty.\n   */\n  minOption(): Option<A>;\n\n  /**\n   * Like max but returns None if the collection is empty.\n   */\n  maxOption(): Option<A>;\n\n  /**\n   * Converts the collection to a string that shows all elements between separators\n   * enclosed in strings start and end.\n   */\n  mkString(start?: string, sep?: string, end?: string): string;\n\n  /**\n   * Returns a collection of pairs of corresponding elements from this collection and the other collection.\n   */\n  zip<B>(other: Iterable<B>): Iterable<[A, B]>;\n\n  /**\n   * Returns a collection of pairs of corresponding elements from this collection and the other collection,\n   * where the shorter sequence is extended to match the longer one by appending elements x or y.\n   */\n  zipAll<B>(other: Iterable<B>, thisElem: A, thatElem: B): Iterable<[A, B]>;\n\n  /**\n   * Returns a collection of pairs of elements from this collection with their indices.\n   */\n  zipWithIndex(): Iterable<[A, number]>;\n\n  /**\n   * Tests whether the collection is empty.\n   */\n  isEmpty(): boolean;\n\n  /**\n   * Tests whether the collection contains elements.\n   */\n  nonEmpty(): boolean;\n\n  /**\n   * Returns the number of elements in the collection.\n   */\n  size(): number;\n\n  /**\n   * Returns the number of elements, if this one takes constant time to compute, otherwise -1.\n   */\n  knownSize(): number;\n\n  /**\n   * Returns a negative value if this collection is shorter than the other collection,\n   * a positive value if it is longer, and 0 if they have the same size.\n   * \n   * Can also be called with a number to compare the collection size with that number.\n   */\n  sizeCompare(other: Iterable<any> | number): number;\n\n  /**\n   * Returns an iterator that yields fixed-sized \"chunks\" of this collection.\n   */\n  grouped(size: number): Iterator<Iterable<A>> & Iterable<Iterable<A>>;\n\n  /**\n   * Returns an iterator that yields a sliding fixed-sized window of elements in this collection.\n   */\n  sliding(size: number): Iterator<Iterable<A>> & Iterable<Iterable<A>>;\n\n  /**\n   * Converts the collection to an array.\n   */\n  toArray(): A[];\n\n  /**\n   * Converts the collection to a list.\n   */\n  toList(): ScatsList<A>;\n\n  /**\n   * Converts the collection to a set.\n   */\n  toSet(): ScatsSet<A>;\n\n  /**\n   * Converts the collection to a map.\n   * @throws Error if the collection does not have pairs as elements\n   */\n  toMap<K, V>(): ScatsMap<K, V>;\n}\n\n/**\n * Abstract base class implementing the Iterable trait.\n * This provides default implementations for many methods based on the iterator method.\n */\nexport abstract class AbstractIterable<A> implements Iterable<A> {\n  abstract iterator(): Iterator<A>;\n\n  [Symbol.iterator](): Iterator<A> {\n    return this.iterator();\n  }\n\n  forEach(f: (a: A) => void): void {\n    for (const a of this) {\n      f(a);\n    }\n  }\n\n  map<B>(f: (a: A) => B): Iterable<B> {\n    return new MappedIterable(this, f);\n  }\n\n  flatMap<B>(f: (a: A) => Iterable<B>): Iterable<B> {\n    return new FlatMappedIterable(this, f);\n  }\n\n  collect<B>(f: (a: A) => Option<B>): Iterable<B> {\n    return new CollectedIterable(this, f);\n  }\n\n  concat(other: Iterable<A>): Iterable<A> {\n    return new ConcatenatedIterable(this, other);\n  }\n\n  filter(p: (a: A) => boolean): Iterable<A> {\n    return new FilteredIterable(this, p);\n  }\n\n  filterNot(p: (a: A) => boolean): Iterable<A> {\n    return this.filter(a => !p(a));\n  }\n\n  withFilter(p: (a: A) => boolean): Iterable<A> {\n    return this.filter(p);\n  }\n\n  head(): A {\n    const iterator = this.iterator();\n    const result = iterator.next();\n    if (result.done) {\n      throw new Error(\"Collection is empty\");\n    }\n    return result.value;\n  }\n\n  headOption(): Option<A> {\n    const iterator = this.iterator();\n    const result = iterator.next();\n    return result.done ? None : Some(result.value);\n  }\n\n  last(): A {\n    let last: A | undefined;\n    let hasElements = false;\n\n    for (const a of this) {\n      last = a;\n      hasElements = true;\n    }\n\n    if (!hasElements) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    return last as A;\n  }\n\n  lastOption(): Option<A> {\n    let last: A | undefined;\n    let hasElements = false;\n\n    for (const a of this) {\n      last = a;\n      hasElements = true;\n    }\n\n    return hasElements ? Some(last as A) : None;\n  }\n\n  find(p: (a: A) => boolean): Option<A> {\n    for (const a of this) {\n      if (p(a)) {\n        return Some(a);\n      }\n    }\n    return None;\n  }\n\n  tail(): Iterable<A> {\n    const iterator = this.iterator();\n    const result = iterator.next();\n    if (result.done) {\n      throw new Error(\"Collection is empty\");\n    }\n    return new TailIterable(this);\n  }\n\n  init(): Iterable<A> {\n    if (this.isEmpty()) {\n      throw new Error(\"Collection is empty\");\n    }\n    return new InitIterable(this);\n  }\n\n  slice(from: number, to: number): Iterable<A> {\n    return new SlicedIterable(this, from, to);\n  }\n\n  take(n: number): Iterable<A> {\n    return new TakenIterable(this, n);\n  }\n\n  drop(n: number): Iterable<A> {\n    return new DroppedIterable(this, n);\n  }\n\n  takeWhile(p: (a: A) => boolean): Iterable<A> {\n    return new TakeWhileIterable(this, p);\n  }\n\n  dropWhile(p: (a: A) => boolean): Iterable<A> {\n    return new DropWhileIterable(this, p);\n  }\n\n  takeRight(n: number): Iterable<A> {\n    return new TakeRightIterable(this, n);\n  }\n\n  dropRight(n: number): Iterable<A> {\n    return new DropRightIterable(this, n);\n  }\n\n  splitAt(n: number): [Iterable<A>, Iterable<A>] {\n    return [this.take(n), this.drop(n)];\n  }\n\n  span(p: (a: A) => boolean): [Iterable<A>, Iterable<A>] {\n    return [this.takeWhile(p), this.dropWhile(p)];\n  }\n\n  partition(p: (a: A) => boolean): [Iterable<A>, Iterable<A>] {\n    return [this.filter(p), this.filterNot(p)];\n  }\n\n  groupBy<K>(f: (a: A) => K): globalThis.Map<K, Iterable<A>> {\n    const map = new globalThis.Map<K, A[]>();\n\n    for (const a of this) {\n      const key = f(a);\n      const group = map.get(key) || [];\n      group.push(a);\n      map.set(key, group);\n    }\n\n    const result = new globalThis.Map<K, Iterable<A>>();\n    for (const [key, values] of map.entries()) {\n      result.set(key, new ArrayIterable(values));\n    }\n\n    return result;\n  }\n\n  forall(p: (a: A) => boolean): boolean {\n    for (const a of this) {\n      if (!p(a)) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  exists(p: (a: A) => boolean): boolean {\n    for (const a of this) {\n      if (p(a)) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  count(p: (a: A) => boolean): number {\n    let count = 0;\n    for (const a of this) {\n      if (p(a)) {\n        count++;\n      }\n    }\n    return count;\n  }\n\n  foldLeft<B>(z: B, op: (b: B, a: A) => B): B {\n    let result = z;\n    for (const a of this) {\n      result = op(result, a);\n    }\n    return result;\n  }\n\n  foldRight<B>(z: B, op: (a: A, b: B) => B): B {\n    const array = this.toArray();\n    let result = z;\n    for (let i = array.length - 1; i >= 0; i--) {\n      result = op(array[i], result);\n    }\n    return result;\n  }\n\n  reduceLeft(op: (a: A, b: A) => A): A {\n    const iterator = this.iterator();\n    const first = iterator.next();\n    if (first.done) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    let result = first.value;\n    let hasStarted = false;\n\n    for (const a of this) {\n      if (!hasStarted) {\n        hasStarted = true;\n        continue; // Skip the first element since we already used it\n      }\n      result = op(result, a);\n    }\n    return result;\n  }\n\n  reduceRight(op: (a: A, b: A) => A): A {\n    const array = this.toArray();\n    if (array.length === 0) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    let result = array[array.length - 1];\n    for (let i = array.length - 2; i >= 0; i--) {\n      result = op(array[i], result);\n    }\n    return result;\n  }\n\n  sum(): number {\n    return this.foldLeft(0, (sum, a) => {\n      if (typeof a !== 'number') {\n        throw new Error(\"Collection contains non-numeric values\");\n      }\n      return sum + a;\n    });\n  }\n\n  product(): number {\n    return this.foldLeft(1, (prod, a) => {\n      if (typeof a !== 'number') {\n        throw new Error(\"Collection contains non-numeric values\");\n      }\n      return prod * a;\n    });\n  }\n\n  min(): A {\n    if (this.isEmpty()) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    let min: A | undefined;\n    let first = true;\n\n    for (const a of this) {\n      if (first || (a as any) < (min as any)) {\n        min = a;\n        first = false;\n      }\n    }\n\n    return min as A;\n  }\n\n  max(): A {\n    if (this.isEmpty()) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    let max: A | undefined;\n    let first = true;\n\n    for (const a of this) {\n      if (first || (a as any) > (max as any)) {\n        max = a;\n        first = false;\n      }\n    }\n\n    return max as A;\n  }\n\n  minOption(): Option<A> {\n    if (this.isEmpty()) {\n      return None;\n    }\n    return Some(this.min());\n  }\n\n  maxOption(): Option<A> {\n    if (this.isEmpty()) {\n      return None;\n    }\n    return Some(this.max());\n  }\n\n  mkString(start: string = \"\", sep: string = \"\", end: string = \"\"): string {\n    const elements = this.toArray();\n    return start + elements.join(sep) + end;\n  }\n\n  zip<B>(other: Iterable<B>): Iterable<[A, B]> {\n    return new ZippedIterable(this, other);\n  }\n\n  zipAll<B>(other: Iterable<B>, thisElem: A, thatElem: B): Iterable<[A, B]> {\n    return new ZipAllIterable(this, other, thisElem, thatElem);\n  }\n\n  zipWithIndex(): Iterable<[A, number]> {\n    return new ZipWithIndexIterable(this);\n  }\n\n  isEmpty(): boolean {\n    const result = this.iterator().next();\n    return !!result.done;\n  }\n\n  nonEmpty(): boolean {\n    return !this.isEmpty();\n  }\n\n  size(): number {\n    let count = 0;\n    for (const _ of this) {\n      count++;\n    }\n    return count;\n  }\n\n  knownSize(): number {\n    return -1; // Default implementation doesn't know the size\n  }\n\n  sizeCompare(other: Iterable<any> | number): number {\n    const thisSize = this.size();\n\n    if (typeof other === 'number') {\n      return thisSize - other;\n    } else {\n      const otherSize = other.size();\n      return thisSize - otherSize;\n    }\n  }\n\n  grouped(size: number): Iterator<Iterable<A>> & Iterable<Iterable<A>> {\n    return new GroupedIterator(this, size);\n  }\n\n  sliding(size: number): Iterator<Iterable<A>> & Iterable<Iterable<A>> {\n    return new SlidingIterator(this, size);\n  }\n\n  toArray(): A[] {\n    const result: A[] = [];\n    for (const a of this) {\n      result.push(a);\n    }\n    return result;\n  }\n\n  toList(): ScatsList<A> {\n    return ScatsList.of(...this.toArray());\n  }\n\n  toSet(): ScatsSet<A> {\n    return ScatsSet.of(...this.toArray());\n  }\n\n  toMap<K, V>(): ScatsMap<K, V> {\n    const entries: Array<[K, V]> = [];\n    for (const a of this) {\n      if (!Array.isArray(a) || a.length !== 2) {\n        throw new Error(\"Collection does not have pairs as elements\");\n      }\n      entries.push([a[0] as K, a[1] as V]);\n    }\n    return ScatsMap.of(entries);\n  }\n}\n\n// Implementation classes for various operations\n\nclass MappedIterable<A, B> extends AbstractIterable<B> {\n  constructor(private source: Iterable<A>, private f: (a: A) => B) {\n    super();\n  }\n\n  iterator(): Iterator<B> {\n    const sourceIterator = this.source.iterator();\n    return {\n      next: () => {\n        const result = sourceIterator.next();\n        if (result.done) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: this.f(result.value) };\n      }\n    };\n  }\n}\n\nclass FlatMappedIterable<A, B> extends AbstractIterable<B> {\n  constructor(private source: Iterable<A>, private f: (a: A) => Iterable<B>) {\n    super();\n  }\n\n  iterator(): Iterator<B> {\n    const sourceIterator = this.source.iterator();\n    let currentIterator: Iterator<B> | null = null;\n\n    return {\n      next: () => {\n        // Loop until we find a value or reach the end\n        while (true) {\n          if (currentIterator === null) {\n            const sourceResult = sourceIterator.next();\n            if (sourceResult.done) {\n              return { done: true, value: undefined as any };\n            }\n            currentIterator = this.f(sourceResult.value).iterator();\n          }\n\n          const result = currentIterator.next();\n          if (result.done) {\n            currentIterator = null;\n            continue;\n          }\n\n          return { done: false, value: result.value };\n        }\n\n        // This line is never reached but satisfies TypeScript\n        return { done: true, value: undefined as any };\n      }\n    };\n  }\n}\n\nclass CollectedIterable<A, B> extends AbstractIterable<B> {\n  constructor(private source: Iterable<A>, private f: (a: A) => Option<B>) {\n    super();\n  }\n\n  iterator(): Iterator<B> {\n    const sourceIterator = this.source.iterator();\n\n    return {\n      next: () => {\n        // Loop until we find a value or reach the end\n        while (true) {\n          const sourceResult = sourceIterator.next();\n          if (sourceResult.done) {\n            return { done: true, value: undefined as any };\n          }\n\n          const option = this.f(sourceResult.value);\n          if (option.isSome) {\n            return { done: false, value: option.get() };\n          }\n        }\n\n        // This line is never reached but satisfies TypeScript\n        return { done: true, value: undefined as any };\n      }\n    };\n  }\n}\n\nclass ConcatenatedIterable<A> extends AbstractIterable<A> {\n  constructor(private first: Iterable<A>, private second: Iterable<A>) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const firstIterator = this.first.iterator();\n    const secondIterator = this.second.iterator();\n    let firstDone = false;\n\n    return {\n      next: () => {\n        if (!firstDone) {\n          const result = firstIterator.next();\n          if (!result.done) {\n            return { done: false, value: result.value };\n          }\n          firstDone = true;\n        }\n\n        const result = secondIterator.next();\n        if (result.done) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: result.value };\n      }\n    };\n  }\n}\n\nclass FilteredIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private p: (a: A) => boolean) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const sourceIterator = this.source.iterator();\n\n    return {\n      next: () => {\n        // Loop until we find a value or reach the end\n        while (true) {\n          const result = sourceIterator.next();\n          if (result.done) {\n            return { done: true, value: undefined as any };\n          }\n\n          if (this.p(result.value)) {\n            return { done: false, value: result.value };\n          }\n        }\n\n        // This line is never reached but satisfies TypeScript\n        return { done: true, value: undefined as any };\n      }\n    };\n  }\n}\n\nclass TailIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const sourceIterator = this.source.iterator();\n    const first = sourceIterator.next();\n    if (first.done) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    return {\n      next: () => {\n        const result = sourceIterator.next();\n        if (result.done) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: result.value };\n      }\n    };\n  }\n}\n\nclass InitIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const array = this.source.toArray();\n    if (array.length === 0) {\n      throw new Error(\"Collection is empty\");\n    }\n\n    let index = 0;\n    return {\n      next: () => {\n        if (index >= array.length - 1) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: array[index++] };\n      }\n    };\n  }\n}\n\nclass SlicedIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private from: number, private to: number) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const array = this.source.toArray();\n    const start = Math.max(0, this.from);\n    const end = Math.min(array.length, this.to);\n    let index = start;\n\n    return {\n      next: () => {\n        if (index >= end) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: array[index++] };\n      }\n    };\n  }\n}\n\nclass TakenIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private n: number) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const sourceIterator = this.source.iterator();\n    let count = 0;\n\n    return {\n      next: () => {\n        if (count >= this.n) {\n          return { done: true, value: undefined as any };\n        }\n\n        const result = sourceIterator.next();\n        if (result.done) {\n          return { done: true, value: undefined as any };\n        }\n\n        count++;\n        return { done: false, value: result.value };\n      }\n    };\n  }\n}\n\nclass DroppedIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private n: number) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const sourceIterator = this.source.iterator();\n    let count = 0;\n\n    return {\n      next: () => {\n        while (count < this.n) {\n          const result = sourceIterator.next();\n          if (result.done) {\n            return { done: true, value: undefined as any };\n          }\n          count++;\n        }\n\n        const result = sourceIterator.next();\n        if (result.done) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: result.value };\n      }\n    };\n  }\n}\n\nclass TakeWhileIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private p: (a: A) => boolean) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const sourceIterator = this.source.iterator();\n    let done = false;\n\n    return {\n      next: () => {\n        if (done) {\n          return { done: true, value: undefined as any };\n        }\n\n        const result = sourceIterator.next();\n        if (result.done) {\n          done = true;\n          return { done: true, value: undefined as any };\n        }\n\n        if (!this.p(result.value)) {\n          done = true;\n          return { done: true, value: undefined as any };\n        }\n\n        return { done: false, value: result.value };\n      }\n    };\n  }\n}\n\nclass DropWhileIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private p: (a: A) => boolean) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const sourceIterator = this.source.iterator();\n    let found = false;\n\n    return {\n      next: () => {\n        if (found) {\n          const result = sourceIterator.next();\n          if (result.done) {\n            return { done: true, value: undefined as any };\n          }\n          return { done: false, value: result.value };\n        }\n\n        // Loop until we find a value or reach the end\n        while (true) {\n          const result = sourceIterator.next();\n          if (result.done) {\n            return { done: true, value: undefined as any };\n          }\n\n          if (!this.p(result.value)) {\n            found = true;\n            return { done: false, value: result.value };\n          }\n        }\n\n        // This line is never reached but satisfies TypeScript\n        return { done: true, value: undefined as any };\n      }\n    };\n  }\n}\n\nclass TakeRightIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private n: number) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const array = this.source.toArray();\n    const start = Math.max(0, array.length - this.n);\n    let index = start;\n\n    return {\n      next: () => {\n        if (index >= array.length) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: array[index++] };\n      }\n    };\n  }\n}\n\nclass DropRightIterable<A> extends AbstractIterable<A> {\n  constructor(private source: Iterable<A>, private n: number) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    const array = this.source.toArray();\n    const end = Math.max(0, array.length - this.n);\n    let index = 0;\n\n    return {\n      next: () => {\n        if (index >= end) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: array[index++] };\n      }\n    };\n  }\n}\n\nclass ZippedIterable<A, B> extends AbstractIterable<[A, B]> {\n  constructor(private first: Iterable<A>, private second: Iterable<B>) {\n    super();\n  }\n\n  iterator(): Iterator<[A, B]> {\n    const firstIterator = this.first.iterator();\n    const secondIterator = this.second.iterator();\n\n    return {\n      next: () => {\n        const firstResult = firstIterator.next();\n        const secondResult = secondIterator.next();\n\n        if (firstResult.done || secondResult.done) {\n          return { done: true, value: undefined as any };\n        }\n\n        return { done: false, value: [firstResult.value, secondResult.value] };\n      }\n    };\n  }\n}\n\nclass ZipAllIterable<A, B> extends AbstractIterable<[A, B]> {\n  constructor(\n    private first: Iterable<A>,\n    private second: Iterable<B>,\n    private thisElem: A,\n    private thatElem: B\n  ) {\n    super();\n  }\n\n  iterator(): Iterator<[A, B]> {\n    const firstIterator = this.first.iterator();\n    const secondIterator = this.second.iterator();\n    let firstDone = false;\n    let secondDone = false;\n\n    return {\n      next: () => {\n        const firstResult = firstIterator.next();\n        const secondResult = secondIterator.next();\n\n        if (firstResult.done) {\n          firstDone = true;\n        }\n\n        if (secondResult.done) {\n          secondDone = true;\n        }\n\n        if (firstDone && secondDone) {\n          return { done: true, value: undefined as any };\n        }\n\n        const a = firstDone ? this.thisElem : firstResult.value;\n        const b = secondDone ? this.thatElem : secondResult.value;\n\n        return { done: false, value: [a, b] };\n      }\n    };\n  }\n}\n\nclass ZipWithIndexIterable<A> extends AbstractIterable<[A, number]> {\n  constructor(private source: Iterable<A>) {\n    super();\n  }\n\n  iterator(): Iterator<[A, number]> {\n    const sourceIterator = this.source.iterator();\n    let index = 0;\n\n    return {\n      next: () => {\n        const result = sourceIterator.next();\n        if (result.done) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: [result.value, index++] };\n      }\n    };\n  }\n}\n\nclass GroupedIterator<A> extends AbstractIterable<Iterable<A>> implements Iterator<Iterable<A>> {\n  private sourceIterator: Iterator<A>;\n  private buffer: A[] = [];\n  private isDone = false;\n  private chunkSize: number;\n\n  constructor(source: Iterable<A>, chunkSize: number) {\n    super();\n    this.sourceIterator = source.iterator();\n    this.chunkSize = chunkSize;\n  }\n\n  iterator(): Iterator<Iterable<A>> {\n    return this;\n  }\n\n  next(): IteratorResult<Iterable<A>> {\n    if (this.isDone) {\n      return { done: true, value: undefined as any };\n    }\n\n    this.buffer = [];\n    for (let i = 0; i < this.chunkSize; i++) {\n      const result = this.sourceIterator.next();\n      if (result.done) {\n        this.isDone = true;\n        break;\n      }\n      this.buffer.push(result.value);\n    }\n\n    if (this.buffer.length === 0) {\n      return { done: true, value: undefined as any };\n    }\n\n    return { done: false, value: new ArrayIterable(this.buffer) };\n  }\n}\n\nclass SlidingIterator<A> extends AbstractIterable<Iterable<A>> implements Iterator<Iterable<A>> {\n  private sourceArray: A[];\n  private index = 0;\n  private windowSize: number;\n\n  constructor(source: Iterable<A>, windowSize: number) {\n    super();\n    this.sourceArray = source.toArray();\n    this.windowSize = windowSize;\n  }\n\n  iterator(): Iterator<Iterable<A>> {\n    return this;\n  }\n\n  next(): IteratorResult<Iterable<A>> {\n    if (this.index + this.windowSize > this.sourceArray.length) {\n      return { done: true, value: undefined as any };\n    }\n\n    const result = new ArrayIterable(this.sourceArray.slice(this.index, this.index + this.windowSize));\n    this.index++;\n    return { done: false, value: result };\n  }\n}\n\nclass ArrayIterable<A> extends AbstractIterable<A> {\n  constructor(private array: A[]) {\n    super();\n  }\n\n  iterator(): Iterator<A> {\n    let index = 0;\n    return {\n      next: () => {\n        if (index >= this.array.length) {\n          return { done: true, value: undefined as any };\n        }\n        return { done: false, value: this.array[index++] };\n      }\n    };\n  }\n\n  knownSize(): number {\n    return this.array.length;\n  }\n}\n","import { AbstractIterable, Iterable } from './Iterable';\nimport { Seq } from './Seq';\n\n/**\n * Abstract base class for sequence implementations.\n */\nexport abstract class AbstractSeq<A> extends AbstractIterable<A> implements Seq<A> {\n  /**\n   * Returns the element at the specified index.\n   */\n  apply(i: number): A {\n    if (i < 0 || i >= this.size()) {\n      throw new Error(`Index out of bounds: ${i}`);\n    }\n    let j = 0;\n    for (const elem of this) {\n      if (j === i) return elem;\n      j++;\n    }\n    throw new Error(`Index out of bounds: ${i}`); // Should never reach here\n  }\n\n  /**\n   * Tests whether an index is contained in this sequence's range.\n   */\n  isDefinedAt(i: number): boolean {\n    return i >= 0 && i < this.size();\n  }\n\n  /**\n   * Returns the index range of this sequence, from 0 to length - 1.\n   */\n  indices(): Iterable<number> {\n    const size = this.size();\n    return new class extends AbstractIterable<number> {\n      iterator(): Iterator<number> {\n        let i = 0;\n        return {\n          next: () => {\n            if (i < size) {\n              return { done: false, value: i++ };\n            } else {\n              return { done: true, value: undefined as any };\n            }\n          }\n        };\n      }\n    }();\n  }\n\n  /**\n   * Compares the length of this sequence with a specified value.\n   */\n  lengthCompare(len: number): number {\n    const size = this.size();\n    if (size < len) return -1;\n    if (size > len) return 1;\n    return 0;\n  }\n\n  /**\n   * Finds the index of the first occurrence of an element.\n   */\n  indexOf(elem: A, from: number = 0): number {\n    let i = 0;\n    for (const a of this) {\n      if (i >= from && this.equals(a, elem)) {\n        return i;\n      }\n      i++;\n    }\n    return -1;\n  }\n\n  /**\n   * Finds the index of the last occurrence of an element.\n   */\n  lastIndexOf(elem: A, end: number = this.size() - 1): number {\n    const arr = this.toArray();\n    for (let i = Math.min(end, arr.length - 1); i >= 0; i--) {\n      if (this.equals(arr[i], elem)) {\n        return i;\n      }\n    }\n    return -1;\n  }\n\n  /**\n   * Finds the first index where a subsequence occurs.\n   */\n  indexOfSlice<B>(that: Seq<B>, from: number = 0): number {\n    const thatArr = that.toArray();\n    if (thatArr.length === 0) return from;\n\n    let i = from;\n    const thisArr = this.toArray();\n\n    outer: while (i <= thisArr.length - thatArr.length) {\n      for (let j = 0; j < thatArr.length; j++) {\n        if (!this.equals(thisArr[i + j], thatArr[j])) {\n          i++;\n          continue outer;\n        }\n      }\n      return i;\n    }\n\n    return -1;\n  }\n\n  /**\n   * Finds the last index where a subsequence occurs.\n   */\n  lastIndexOfSlice<B>(that: Seq<B>, end: number = this.size() - 1): number {\n    const thatArr = that.toArray();\n    if (thatArr.length === 0) return Math.min(end, this.size());\n\n    const thisArr = this.toArray();\n    const maxStartIdx = Math.min(end, thisArr.length - thatArr.length);\n\n    for (let i = maxStartIdx; i >= 0; i--) {\n      let found = true;\n      for (let j = 0; j < thatArr.length; j++) {\n        if (!this.equals(thisArr[i + j], thatArr[j])) {\n          found = false;\n          break;\n        }\n      }\n      if (found) return i;\n    }\n\n    return -1;\n  }\n\n  /**\n   * Finds the first index where a predicate is satisfied.\n   */\n  indexWhere(p: (a: A) => boolean, from: number = 0): number {\n    let i = 0;\n    for (const a of this) {\n      if (i >= from && p(a)) {\n        return i;\n      }\n      i++;\n    }\n    return -1;\n  }\n\n  /**\n   * Finds the last index where a predicate is satisfied.\n   */\n  lastIndexWhere(p: (a: A) => boolean, end: number = this.size() - 1): number {\n    const arr = this.toArray();\n    for (let i = Math.min(end, arr.length - 1); i >= 0; i--) {\n      if (p(arr[i])) {\n        return i;\n      }\n    }\n    return -1;\n  }\n\n  /**\n   * Returns the length of the longest segment of elements starting at a given index that all satisfy a predicate.\n   */\n  segmentLength(p: (a: A) => boolean, from: number = 0): number {\n    let i = 0;\n    let count = 0;\n\n    for (const a of this) {\n      if (i < from) {\n        i++;\n        continue;\n      }\n\n      if (p(a)) {\n        count++;\n      } else {\n        break;\n      }\n\n      i++;\n    }\n\n    return count;\n  }\n\n  /**\n   * Returns a new sequence with an element prepended.\n   */\n  abstract prepended(elem: A): Seq<A>;\n\n  /**\n   * Returns a new sequence with elements prepended.\n   */\n  abstract prependedAll<B>(prefix: Iterable<B>): Seq<A | B>;\n\n  /**\n   * Returns a new sequence with an element appended.\n   */\n  abstract appended(elem: A): Seq<A>;\n\n  /**\n   * Returns a new sequence with elements appended.\n   */\n  abstract appendedAll<B>(suffix: Iterable<B>): Seq<A | B>;\n\n  /**\n   * Returns a new sequence padded to a given length with a given value.\n   */\n  padTo(len: number, elem: A): Seq<A> {\n    const size = this.size();\n    if (size >= len) return this;\n\n    return this.appendedAll(new class extends AbstractIterable<A> {\n      iterator(): Iterator<A> {\n        let i = 0;\n        return {\n          next: () => {\n            if (i < len - size) {\n              i++;\n              return { done: false, value: elem };\n            } else {\n              return { done: true, value: undefined as any };\n            }\n          }\n        };\n      }\n    }());\n  }\n\n  /**\n   * Returns a new sequence with a slice of another sequence patched in.\n   */\n  abstract patch<B>(from: number, patch: Seq<B>, replaced: number): Seq<A | B>;\n\n  /**\n   * Returns a new sequence with one element replaced.\n   */\n  abstract updated(index: number, elem: A): Seq<A>;\n\n  /**\n   * Returns a new sequence with elements sorted.\n   */\n  sorted(implicit: (a: A, b: A) => number = (a, b) => (a as any) - (b as any)): Seq<A> {\n    const arr = this.toArray();\n    arr.sort(implicit);\n    return this.fromArray(arr);\n  }\n\n  /**\n   * Returns a new sequence sorted according to a comparison function.\n   */\n  sortWith(lt: (a: A, b: A) => boolean): Seq<A> {\n    const arr = this.toArray();\n    arr.sort((a, b) => lt(a, b) ? -1 : lt(b, a) ? 1 : 0);\n    return this.fromArray(arr);\n  }\n\n  /**\n   * Returns a new sequence sorted according to a key function.\n   */\n  sortBy<B>(f: (a: A) => B, implicit: (a: B, b: B) => number = (a, b) => (a as any) - (b as any)): Seq<A> {\n    const arr = this.toArray();\n    arr.sort((a, b) => implicit(f(a), f(b)));\n    return this.fromArray(arr);\n  }\n\n  /**\n   * Returns a new sequence with elements in reverse order.\n   */\n  reverse(): Seq<A> {\n    const arr = this.toArray();\n    arr.reverse();\n    return this.fromArray(arr);\n  }\n\n  /**\n   * Returns an iterator yielding elements in reverse order.\n   */\n  reverseIterator(): Iterator<A> {\n    const arr = this.toArray();\n    let i = arr.length - 1;\n\n    return {\n      next: () => {\n        if (i >= 0) {\n          return { done: false, value: arr[i--] };\n        } else {\n          return { done: true, value: undefined as any };\n        }\n      }\n    };\n  }\n\n  /**\n   * Tests whether this sequence starts with a given sequence.\n   */\n  startsWith<B>(that: Seq<B>, offset: number = 0): boolean {\n    if (offset < 0) return false;\n\n    const thisArr = this.toArray();\n    const thatArr = that.toArray();\n\n    if (thisArr.length - offset < thatArr.length) return false;\n\n    for (let i = 0; i < thatArr.length; i++) {\n      if (!this.equals(thisArr[i + offset], thatArr[i])) {\n        return false;\n      }\n    }\n\n    return true;\n  }\n\n  /**\n   * Tests whether this sequence ends with a given sequence.\n   */\n  endsWith<B>(that: Seq<B>): boolean {\n    const thisArr = this.toArray();\n    const thatArr = that.toArray();\n\n    if (thisArr.length < thatArr.length) return false;\n\n    const offset = thisArr.length - thatArr.length;\n\n    for (let i = 0; i < thatArr.length; i++) {\n      if (!this.equals(thisArr[i + offset], thatArr[i])) {\n        return false;\n      }\n    }\n\n    return true;\n  }\n\n  /**\n   * Tests whether this sequence contains a given value as an element.\n   */\n  contains(elem: A): boolean {\n    for (const a of this) {\n      if (this.equals(a, elem)) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  /**\n   * Tests whether this sorted sequence contains a given value.\n   */\n  search(elem: A): number {\n    // Binary search could be implemented for sorted sequences\n    // but for simplicity we'll use indexOf\n    return this.indexOf(elem);\n  }\n\n  /**\n   * Tests whether this sequence contains a given sequence as a slice.\n   */\n  containsSlice<B>(that: Seq<B>): boolean {\n    return this.indexOfSlice(that) >= 0;\n  }\n\n  /**\n   * Tests whether corresponding elements of this sequence and another satisfy a predicate.\n   */\n  corresponds<B>(that: Seq<B>, p: (a: A, b: B) => boolean): boolean {\n    const thisIt = this.iterator();\n    const thatIt = that.iterator();\n\n    let thisNext = thisIt.next();\n    let thatNext = thatIt.next();\n\n    while (!thisNext.done && !thatNext.done) {\n      if (!p(thisNext.value, thatNext.value)) return false;\n      thisNext = thisIt.next();\n      thatNext = thatIt.next();\n    }\n\n    // Fix the boolean | undefined issue\n    return Boolean(thisNext.done) && Boolean(thatNext.done);\n  }\n\n  /**\n   * Returns the multi-set intersection of this sequence and another.\n   */\n  intersect<B>(that: Seq<B>): Seq<A> {\n    const thatElements = new Set();\n    for (const b of that) {\n      thatElements.add(b);\n    }\n\n    return this.filter(a => {\n      for (const b of thatElements) {\n        if (this.equals(a, b)) {\n          thatElements.delete(b);\n          return true;\n        }\n      }\n      return false;\n    }) as any as Seq<A>;\n  }\n\n  /**\n   * Returns the multi-set difference of this sequence and another.\n   */\n  diff<B>(that: Seq<B>): Seq<A> {\n    const thatElements = new Set();\n    for (const b of that) {\n      thatElements.add(b);\n    }\n\n    return this.filter(a => {\n      for (const b of thatElements) {\n        if (this.equals(a, b)) {\n          thatElements.delete(b);\n          return false;\n        }\n      }\n      return true;\n    }) as any as Seq<A>;\n  }\n\n  /**\n   * Returns a new sequence with no duplicate elements.\n   */\n  distinct(): Seq<A> {\n    const seen = new Set();\n    return this.filter(a => {\n      for (const b of seen) {\n        if (this.equals(a, b)) return false;\n      }\n      seen.add(a);\n      return true;\n    }) as any as Seq<A>;\n  }\n\n  /**\n   * Returns a new sequence with no duplicate elements according to a transformation function.\n   */\n  distinctBy<B>(f: (a: A) => B): Seq<A> {\n    const seen = new Set();\n    return this.filter(a => {\n      const b = f(a);\n      for (const c of seen) {\n        if (this.equals(b, c)) return false;\n      }\n      seen.add(b);\n      return true;\n    }) as any as Seq<A>;\n  }\n\n  /**\n   * Helper method to compare elements for equality.\n   */\n  protected equals(a: any, b: any): boolean {\n    return a === b;\n  }\n\n  /**\n   * Helper method to create a sequence from an array.\n   */\n  protected abstract fromArray(arr: A[]): Seq<A>;\n} ","import { AbstractSeq } from './AbstractSeq';\nimport { IndexedSeq, Seq } from './Seq';\nimport { Iterable } from './Iterable';\n\n/**\n * An implementation of IndexedSeq backed by an array.\n */\nexport class ArraySeq<A> extends AbstractSeq<A> implements IndexedSeq<A> {\n  /**\n   * Creates a new ArraySeq from the given elements.\n   */\n  constructor(private elements: A[]) {\n    super();\n  }\n\n  /**\n   * Creates a new ArraySeq from the given elements.\n   */\n  static of<A>(...elements: A[]): ArraySeq<A> {\n    return new ArraySeq(elements);\n  }\n\n  /**\n   * Creates a new ArraySeq from an iterable.\n   */\n  static from<A>(iterable: Iterable<A>): ArraySeq<A> {\n    const elements: A[] = [];\n    for (const elem of iterable) {\n      elements.push(elem);\n    }\n    return new ArraySeq(elements);\n  }\n\n  /**\n   * Creates an empty ArraySeq.\n   */\n  static empty<A>(): ArraySeq<A> {\n    return new ArraySeq<A>([]);\n  }\n\n  /**\n   * Returns an iterator over the elements of this sequence.\n   */\n  iterator(): Iterator<A> {\n    let index = 0;\n    return {\n      next: () => {\n        if (index < this.elements.length) {\n          return { done: false, value: this.elements[index++] };\n        } else {\n          return { done: true, value: undefined as any };\n        }\n      }\n    };\n  }\n\n  /**\n   * Returns the element at the specified index.\n   * This is more efficient than the default implementation.\n   */\n  apply(i: number): A {\n    if (i < 0 || i >= this.elements.length) {\n      throw new Error(`Index out of bounds: ${i}`);\n    }\n    return this.elements[i];\n  }\n\n  /**\n   * Returns the size of this sequence.\n   * This is more efficient than the default implementation.\n   */\n  size(): number {\n    return this.elements.length;\n  }\n\n  /**\n   * Returns the known size of this sequence.\n   * This is more efficient than the default implementation.\n   */\n  knownSize(): number {\n    return this.elements.length;\n  }\n\n  /**\n   * Returns a new sequence with an element prepended.\n   */\n  prepended(elem: A): Seq<A> {\n    return new ArraySeq([elem, ...this.elements]);\n  }\n\n  /**\n   * Returns a new sequence with elements prepended.\n   */\n  prependedAll<B>(prefix: Iterable<B>): Seq<A | B> {\n    const newElements: (A | B)[] = [];\n    for (const elem of prefix) {\n      newElements.push(elem);\n    }\n    newElements.push(...this.elements);\n    return new ArraySeq(newElements);\n  }\n\n  /**\n   * Returns a new sequence with an element appended.\n   */\n  appended(elem: A): Seq<A> {\n    return new ArraySeq([...this.elements, elem]);\n  }\n\n  /**\n   * Returns a new sequence with elements appended.\n   */\n  appendedAll<B>(suffix: Iterable<B>): Seq<A | B> {\n    const newElements = [...this.elements] as (A | B)[];\n    for (const elem of suffix) {\n      newElements.push(elem);\n    }\n    return new ArraySeq(newElements);\n  }\n\n  /**\n   * Returns a new sequence with a slice of another sequence patched in.\n   */\n  patch<B>(from: number, patch: Seq<B>, replaced: number): Seq<A | B> {\n    const before = this.elements.slice(0, from);\n    const middle: B[] = [];\n    for (const elem of patch) {\n      middle.push(elem);\n    }\n    const after = this.elements.slice(from + replaced);\n\n    return new ArraySeq([...before, ...middle, ...after]);\n  }\n\n  /**\n   * Returns a new sequence with one element replaced.\n   */\n  updated(index: number, elem: A): Seq<A> {\n    if (index < 0 || index >= this.elements.length) {\n      throw new Error(`Index out of bounds: ${index}`);\n    }\n\n    const newElements = [...this.elements];\n    newElements[index] = elem;\n    return new ArraySeq(newElements);\n  }\n\n  /**\n   * Helper method to create a sequence from an array.\n   */\n  protected fromArray(arr: A[]): Seq<A> {\n    return new ArraySeq(arr);\n  }\n} ","import { Buffer, Seq } from './Seq';\nimport { AbstractSeq } from './AbstractSeq';\nimport { Iterable } from './Iterable';\nimport { ArraySeq } from './ArraySeq';\n\n/**\n * A mutable buffer implementation backed by an array.\n */\nexport class ArrayBuffer<A> extends AbstractSeq<A> implements Buffer<A> {\n  private elements: A[];\n\n  /**\n   * Creates a new ArrayBuffer from the given elements.\n   */\n  constructor(elements: A[] = []) {\n    super();\n    this.elements = [...elements];\n  }\n\n  /**\n   * Creates a new ArrayBuffer from the given elements.\n   */\n  static of<A>(...elements: A[]): ArrayBuffer<A> {\n    return new ArrayBuffer(elements);\n  }\n\n  /**\n   * Creates a new ArrayBuffer from an iterable.\n   */\n  static from<A>(iterable: Iterable<A>): ArrayBuffer<A> {\n    const elements: A[] = [];\n    for (const elem of iterable) {\n      elements.push(elem);\n    }\n    return new ArrayBuffer(elements);\n  }\n\n  /**\n   * Creates an empty ArrayBuffer.\n   */\n  static empty<A>(): ArrayBuffer<A> {\n    return new ArrayBuffer<A>([]);\n  }\n\n  /**\n   * Returns an iterator over the elements of this buffer.\n   */\n  iterator(): Iterator<A> {\n    let index = 0;\n    return {\n      next: () => {\n        if (index < this.elements.length) {\n          return { done: false, value: this.elements[index++] };\n        } else {\n          return { done: true, value: undefined as any };\n        }\n      }\n    };\n  }\n\n  /**\n   * Returns the element at the specified index.\n   */\n  apply(i: number): A {\n    if (i < 0 || i >= this.elements.length) {\n      throw new Error(`Index out of bounds: ${i}`);\n    }\n    return this.elements[i];\n  }\n\n  /**\n   * Updates the element at the given index.\n   */\n  update(index: number, elem: A): void {\n    if (index < 0 || index >= this.elements.length) {\n      throw new Error(`Index out of bounds: ${index}`);\n    }\n    this.elements[index] = elem;\n  }\n\n  /**\n   * Returns the size of this buffer.\n   */\n  size(): number {\n    return this.elements.length;\n  }\n\n  /**\n   * Returns the known size of this buffer.\n   */\n  knownSize(): number {\n    return this.elements.length;\n  }\n\n  /**\n   * Transforms all elements of this buffer in place.\n   */\n  mapInPlace(f: (a: A) => A): this {\n    for (let i = 0; i < this.elements.length; i++) {\n      this.elements[i] = f(this.elements[i]);\n    }\n    return this;\n  }\n\n  /**\n   * Sorts this buffer in place.\n   */\n  sortInPlace(implicit: (a: A, b: A) => number = (a, b) => (a as any) - (b as any)): this {\n    this.elements.sort(implicit);\n    return this;\n  }\n\n  /**\n   * Sorts this buffer in place according to a comparison function.\n   */\n  sortInPlaceWith(lt: (a: A, b: A) => boolean): this {\n    this.elements.sort((a, b) => lt(a, b) ? -1 : lt(b, a) ? 1 : 0);\n    return this;\n  }\n\n  /**\n   * Sorts this buffer in place according to a key function.\n   */\n  sortInPlaceBy<B>(f: (a: A) => B, implicit: (a: B, b: B) => number = (a, b) => (a as any) - (b as any)): this {\n    this.elements.sort((a, b) => implicit(f(a), f(b)));\n    return this;\n  }\n\n  /**\n   * Appends an element to this buffer.\n   */\n  append(elem: A): this {\n    this.elements.push(elem);\n    return this;\n  }\n\n  /**\n   * Appends all elements of a collection to this buffer.\n   */\n  appendAll<B extends A>(xs: Iterable<B>): this {\n    for (const elem of xs) {\n      this.elements.push(elem);\n    }\n    return this;\n  }\n\n  /**\n   * Prepends an element to this buffer.\n   */\n  prepend(elem: A): this {\n    this.elements.unshift(elem);\n    return this;\n  }\n\n  /**\n   * Prepends all elements of a collection to this buffer.\n   */\n  prependAll<B extends A>(xs: Iterable<B>): this {\n    const newElements: A[] = [];\n    for (const elem of xs) {\n      newElements.push(elem);\n    }\n    this.elements = [...newElements, ...this.elements];\n    return this;\n  }\n\n  /**\n   * Inserts an element at a given index.\n   */\n  insert(idx: number, elem: A): this {\n    if (idx < 0 || idx > this.elements.length) {\n      throw new Error(`Index out of bounds: ${idx}`);\n    }\n    this.elements.splice(idx, 0, elem);\n    return this;\n  }\n\n  /**\n   * Inserts elements at a given index.\n   */\n  insertAll<B extends A>(idx: number, xs: Iterable<B>): this {\n    if (idx < 0 || idx > this.elements.length) {\n      throw new Error(`Index out of bounds: ${idx}`);\n    }\n\n    const toInsert: B[] = [];\n    for (const elem of xs) {\n      toInsert.push(elem);\n    }\n\n    this.elements.splice(idx, 0, ...toInsert);\n    return this;\n  }\n\n  /**\n   * Pads this buffer to a given length by appending a value.\n   */\n  padToInPlace(len: number, elem: A): this {\n    while (this.elements.length < len) {\n      this.elements.push(elem);\n    }\n    return this;\n  }\n\n  /**\n   * Removes an element from this buffer.\n   */\n  subtractOne(elem: A): this {\n    const idx = this.elements.findIndex(e => this.equals(e, elem));\n    if (idx >= 0) {\n      this.elements.splice(idx, 1);\n    }\n    return this;\n  }\n\n  /**\n   * Removes all elements in a collection from this buffer.\n   */\n  subtractAll<B extends A>(xs: Iterable<B>): this {\n    for (const elem of xs) {\n      this.subtractOne(elem);\n    }\n    return this;\n  }\n\n  /**\n   * Removes the element at a given index.\n   */\n  remove(idx: number, count: number = 1): A {\n    if (idx < 0 || idx >= this.elements.length) {\n      throw new Error(`Index out of bounds: ${idx}`);\n    }\n\n    const removed = this.elements[idx];\n    this.elements.splice(idx, count);\n    return removed;\n  }\n\n  /**\n   * Removes the first n elements.\n   */\n  trimStart(n: number): this {\n    if (n > 0) {\n      this.elements.splice(0, n);\n    }\n    return this;\n  }\n\n  /**\n   * Removes the last n elements.\n   */\n  trimEnd(n: number): this {\n    if (n > 0) {\n      this.elements.splice(this.elements.length - n, n);\n    }\n    return this;\n  }\n\n  /**\n   * Removes all elements from this buffer.\n   */\n  clear(): this {\n    this.elements = [];\n    return this;\n  }\n\n  /**\n   * Replaces a slice of this buffer with another sequence.\n   */\n  patchInPlace<B extends A>(from: number, patch: Iterable<B>, replaced: number): this {\n    if (from < 0) {\n      throw new Error(`Index out of bounds: ${from}`);\n    }\n\n    const patchElements: B[] = [];\n    for (const elem of patch) {\n      patchElements.push(elem);\n    }\n\n    this.elements.splice(from, replaced, ...patchElements);\n    return this;\n  }\n\n  /**\n   * Returns a new buffer with the same elements as this buffer.\n   */\n  clone(): Buffer<A> {\n    return new ArrayBuffer([...this.elements]);\n  }\n\n  /**\n   * Returns a new sequence with an element prepended.\n   */\n  prepended(elem: A): Seq<A> {\n    return new ArraySeq([elem, ...this.elements]);\n  }\n\n  /**\n   * Returns a new sequence with elements prepended.\n   */\n  prependedAll<B>(prefix: Iterable<B>): Seq<A | B> {\n    const newElements: (A | B)[] = [];\n    for (const elem of prefix) {\n      newElements.push(elem);\n    }\n    newElements.push(...this.elements);\n    return new ArraySeq(newElements);\n  }\n\n  /**\n   * Returns a new sequence with an element appended.\n   */\n  appended(elem: A): Seq<A> {\n    return new ArraySeq([...this.elements, elem]);\n  }\n\n  /**\n   * Returns a new sequence with elements appended.\n   */\n  appendedAll<B>(suffix: Iterable<B>): Seq<A | B> {\n    const newElements = [...this.elements] as (A | B)[];\n    for (const elem of suffix) {\n      newElements.push(elem);\n    }\n    return new ArraySeq(newElements);\n  }\n\n  /**\n   * Returns a new sequence with a slice of another sequence patched in.\n   */\n  patch<B>(from: number, patch: Seq<B>, replaced: number): Seq<A | B> {\n    const before = this.elements.slice(0, from);\n    const middle: B[] = [];\n    for (const elem of patch) {\n      middle.push(elem);\n    }\n    const after = this.elements.slice(from + replaced);\n\n    return new ArraySeq([...before, ...middle, ...after]);\n  }\n\n  /**\n   * Returns a new sequence with one element replaced.\n   */\n  updated(index: number, elem: A): Seq<A> {\n    if (index < 0 || index >= this.elements.length) {\n      throw new Error(`Index out of bounds: ${index}`);\n    }\n\n    const newElements = [...this.elements];\n    newElements[index] = elem;\n    return new ArraySeq(newElements);\n  }\n\n  /**\n   * Helper method to create a sequence from an array.\n   */\n  protected fromArray(arr: A[]): Seq<A> {\n    return new ArraySeq(arr);\n  }\n} ","/**\n * Implementation of Scala-like LazyList, a lazy collection that evaluates elements only when needed.\n * \n * @example\n * ```ts\n * import { LazyList } from '@chris5855/scats';\n * \n * // Creating an infinite stream of numbers\n * const naturals = LazyList.from(0).map(n => n + 1);\n * \n * // Taking only the first 5 elements\n * const firstFive = naturals.take(5).toArray(); // [1, 2, 3, 4, 5]\n * ```\n * @module\n */\n\nimport { Option, Some, None } from '../Option';\n\n/**\n * A state of LazyList that is either empty or contains a head value and a tail LazyList.\n */\ntype State<A> = Empty | Cons<A>;\n\n/**\n * Represents an empty LazyList.\n */\nclass Empty {\n  readonly isEmpty = true;\n}\n\n/**\n * Represents a non-empty LazyList with a head element and a thunk that evaluates to the tail.\n */\nclass Cons<A> {\n  readonly isEmpty = false;\n\n  constructor(\n    readonly head: A,\n    readonly tail: () => LazyList<A>\n  ) { }\n}\n\n/**\n * LazyList is an immutable, lazy evaluated sequence.\n * Elements are evaluated only when needed, making it efficient for representing\n * potentially infinite sequences.\n */\nexport class LazyList<A> {\n  private readonly state: () => State<A>;\n\n  /**\n   * Creates a new LazyList with the given state thunk.\n   */\n  private constructor(state: () => State<A>) {\n    this.state = state;\n  }\n\n  /**\n   * Returns whether this LazyList is empty.\n   */\n  isEmpty(): boolean {\n    return this.state().isEmpty;\n  }\n\n  /**\n   * Returns the first element of this LazyList, or None if it's empty.\n   */\n  headOption(): Option<A> {\n    const s = this.state();\n    return s.isEmpty ? None : Some((s as Cons<A>).head);\n  }\n\n  /**\n   * Returns the first element of this LazyList.\n   * @throws Error if the LazyList is empty\n   */\n  head(): A {\n    const s = this.state();\n    if (s.isEmpty) {\n      throw new Error(\"head of empty LazyList\");\n    }\n    return (s as Cons<A>).head;\n  }\n\n  /**\n   * Returns the tail of this LazyList, or an empty LazyList if it's empty.\n   */\n  tail(): LazyList<A> {\n    const s = this.state();\n    return s.isEmpty ? LazyList.empty<A>() : (s as Cons<A>).tail();\n  }\n\n  /**\n   * Takes the first n elements of this LazyList.\n   */\n  take(n: number): LazyList<A> {\n    if (n <= 0) {\n      return LazyList.empty<A>();\n    }\n\n    return LazyList.suspend(() => {\n      const s = this.state();\n      if (s.isEmpty) {\n        return new Empty();\n      }\n      const cons = s as Cons<A>;\n      return new Cons(cons.head, () => cons.tail().take(n - 1));\n    });\n  }\n\n  /**\n   * Skips the first n elements of this LazyList.\n   */\n  drop(n: number): LazyList<A> {\n    return LazyList.suspend(() => {\n      if (n <= 0) {\n        return this.state();\n      }\n      const s = this.state();\n      if (s.isEmpty) {\n        return new Empty();\n      }\n      return (s as Cons<A>).tail().drop(n - 1).state();\n    });\n  }\n\n  /**\n   * Maps each element of this LazyList using the provided function.\n   */\n  map<B>(f: (a: A) => B): LazyList<B> {\n    return LazyList.suspend(() => {\n      const s = this.state();\n      if (s.isEmpty) {\n        return new Empty();\n      }\n      const cons = s as Cons<A>;\n      return new Cons(f(cons.head), () => cons.tail().map(f));\n    });\n  }\n\n  /**\n   * Applies the given function to each element and concatenates the results.\n   * Uses a safe implementation to prevent stack overflows.\n   */\n  flatMap<B>(f: (a: A) => LazyList<B>): LazyList<B> {\n    // The key insight is to process one level at a time without recursion\n    const flatMapState = (input: LazyList<A>, currentPrefix?: LazyList<B>): State<B> => {\n      // First, handle the case where we're still processing elements from a previous mapping\n      if (currentPrefix && !currentPrefix.isEmpty()) {\n        const prefixState = currentPrefix.state();\n        if (!prefixState.isEmpty) {\n          const prefixCons = prefixState as Cons<B>;\n          return new Cons(\n            prefixCons.head,\n            () => LazyList.suspend(() =>\n              flatMapState(input, prefixCons.tail())\n            )\n          );\n        }\n      }\n\n      // If we've finished the current prefix or don't have one, move to the next input element\n      if (input.isEmpty()) {\n        return new Empty();\n      }\n\n      const inputState = input.state();\n      if (inputState.isEmpty) {\n        return new Empty();\n      }\n\n      const inputCons = inputState as Cons<A>;\n      const mapped = f(inputCons.head);\n\n      if (mapped.isEmpty()) {\n        // If mapping produced an empty result, skip to the next input element\n        return flatMapState(inputCons.tail());\n      } else {\n        // Otherwise process the mapped result\n        return flatMapState(inputCons.tail(), mapped);\n      }\n    };\n\n    return LazyList.suspend(() => flatMapState(this));\n  }\n\n  /**\n   * Filters elements of this LazyList using the provided predicate.\n   * Uses a non-recursive approach to prevent stack overflows.\n   */\n  filter(p: (a: A) => boolean): LazyList<A> {\n    // Create a new filter function that can handle multiple elements at once\n    // to reduce stack pressure\n    const filterElements = (list: LazyList<A>, maxDepth: number = 100): State<A> => {\n      let current = list;\n      let depth = 0;\n\n      // Find the first element that passes the predicate\n      while (!current.isEmpty() && depth < maxDepth) {\n        const s = current.state();\n        if (s.isEmpty) {\n          return new Empty();\n        }\n\n        const cons = s as Cons<A>;\n        if (p(cons.head)) {\n          // Found an element that passes - return it with a safe tail\n          return new Cons(cons.head, () => {\n            // When the tail is accessed, continue filtering from the next element\n            return LazyList.suspend(() => filterElements(cons.tail(), maxDepth));\n          });\n        }\n\n        // This element doesn't match, move to the next one\n        current = cons.tail();\n        depth++;\n      }\n\n      // If we've gone through maxDepth elements without finding a match,\n      // return a continuation to prevent stack overflow\n      if (!current.isEmpty()) {\n        return filterElements(current, maxDepth);\n      }\n\n      return new Empty();\n    };\n\n    return LazyList.suspend(() => filterElements(this));\n  }\n\n  /**\n   * Folds this LazyList from left to right using the provided function.\n   */\n  foldLeft<B>(z: B, f: (b: B, a: A) => B): B {\n    let result = z;\n    let current: LazyList<A> = this;\n\n    while (!current.isEmpty()) {\n      const s = current.state();\n      if (!s.isEmpty) {\n        const cons = s as Cons<A>;\n        result = f(result, cons.head);\n        current = cons.tail();\n      }\n    }\n\n    return result;\n  }\n\n  /**\n   * Converts this LazyList to an array.\n   * This will force the evaluation of all elements.\n   * Limits the maximum number of elements to prevent array length errors.\n   */\n  toArray(): A[] {\n    const MAX_ARRAY_LENGTH = 100000; // Safe maximum array size\n    const result: A[] = [];\n    let current: LazyList<A> = this;\n    let count = 0;\n\n    while (!current.isEmpty() && count < MAX_ARRAY_LENGTH) {\n      const s = current.state();\n      if (!s.isEmpty) {\n        const cons = s as Cons<A>;\n        result.push(cons.head);\n        current = cons.tail();\n        count++;\n      }\n    }\n\n    if (!current.isEmpty()) {\n      console.warn('LazyList.toArray: array length exceeded maximum limit, truncating results');\n    }\n\n    return result;\n  }\n\n  /**\n   * Returns a LazyList consisting of the results of applying\n   * the given function to the elements of this LazyList.\n   */\n  static map<A, B>(la: LazyList<A>, f: (a: A) => B): LazyList<B> {\n    return la.map(f);\n  }\n\n  /**\n   * Creates a LazyList containing the given elements.\n   */\n  static of<A>(...elements: A[]): LazyList<A> {\n    if (elements.length === 0) {\n      return LazyList.empty();\n    }\n\n    // Create a copy of the elements array to avoid mutation issues\n    const elementsCopy = [...elements];\n\n    // Define a recursive function that returns the correct state\n    const createState = (index: number): () => State<A> => {\n      return () => {\n        if (index >= elementsCopy.length) {\n          return new Empty();\n        }\n        return new Cons(\n          elementsCopy[index],\n          () => new LazyList<A>(createState(index + 1))\n        );\n      };\n    };\n\n    return new LazyList<A>(createState(0));\n  }\n\n  /**\n   * Creates an empty LazyList.\n   */\n  static empty<A>(): LazyList<A> {\n    return new LazyList<A>(() => new Empty());\n  }\n\n  /**\n   * Creates a LazyList with the given head and tail.\n   */\n  static cons<A>(head: A, tail: () => LazyList<A>): LazyList<A> {\n    return new LazyList<A>(() => new Cons(head, tail));\n  }\n\n  /**\n   * Suspends a state computation in a thunk.\n   */\n  static suspend<A>(state: () => State<A>): LazyList<A> {\n    return new LazyList<A>(state);\n  }\n\n  /**\n   * Creates a LazyList from an iterable source (array, Set, or other iterable).\n   * If a single value is provided that's not an iterable, a single-element LazyList is returned.\n   * @param iterable A value that can be iterated over, or a single value\n   */\n  static from<A>(iterable: A | A[] | Iterable<A>): LazyList<A> {\n    // Handle single primitive values (like numbers)\n    if (iterable === null || iterable === undefined || (typeof iterable !== 'object' && typeof iterable !== 'function')) {\n      return new LazyList<A>(() => new Cons(iterable as A, () => LazyList.empty()));\n    }\n\n    // Handle array case directly without delegating to of\n    if (Array.isArray(iterable)) {\n      if (iterable.length === 0) {\n        return LazyList.empty<A>();\n      }\n\n      // Create a copy to avoid mutation issues\n      const elementsCopy = [...iterable];\n\n      // Define a recursive function with proper closure over the index\n      const createState = (index: number): () => State<A> => {\n        return () => {\n          if (index >= elementsCopy.length) {\n            return new Empty();\n          }\n          return new Cons(\n            elementsCopy[index],\n            () => new LazyList<A>(createState(index + 1))\n          );\n        };\n      };\n\n      return new LazyList<A>(createState(0));\n    }\n\n    // Handle other iterables\n    try {\n      // Collect values from the iterable\n      const values: A[] = [];\n      for (const value of iterable as Iterable<A>) {\n        values.push(value);\n      }\n\n      if (values.length === 0) {\n        return LazyList.empty<A>();\n      }\n\n      // Create a recursive function with proper closure\n      const createState = (index: number): () => State<A> => {\n        return () => {\n          if (index >= values.length) {\n            return new Empty();\n          }\n          return new Cons(\n            values[index],\n            () => new LazyList<A>(createState(index + 1))\n          );\n        };\n      };\n\n      return new LazyList<A>(createState(0));\n    } catch (e) {\n      // If not iterable, create a single element LazyList\n      return new LazyList<A>(() => new Cons(iterable as A, () => LazyList.empty()));\n    }\n  }\n\n  /**\n   * Creates a range of numbers from start (inclusive) to end (exclusive).\n   * If no end is provided, creates a range from start to MAX_SAFE_RANGE.\n   * @param start The start of the range (inclusive)\n   * @param end The end of the range (exclusive). If undefined, creates a finite range up to MAX_SAFE_RANGE\n   * @param step The step size\n   */\n  static range(start: number, end?: number, step: number = 1): LazyList<number> {\n    // Set a reasonable maximum for \"infinite\" sequences\n    const MAX_SAFE_RANGE = 1000000;\n\n    if (end === undefined) {\n      // Use a large but finite range instead of an infinite range\n      end = start + MAX_SAFE_RANGE;\n    }\n\n    // Finite range from start to end\n    if ((step > 0 && start >= end) || (step < 0 && start <= end)) {\n      return LazyList.empty();\n    }\n\n    return LazyList.suspend(() =>\n      start === end\n        ? new Empty()\n        : new Cons(start, () => LazyList.range(start + step, end, step))\n    );\n  }\n\n  /**\n   * Creates a finite LazyList by repeated application of a function.\n   * @param seed The initial value\n   * @param f The function to apply to generate the next value\n   * @param maxSize Maximum number of elements to generate (default 1000)\n   */\n  static iterate<A>(seed: A, f: (a: A) => A, maxSize: number = 1000): LazyList<A> {\n    // Function to generate the state for iterate\n    const iterate = (current: A, remaining: number): State<A> => {\n      if (remaining <= 0) {\n        return new Empty();\n      }\n      return new Cons(current, () => LazyList.suspend(() => iterate(f(current), remaining - 1)));\n    };\n\n    return LazyList.suspend(() => iterate(seed, maxSize));\n  }\n\n  /**\n   * Creates a finite LazyList that repeatedly applies f.\n   * @param f The function to apply\n   * @param maxSize Maximum number of elements to generate (default 1000)\n   */\n  static continually<A>(f: () => A, maxSize: number = 1000): LazyList<A> {\n    // Function to generate the state for continually\n    const continually = (remaining: number): State<A> => {\n      if (remaining <= 0) {\n        return new Empty();\n      }\n      return new Cons(f(), () => LazyList.suspend(() => continually(remaining - 1)));\n    };\n\n    return LazyList.suspend(() => continually(maxSize));\n  }\n\n  /**\n   * Applies a function to each element to create a new LazyList by iterating.\n   * This is an instance method that allows chaining from a single value LazyList.\n   * @param f The function to apply to generate next values\n   */\n  iterate(f: (a: A) => A): LazyList<A> {\n    if (this.isEmpty()) {\n      return LazyList.empty<A>();\n    }\n\n    // Get the first element as the seed\n    const seed = this.head();\n\n    // Use the static iterate method directly with the seed\n    return LazyList.iterate(seed, f);\n  }\n}\n\n/**\n * Prepends all elements of a LazyList to another LazyList.\n */\nfunction prependAll<A>(prefix: LazyList<A>, list: LazyList<A>): LazyList<A> {\n  if (prefix.isEmpty()) {\n    return list;\n  }\n\n  const head = prefix.head();\n  const tail = prefix.tail();\n  return LazyList.cons(head, () => prependAll(tail, list));\n}\n\n// Default export\nexport default LazyList; ","/**\n * Implementation of Scala-like Vector, an efficient immutable indexed sequence.\n * \n * This is a trie-based implementation with a branching factor of 32, similar to\n * Scala's Vector. It provides efficient random access and updates while\n * maintaining immutability.\n * \n * @example\n * ```ts\n * import { Vector } from 'scats/vector';\n * \n * const vec = Vector.of(1, 2, 3, 4, 5);\n * const doubled = vec.map(x => x * 2);      // Vector(2, 4, 6, 8, 10)\n * const appended = vec.appended(6);          // Vector(1, 2, 3, 4, 5, 6)\n * const updated = vec.updated(2, 10);        // Vector(1, 2, 10, 4, 5)\n * ```\n */\n\nimport { Option, Some, None } from '../Option';\n\n\n/**\n * Vector is an immutable, indexed sequence optimized for fast random access\n * and updates. It provides efficient access to any element and good performance\n * for most operations.\n */\nexport class Vector<A> {\n  /**\n   * Private constructor for creating a Vector from array data.\n   * Use static methods like empty(), of(), from() to create vectors.\n   */\n  private constructor(private readonly data: A[]) { }\n\n  /**\n   * Returns the number of elements in this Vector.\n   */\n  size(): number {\n    return this.data.length;\n  }\n\n  /**\n   * Returns whether this Vector is empty.\n   */\n  isEmpty(): boolean {\n    return this.data.length === 0;\n  }\n\n  /**\n   * Returns the element at the specified index.\n   * @throws {Error} If the index is out of bounds.\n   */\n  apply(index: number): A {\n    if (index < 0 || index >= this.data.length) {\n      throw new Error(`Index out of bounds: ${index}`);\n    }\n    return this.data[index];\n  }\n\n  /**\n   * Returns the element at the specified index, or None if the index is out of bounds.\n   */\n  get(index: number): Option<A> {\n    if (index < 0 || index >= this.data.length) {\n      return None;\n    }\n    return Some(this.data[index]);\n  }\n\n  /**\n   * Returns a new Vector with the element at the specified index updated.\n   * If the index is out of bounds, returns this Vector unchanged.\n   */\n  updated(index: number, elem: A): Vector<A> {\n    if (index < 0 || index >= this.data.length) {\n      return this;\n    }\n    const newData = [...this.data];\n    newData[index] = elem;\n    return new Vector<A>(newData);\n  }\n\n  /**\n   * Returns a new Vector with the specified element appended.\n   */\n  appended(elem: A): Vector<A> {\n    return new Vector<A>([...this.data, elem]);\n  }\n\n  /**\n   * Returns a new Vector with the specified element prepended.\n   */\n  prepended(elem: A): Vector<A> {\n    return new Vector<A>([elem, ...this.data]);\n  }\n\n  /**\n   * Returns a new Vector with all elements of the specified Vector appended.\n   */\n  appendAll<B>(that: Vector<B>): Vector<A | B> {\n    return new Vector<A | B>([...this.data, ...that.data]);\n  }\n\n  /**\n   * Maps each element of this Vector using the provided function.\n   */\n  map<B>(f: (a: A) => B): Vector<B> {\n    return new Vector<B>(this.data.map(f));\n  }\n\n  /**\n   * Applies the given function to each element and concatenates the results.\n   */\n  flatMap<B>(f: (a: A) => Vector<B>): Vector<B> {\n    const result: B[] = [];\n    for (const elem of this.data) {\n      const mapped = f(elem);\n      result.push(...mapped.data);\n    }\n    return new Vector<B>(result);\n  }\n\n  /**\n   * Filters elements of this Vector using the provided predicate.\n   */\n  filter(p: (a: A) => boolean): Vector<A> {\n    return new Vector<A>(this.data.filter(p));\n  }\n\n  /**\n   * Converts this Vector to an array.\n   */\n  toArray(): A[] {\n    return [...this.data];\n  }\n\n  /**\n   * Creates a Vector containing the given elements.\n   */\n  static of<A>(...elements: A[]): Vector<A> {\n    return new Vector<A>([...elements]);\n  }\n\n  /**\n   * Creates an empty Vector.\n   */\n  static empty<A>(): Vector<A> {\n    return new Vector<A>([]);\n  }\n\n  /**\n   * Creates a Vector from an array.\n   */\n  static from<A>(array: A[]): Vector<A> {\n    return new Vector<A>([...array]);\n  }\n}\n\nexport default Vector; ","/**\n * Pattern matching implementation inspired by Scala's match expressions.\n * This module provides a way to match values against patterns and extract parts of them.\n * \n * @example\n * ```ts\n * import { match, when, otherwise } from 'scats';\n * \n * // Simple value matching\n * const result = match(value)\n *   .with(1, () => \"one\")\n *   .with(2, () => \"two\")\n *   .with(3, () => \"three\")\n *   .otherwise(() => \"other\");\n * \n * // Type matching with Option\n * const optRes = match(opt)\n *   .when(Some, (some) => `Value: ${some.get()}`)\n *   .when(None, () => \"No value\")\n *   .run();\n * \n * // Pattern matching with extractors\n * const person = { name: \"John\", age: 30 };\n * const greeting = match(person)\n *   .with({ name: \"John\", age: when((a) => a > 18) }, () => \"Hello Mr. John\")\n *   .with({ name: \"John\" }, () => \"Hello John\")\n *   .otherwise(() => \"Hello stranger\");\n * ```\n */\n\n// Type Utilities\ntype Constructor<T> = new (...args: any[]) => T;\ntype TypePredicate<T> = (value: any) => value is T;\ntype PredicateFunction<T> = (value: T) => boolean;\ntype ExtractorFunction<T, R> = (value: T) => R;\n\n/**\n * Represents a pattern that can be matched against a value\n */\nexport interface Pattern<T, R = T> {\n  match(value: any): { matched: boolean; extracted?: R };\n}\n\n/**\n * Pattern that checks if a value equals the provided value\n */\nclass ValuePattern<T> implements Pattern<T> {\n  constructor(private readonly expected: T) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    return { matched: value === this.expected, extracted: value };\n  }\n}\n\n/**\n * Pattern that checks if a value is an instance of the provided class\n */\nclass TypePattern<T> implements Pattern<T> {\n  constructor(\n    private readonly typeCheck: Constructor<T> | TypePredicate<T>\n  ) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    if (typeof this.typeCheck === 'function' && !isClass(this.typeCheck)) {\n      return { matched: (this.typeCheck as TypePredicate<T>)(value), extracted: value };\n    }\n    return { matched: value instanceof this.typeCheck, extracted: value };\n  }\n}\n\n/**\n * Pattern that checks if a value satisfies the provided predicate\n */\nclass PredicatePattern<T> implements Pattern<T> {\n  constructor(private readonly predicate: PredicateFunction<T>) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    return { matched: this.predicate(value), extracted: value };\n  }\n}\n\n/**\n * Pattern that extracts a value using the provided extractor function\n */\nclass ExtractorPattern<T, R> implements Pattern<T, R> {\n  constructor(private readonly extractor: ExtractorFunction<T, R>) { }\n\n  match(value: any): { matched: boolean; extracted?: R } {\n    try {\n      const extracted = this.extractor(value);\n      return { matched: true, extracted };\n    } catch (e) {\n      return { matched: false };\n    }\n  }\n}\n\n/**\n * Pattern that matches an object with specific properties\n */\nclass ObjectPattern<T extends object> implements Pattern<T> {\n  constructor(private readonly pattern: Partial<{ [K in keyof T]: Pattern<T[K]> | T[K] }>) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    if (value == null || typeof value !== 'object') {\n      return { matched: false };\n    }\n\n    for (const key in this.pattern) {\n      const patternValue = this.pattern[key];\n\n      if (!(key in value)) {\n        return { matched: false };\n      }\n\n      if (isPattern(patternValue)) {\n        const result = (patternValue as Pattern<T[typeof key]>).match(value[key]);\n        if (!result.matched) {\n          return { matched: false };\n        }\n      } else if (patternValue !== value[key]) {\n        return { matched: false };\n      }\n    }\n\n    return { matched: true, extracted: value };\n  }\n}\n\n/**\n * Pattern that matches an array with specific elements\n */\nclass ArrayPattern<T> implements Pattern<T[]> {\n  constructor(private readonly patterns: (Pattern<T> | T)[]) { }\n\n  match(value: any): { matched: boolean; extracted?: T[] } {\n    if (!Array.isArray(value) || value.length !== this.patterns.length) {\n      return { matched: false };\n    }\n\n    for (let i = 0; i < this.patterns.length; i++) {\n      const pattern = this.patterns[i];\n      if (isPattern(pattern)) {\n        const result = (pattern as Pattern<T>).match(value[i]);\n        if (!result.matched) {\n          return { matched: false };\n        }\n      } else if (pattern !== value[i]) {\n        return { matched: false };\n      }\n    }\n\n    return { matched: true, extracted: value };\n  }\n}\n\n/**\n * Pattern that matches if any of the provided patterns match\n */\nclass OrPattern<T> implements Pattern<T> {\n  constructor(private readonly patterns: Pattern<T>[]) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    for (const pattern of this.patterns) {\n      const result = pattern.match(value);\n      if (result.matched) {\n        return result;\n      }\n    }\n    return { matched: false };\n  }\n}\n\n/**\n * Pattern that matches if all of the provided patterns match\n */\nclass AndPattern<T> implements Pattern<T> {\n  constructor(private readonly patterns: Pattern<T>[]) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    for (const pattern of this.patterns) {\n      const result = pattern.match(value);\n      if (!result.matched) {\n        return { matched: false };\n      }\n    }\n    return { matched: true, extracted: value };\n  }\n}\n\n/**\n * Pattern that always matches\n */\nclass WildcardPattern<T> implements Pattern<T> {\n  match(value: any): { matched: boolean; extracted?: T } {\n    return { matched: true, extracted: value };\n  }\n}\n\n/**\n * Pattern that negates another pattern\n */\nclass NotPattern<T> implements Pattern<T> {\n  constructor(private readonly pattern: Pattern<T>) { }\n\n  match(value: any): { matched: boolean; extracted?: T } {\n    const result = this.pattern.match(value);\n    return { matched: !result.matched, extracted: result.matched ? undefined : value };\n  }\n}\n\n/**\n * Represents a match expression\n */\nclass MatchExpression<T, R> {\n  private cases: { pattern: Pattern<T>; handler: (value: any) => R }[] = [];\n  private otherwiseHandler: ((value: T) => R) | null = null;\n\n  constructor(private readonly value: T) { }\n\n  /**\n   * Adds a case with the provided pattern and handler\n   */\n  with<P>(pattern: P | Pattern<T>, handler: (value: P extends Pattern<T, infer X> ? X : T) => R): MatchExpression<T, R> {\n    this.cases.push({\n      pattern: isPattern(pattern) ? pattern as Pattern<T> : pattern as any,\n      handler: handler as any,\n    });\n    return this;\n  }\n\n  /**\n   * Adds a case that matches if the value is of the provided type\n   */\n  when<P>(typeCheck: Constructor<P> | TypePredicate<P>, handler: (value: P) => R): MatchExpression<T, R> {\n    this.cases.push({\n      pattern: new TypePattern(typeCheck) as unknown as Pattern<T>,\n      handler: handler as any,\n    });\n    return this;\n  }\n\n  /**\n   * Adds a default case that matches if no other case matches\n   */\n  otherwise(handler: (value: T) => R): MatchExpression<T, R> {\n    this.otherwiseHandler = handler;\n    return this;\n  }\n\n  /**\n   * Runs the match expression and returns the result\n   */\n  run(): R {\n    for (const { pattern, handler } of this.cases) {\n      const result = isPattern(pattern)\n        ? pattern.match(this.value)\n        : new ValuePattern(pattern).match(this.value);\n\n      if (result.matched) {\n        return handler(result.extracted);\n      }\n    }\n\n    if (this.otherwiseHandler) {\n      return this.otherwiseHandler(this.value);\n    }\n\n    throw new Error(\"Match error: No case matched and no otherwise clause provided\");\n  }\n}\n\n// Utility functions to check if a value is a pattern or a class\nfunction isPattern(value: any): value is Pattern<any> {\n  return value != null && typeof value === 'object' && 'match' in value && typeof value.match === 'function';\n}\n\nfunction isClass(func: any): boolean {\n  return typeof func === 'function' && /^\\s*class\\s+/.test(func.toString());\n}\n\n/**\n * Creates a match expression for the provided value\n */\nexport function match<T, R = any>(value: T): MatchExpression<T, R> {\n  return new MatchExpression<T, R>(value);\n}\n\n/**\n * Creates a pattern that matches if the value satisfies the provided predicate\n */\nexport function when<T>(predicate: PredicateFunction<T>): Pattern<T> {\n  return new PredicatePattern(predicate);\n}\n\n/**\n * Creates a pattern that always matches\n */\nexport function otherwise<T>(): Pattern<T> {\n  return new WildcardPattern<T>();\n}\n\n/**\n * Creates a pattern that extracts a value using the provided extractor function\n */\nexport function extract<T, R>(extractor: ExtractorFunction<T, R>): Pattern<T, R> {\n  return new ExtractorPattern(extractor);\n}\n\n/**\n * Creates a pattern that matches if the value equals the provided value\n */\nexport function value<T>(expected: T): Pattern<T> {\n  return new ValuePattern(expected);\n}\n\n/**\n * Creates a pattern that matches an object with the provided properties\n */\nexport function object<T extends object>(pattern: Partial<{ [K in keyof T]: Pattern<T[K]> | T[K] }>): Pattern<T> {\n  return new ObjectPattern(pattern);\n}\n\n/**\n * Creates a pattern that matches an array with the provided elements\n */\nexport function array<T>(patterns: (Pattern<T> | T)[]): Pattern<T[]> {\n  return new ArrayPattern(patterns);\n}\n\n/**\n * Creates a pattern that matches if any of the provided patterns match\n */\nexport function or<T>(...patterns: Pattern<T>[]): Pattern<T> {\n  return new OrPattern(patterns);\n}\n\n/**\n * Creates a pattern that matches if all of the provided patterns match\n */\nexport function and<T>(...patterns: Pattern<T>[]): Pattern<T> {\n  return new AndPattern(patterns);\n}\n\n/**\n * Creates a pattern that matches if the provided pattern does not match\n */\nexport function not<T>(pattern: Pattern<T>): Pattern<T> {\n  return new NotPattern(pattern);\n}\n\n/**\n * Creates a pattern that matches if the value is of the provided type\n */\nexport function type<T>(typeCheck: Constructor<T> | TypePredicate<T>): Pattern<T> {\n  return new TypePattern(typeCheck);\n} ","/**\n * For-comprehension implementation inspired by Scala's for expressions.\n * This module provides a way to sequence monadic operations in a readable way,\n * similar to how `async/await` works for Promises, but for any monad.\n * \n * @example\n * ```ts\n * import { For, Some, None, Option, List } from 'scats';\n * \n * // Using for-comprehension with Options\n * const result = For.of<Option<number>>()\n *   .bind('a', () => Some(1))\n *   .bind('b', ({ a }) => Some(a + 1))\n *   .bind('c', ({ a, b }) => Some(a + b))\n *   .yield(({ a, b, c }) => a + b + c);  // Some(6)\n * \n * // Early return if any step returns None\n * const noResult = For.of<Option<number>>()\n *   .bind('a', () => Some(1))\n *   .bind('b', ({ a }) => None)\n *   .bind('c', ({ a, b }) => Some(a + b))\n *   .yield(({ a, b, c }) => a + b + c);  // None\n * \n * // Using for-comprehension with Lists\n * const cartesianProduct = For.of<List<[number, string]>>()\n *   .bind('a', () => List.of(1, 2, 3))\n *   .bind('b', () => List.of('x', 'y'))\n *   .yield(({ a, b }) => [a, b] as [number, string]);  // List([1, 'x'], [1, 'y'], [2, 'x'], [2, 'y'], [3, 'x'], [3, 'y'])\n * ```\n */\n\nimport { Option, Some, None } from './Option';\nimport { List, empty as emptyList } from './List';\nimport { Try, Success } from './Try';\nimport { Either, Right } from './Either';\n\n/**\n * An interface that represents monads with map and flatMap operations\n */\nexport interface Monad<A> {\n  map<B>(f: (a: A) => B): Monad<B>;\n  flatMap<B>(f: (a: A) => Monad<B>): Monad<B>;\n}\n\n/**\n * Type for the environment object in for-comprehension\n */\nexport type Env = Record<string, any>;\n\n/**\n * A monadic context that accumulates bindings for for-comprehension\n */\nexport class ForComprehension<M, T extends Env = {}> {\n  constructor(\n    private readonly pure: <A>(a: A) => M,\n    private readonly flatMap: <A>(ma: M, f: (a: A) => M) => M,\n    private readonly value: M = pure({} as T)\n  ) { }\n\n  /**\n   * Binds a new value to the given name in the environment\n   */\n  bind<K extends string, A>(name: K, f: (env: T) => M): ForComprehension<M, T & Record<K, A>> {\n    return new ForComprehension<M, T & Record<K, A>>(\n      this.pure,\n      this.flatMap,\n      this.flatMap(this.value, (env: T) =>\n        this.flatMap(f(env), (a: A) =>\n          this.pure({ ...env, [name]: a })\n        )\n      )\n    );\n  }\n\n  /**\n   * Adds a filter condition to the for-comprehension\n   */\n  filter(predicate: (env: T) => boolean): ForComprehension<M, T> {\n    return new ForComprehension<M, T>(\n      this.pure,\n      this.flatMap,\n      this.flatMap(this.value, (env: T) =>\n        predicate(env) ? this.pure(env) : this.empty()\n      )\n    );\n  }\n\n  /**\n   * Yields a final result from the for-comprehension\n   */\n  yield<R>(f: (env: T) => R): M {\n    return this.flatMap(this.value, (env: T) => this.pure(f(env)));\n  }\n\n  /**\n   * Returns an empty value for the given monad\n   */\n  private empty(): M {\n    // This is a simplification. In a full implementation, this would \n    // depend on the monad type. Here we just return a default \"zero\" element.\n    if (this.isOptionMonad()) {\n      return None as unknown as M;\n    } else if (this.isListMonad()) {\n      return emptyList() as unknown as M;\n    } else {\n      // For other monads, we don't have a way to provide an empty value\n      throw new Error(\"Filter operation not supported for this monad type\");\n    }\n  }\n\n  /**\n   * Checks if the monad is an Option\n   */\n  private isOptionMonad(): boolean {\n    return this.pure(42) instanceof Object && (this.pure(42) as any).isSome !== undefined;\n  }\n\n  /**\n   * Checks if the monad is a List\n   */\n  private isListMonad(): boolean {\n    return this.pure(42) instanceof Object && (this.pure(42) as any).isEmpty !== undefined;\n  }\n}\n\n/**\n * Factory for creating for-comprehensions for different monads\n */\nexport namespace For {\n  /**\n   * Creates a for-comprehension for Option\n   */\n  export function option<T extends Env = {}>(): ForComprehension<Option<any>, T> {\n    return new ForComprehension<Option<any>, T>(\n      <A>(a: A) => Some(a),\n      <A, B>(ma: Option<A>, f: (a: A) => Option<B>) => ma.flatMap(f)\n    );\n  }\n\n  /**\n   * Creates a for-comprehension for Either\n   */\n  export function either<E, T extends Env = {}>(): ForComprehension<Either<E, any>, T> {\n    return new ForComprehension<Either<E, any>, T>(\n      <A>(a: A) => Right<A, E>(a),\n      <A, B>(ma: Either<E, A>, f: (a: A) => Either<E, B>) => ma.flatMap(f)\n    );\n  }\n\n  /**\n   * Creates a for-comprehension for List\n   */\n  export function list<T extends Env = {}>(): ForComprehension<List<any>, T> {\n    return new ForComprehension<List<any>, T>(\n      <A>(a: A) => List.of(a),\n      <A, B>(ma: List<A>, f: (a: A) => List<B>) => ma.flatMap(f)\n    );\n  }\n\n  /**\n   * Creates a for-comprehension for Try\n   */\n  export function tryM<T extends Env = {}>(): ForComprehension<Try<any>, T> {\n    return new ForComprehension<Try<any>, T>(\n      <A>(a: A) => Success(a),\n      <A, B>(ma: Try<A>, f: (a: A) => Try<B>) => ma.flatMap(f)\n    );\n  }\n\n  /**\n   * Creates a generic for-comprehension for any monad\n   */\n  export function of<M, T extends Env = {}>(): ForComprehensionBuilder<M, T> {\n    return new ForComprehensionBuilder<M, T>();\n  }\n}\n\n/**\n * Builder for creating for-comprehensions\n */\nexport class ForComprehensionBuilder<M, T extends Env = {}> {\n  /**\n   * Creates a for-comprehension for Option\n   */\n  option(): ForComprehension<Option<any>, T> {\n    return For.option<T>();\n  }\n\n  /**\n   * Creates a for-comprehension for Either\n   */\n  either<E>(): ForComprehension<Either<E, any>, T> {\n    return For.either<E, T>();\n  }\n\n  /**\n   * Creates a for-comprehension for List\n   */\n  list(): ForComprehension<List<any>, T> {\n    return For.list<T>();\n  }\n\n  /**\n   * Creates a for-comprehension for Try\n   */\n  tryM(): ForComprehension<Try<any>, T> {\n    return For.tryM<T>();\n  }\n\n  /**\n   * Creates a for-comprehension for a custom monad\n   */\n  custom(\n    pure: <X>(b: X) => M,\n    flatMap: <X>(mb: M, f: (b: X) => M) => M\n  ): ForComprehension<M, T> {\n    return new ForComprehension<M, T>(pure, flatMap);\n  }\n} ","/**\n * Type class implementation that provides a way to add functionality to existing types.\n * This module enables ad-hoc polymorphism and interface extension through a pattern\n * similar to Scala's implicits and type classes.\n * \n * @example\n * ```ts\n * import { TypeClass, TypeClassRegistry } from 'scats';\n * \n * // Define a type class\n * interface Numeric<T> {\n *   add(a: T, b: T): T;\n *   zero(): T;\n *   fromNumber(n: number): T;\n * }\n * \n * // Create a registry for the Numeric type class\n * const NumericRegistry = new TypeClassRegistry<Numeric<any>>();\n * \n * // Register an instance for the number type\n * NumericRegistry.register<number>({\n *   add: (a, b) => a + b,\n *   zero: () => 0,\n *   fromNumber: n => n\n * });\n * \n * // Register an instance for the string type\n * NumericRegistry.register<string>({\n *   add: (a, b) => a + b,\n *   zero: () => \"\",\n *   fromNumber: n => n.toString()\n * });\n * \n * // Use the type class\n * function sum<T>(values: T[], numeric: Numeric<T>): T {\n *   return values.reduce((acc, val) => numeric.add(acc, val), numeric.zero());\n * }\n * \n * // Automatically resolving type class instances\n * function sumWith<T>(values: T[]): T {\n *   const numeric = NumericRegistry.get<T>();\n *   return sum(values, numeric);\n * }\n * ```\n */\n\n/**\n * Base interface for type classes\n */\nexport interface TypeClass<T> {\n  // This interface serves as a marker for type classes that work with type T\n  // Using nominal typing to force the use of the type parameter\n  readonly __type?: T;\n}\n\n/**\n * Registry for type class instances\n */\nexport class TypeClassRegistry<TC extends TypeClass<any>> {\n  private readonly instances = new Map<any, TC>();\n\n  /**\n   * Registers a type class instance for a specific type\n   */\n  register<T>(instance: TC & TypeClass<T>, type?: { new(...args: any[]): T }): void {\n    const key = type || this.typeKey(instance);\n    this.instances.set(key, instance);\n  }\n\n  /**\n   * Gets a type class instance for a specific type\n   * @throws Error if no instance is found\n   */\n  get<T>(): TC & TypeClass<T> {\n    // In a real implementation, this would do more sophisticated type resolution\n    // based on compile-time type information or runtime checks.\n    // TypeScript doesn't provide a way to get a type at runtime, so this is a limitation.\n    throw new Error(\"Type class instance not found. Use getFor instead.\");\n  }\n\n  /**\n   * Gets a type class instance for a specific value\n   * @throws Error if no instance is found\n   */\n  getFor<T>(value: T): TC & TypeClass<T> {\n    const constructor = (value as any)?.constructor;\n    if (constructor && this.instances.has(constructor)) {\n      return this.instances.get(constructor) as TC & TypeClass<T>;\n    }\n\n    for (const [key, instance] of this.instances.entries()) {\n      if (this.isInstanceOf(value, key)) {\n        return instance as TC & TypeClass<T>;\n      }\n    }\n\n    throw new Error(`Type class instance not found for ${value}`);\n  }\n\n  /**\n   * Checks if an instance exists for a specific type\n   */\n  has<T>(type: { new(...args: any[]): T }): boolean {\n    return this.instances.has(type);\n  }\n\n  /**\n   * Checks if an instance exists for a specific value\n   */\n  hasFor<T>(value: T): boolean {\n    const constructor = (value as any)?.constructor;\n    if (constructor && this.instances.has(constructor)) {\n      return true;\n    }\n\n    for (const key of this.instances.keys()) {\n      if (this.isInstanceOf(value, key)) {\n        return true;\n      }\n    }\n\n    return false;\n  }\n\n  /**\n   * Gets a type key for a type class instance\n   */\n  private typeKey<T>(instance: TC & TypeClass<T>): any {\n    // This is a limitation in TypeScript - we can't get the real type\n    // Instead, we use the instance itself as a key\n    return instance;\n  }\n\n  /**\n   * Checks if a value is an instance of a type\n   */\n  private isInstanceOf(value: any, type: any): boolean {\n    // Handle primitive types\n    if (typeof value === 'number' && type === Number) return true;\n    if (typeof value === 'string' && type === String) return true;\n    if (typeof value === 'boolean' && type === Boolean) return true;\n\n    // Handle class instances\n    if (typeof type === 'function') {\n      return value instanceof type;\n    }\n\n    return false;\n  }\n}\n\n/**\n * Decorator for registering type class instances\n */\nexport function register<TC extends TypeClass<any>>(registry: TypeClassRegistry<TC>) {\n  return function <T extends TC>(target: T): void {\n    registry.register(target);\n  };\n}\n\n/**\n * Extension method factory for type classes\n */\nexport function extension<T, TC extends TypeClass<T>>(\n  registry: TypeClassRegistry<TC>,\n  getForValue: (value: any) => T\n) {\n  return function <K extends keyof TC>(methodName: K): (...args: any[]) => any {\n    return function (this: any, ...args: any[]): any {\n      const instance = registry.getFor<T>(this);\n      const value = getForValue(this);\n      return (instance[methodName] as any)(value, ...args);\n    };\n  };\n}\n\n/**\n * Context bound implementation that allows using type classes with a specific type\n */\nexport function withContext<T, TC extends TypeClass<T>>(\n  registry: TypeClassRegistry<TC>,\n  action: (instance: TC) => void\n): void {\n  const instance = registry.get<T>();\n  action(instance);\n}\n\n/**\n * A registry for all type classes\n */\nexport const GlobalTypeClassRegistry = new TypeClassRegistry<TypeClass<any>>(); ","/**\n * Implementation of Scala-like Tuples\n * \n * @example\n * ```ts\n * import { Tuple, Tuple2 } from 'scats/tuple';\n * \n * const pair = Tuple.of(1, \"hello\");\n * const first = pair._1;  // 1\n * const swapped = pair.swap();  // Tuple2(\"hello\", 1)\n * \n * // Destructuring\n * const [num, str] = pair;\n * \n * // Creating a tuple of 3 elements\n * const triple = Tuple.of(1, \"hello\", true);\n * ```\n */\n\n/**\n * Tuple2 represents an ordered pair of values.\n */\nexport class Tuple2<T1, T2> implements Iterable<T1 | T2> {\n  /**\n   * Creates a new Tuple2 with the given values.\n   */\n  constructor(\n    readonly _1: T1,\n    readonly _2: T2\n  ) { }\n\n  /**\n   * Returns a new Tuple2 with the elements swapped.\n   */\n  swap(): Tuple2<T2, T1> {\n    return new Tuple2(this._2, this._1);\n  }\n\n  /**\n   * Maps the first element of this Tuple2 using the provided function.\n   */\n  map1<U>(f: (value: T1) => U): Tuple2<U, T2> {\n    return new Tuple2(f(this._1), this._2);\n  }\n\n  /**\n   * Maps the second element of this Tuple2 using the provided function.\n   */\n  map2<U>(f: (value: T2) => U): Tuple2<T1, U> {\n    return new Tuple2(this._1, f(this._2));\n  }\n\n  /**\n   * Maps both elements of this Tuple2 using the provided functions.\n   */\n  bimap<U1, U2>(f1: (value: T1) => U1, f2: (value: T2) => U2): Tuple2<U1, U2> {\n    return new Tuple2(f1(this._1), f2(this._2));\n  }\n\n  /**\n   * Converts this Tuple2 to an array.\n   */\n  toArray(): [T1, T2] {\n    return [this._1, this._2];\n  }\n\n  /**\n   * Returns a string representation of this Tuple2.\n   */\n  toString(): string {\n    return `(${this._1}, ${this._2})`;\n  }\n\n  /**\n   * Returns an iterator over the elements of this Tuple2.\n   */\n  [Symbol.iterator](): Iterator<T1 | T2> {\n    let index = 0;\n    const tuple = this;\n\n    return {\n      next(): IteratorResult<T1 | T2> {\n        if (index === 0) {\n          index++;\n          return { value: tuple._1, done: false };\n        } else if (index === 1) {\n          index++;\n          return { value: tuple._2, done: false };\n        } else {\n          return { value: undefined, done: true };\n        }\n      }\n    };\n  }\n}\n\n/**\n * Tuple3 represents an ordered triplet of values.\n */\nexport class Tuple3<T1, T2, T3> implements Iterable<T1 | T2 | T3> {\n  /**\n   * Creates a new Tuple3 with the given values.\n   */\n  constructor(\n    readonly _1: T1,\n    readonly _2: T2,\n    readonly _3: T3\n  ) { }\n\n  /**\n   * Maps the first element of this Tuple3 using the provided function.\n   */\n  map1<U>(f: (value: T1) => U): Tuple3<U, T2, T3> {\n    return new Tuple3(f(this._1), this._2, this._3);\n  }\n\n  /**\n   * Maps the second element of this Tuple3 using the provided function.\n   */\n  map2<U>(f: (value: T2) => U): Tuple3<T1, U, T3> {\n    return new Tuple3(this._1, f(this._2), this._3);\n  }\n\n  /**\n   * Maps the third element of this Tuple3 using the provided function.\n   */\n  map3<U>(f: (value: T3) => U): Tuple3<T1, T2, U> {\n    return new Tuple3(this._1, this._2, f(this._3));\n  }\n\n  /**\n   * Maps all elements of this Tuple3 using the provided functions.\n   */\n  map<U1, U2, U3>(f1: (value: T1) => U1, f2: (value: T2) => U2, f3: (value: T3) => U3): Tuple3<U1, U2, U3> {\n    return new Tuple3(f1(this._1), f2(this._2), f3(this._3));\n  }\n\n  /**\n   * Converts this Tuple3 to a Tuple2 by removing the third element.\n   */\n  toTuple2(): Tuple2<T1, T2> {\n    return new Tuple2(this._1, this._2);\n  }\n\n  /**\n   * Converts this Tuple3 to an array.\n   */\n  toArray(): [T1, T2, T3] {\n    return [this._1, this._2, this._3];\n  }\n\n  /**\n   * Returns a string representation of this Tuple3.\n   */\n  toString(): string {\n    return `(${this._1}, ${this._2}, ${this._3})`;\n  }\n\n  /**\n   * Returns an iterator over the elements of this Tuple3.\n   */\n  [Symbol.iterator](): Iterator<T1 | T2 | T3> {\n    let index = 0;\n    const tuple = this;\n\n    return {\n      next(): IteratorResult<T1 | T2 | T3> {\n        if (index === 0) {\n          index++;\n          return { value: tuple._1, done: false };\n        } else if (index === 1) {\n          index++;\n          return { value: tuple._2, done: false };\n        } else if (index === 2) {\n          index++;\n          return { value: tuple._3, done: false };\n        } else {\n          return { value: undefined, done: true };\n        }\n      }\n    };\n  }\n}\n\n/**\n * Tuple namespace containing utility functions for creating tuples.\n */\nexport const Tuple = {\n  /**\n   * Creates a tuple from the given values.\n   */\n  of(...values: any[]): any {\n    if (values.length === 2) {\n      return new Tuple2(values[0], values[1]);\n    } else if (values.length === 3) {\n      return new Tuple3(values[0], values[1], values[2]);\n    } else {\n      throw new Error(`Unsupported number of arguments: ${values.length}`);\n    }\n  },\n\n  /**\n   * Creates a Tuple2 from an array with two elements.\n   */\n  fromArray2<T1, T2>(array: [T1, T2]): Tuple2<T1, T2> {\n    return new Tuple2(array[0], array[1]);\n  },\n\n  /**\n   * Creates a Tuple3 from an array with three elements.\n   */\n  fromArray3<T1, T2, T3>(array: [T1, T2, T3]): Tuple3<T1, T2, T3> {\n    return new Tuple3(array[0], array[1], array[2]);\n  },\n\n  /**\n   * Creates a Tuple2 from an entry (key-value pair).\n   */\n  fromEntry<K, V>(entry: [K, V]): Tuple2<K, V> {\n    return this.fromArray2(entry);\n  }\n};\n\n// Default export\nexport default Tuple; ","/**\n * Implementation of Scala-like Ordering type class for comparison operations.\n * \n * @example\n * ```ts\n * import { Ordering } from 'scats/ordering';\n * \n * // Using built-in orderings\n * const numbers = [3, 1, 4, 1, 5, 9];\n * const sorted = numbers.sort(Ordering.number.compare);\n * \n * // Creating a custom ordering\n * const personOrdering = Ordering.by<Person, string>(p => p.name);\n * const sortedPeople = people.sort(personOrdering.compare);\n * \n * // Reverse ordering\n * const descendingOrder = Ordering.number.reverse();\n * const sortedDesc = numbers.sort(descendingOrder.compare);\n * ```\n */\n\n/**\n * Ordering is a type class for objects that can be compared.\n */\nexport interface Ordering<T> {\n  /**\n   * Compares two values.\n   * \n   * Returns a negative number if x < y, zero if x = y, and a positive number if x > y.\n   */\n  compare(x: T, y: T): number;\n\n  /**\n   * Returns true if x < y.\n   */\n  lt(x: T, y: T): boolean;\n\n  /**\n   * Returns true if x <= y.\n   */\n  lte(x: T, y: T): boolean;\n\n  /**\n   * Returns true if x > y.\n   */\n  gt(x: T, y: T): boolean;\n\n  /**\n   * Returns true if x >= y.\n   */\n  gte(x: T, y: T): boolean;\n\n  /**\n   * Returns true if x = y.\n   */\n  equals(x: T, y: T): boolean;\n\n  /**\n   * Returns the minimum of two values.\n   */\n  min(x: T, y: T): T;\n\n  /**\n   * Returns the maximum of two values.\n   */\n  max(x: T, y: T): T;\n\n  /**\n   * Returns a new Ordering that compares in the reverse order.\n   */\n  reverse(): Ordering<T>;\n\n  /**\n   * Returns a new Ordering that first compares using this ordering, and if that\n   * comparison is zero, then compares using the given ordering.\n   */\n  andThen<U extends T>(that: Ordering<U>): Ordering<U>;\n}\n\n/**\n * Abstract base class for implementing the Ordering interface.\n */\nabstract class AbstractOrdering<T> implements Ordering<T> {\n  abstract compare(x: T, y: T): number;\n\n  lt(x: T, y: T): boolean {\n    return this.compare(x, y) < 0;\n  }\n\n  lte(x: T, y: T): boolean {\n    return this.compare(x, y) <= 0;\n  }\n\n  gt(x: T, y: T): boolean {\n    return this.compare(x, y) > 0;\n  }\n\n  gte(x: T, y: T): boolean {\n    return this.compare(x, y) >= 0;\n  }\n\n  equals(x: T, y: T): boolean {\n    return this.compare(x, y) === 0;\n  }\n\n  min(x: T, y: T): T {\n    return this.lte(x, y) ? x : y;\n  }\n\n  max(x: T, y: T): T {\n    return this.gte(x, y) ? x : y;\n  }\n\n  reverse(): Ordering<T> {\n    const self = this;\n    return new class extends AbstractOrdering<T> {\n      compare(x: T, y: T): number {\n        return self.compare(y, x);\n      }\n    };\n  }\n\n  andThen<U extends T>(that: Ordering<U>): Ordering<U> {\n    const self = this;\n    return new class extends AbstractOrdering<U> {\n      compare(x: U, y: U): number {\n        const result = self.compare(x, y);\n        return result !== 0 ? result : that.compare(x, y);\n      }\n    };\n  }\n}\n\n/**\n * Ordering instance for numbers.\n */\nclass NumberOrdering extends AbstractOrdering<number> {\n  compare(x: number, y: number): number {\n    return x - y;\n  }\n}\n\n/**\n * Ordering instance for strings.\n */\nclass StringOrdering extends AbstractOrdering<string> {\n  compare(x: string, y: string): number {\n    return x.localeCompare(y);\n  }\n}\n\n/**\n * Ordering instance for booleans.\n */\nclass BooleanOrdering extends AbstractOrdering<boolean> {\n  compare(x: boolean, y: boolean): number {\n    return Number(x) - Number(y);\n  }\n}\n\n/**\n * Ordering instance for dates.\n */\nclass DateOrdering extends AbstractOrdering<Date> {\n  compare(x: Date, y: Date): number {\n    return x.getTime() - y.getTime();\n  }\n}\n\n/**\n * Creates an ordering by mapping the values to a type with a defined ordering.\n */\nclass MappedOrdering<T, U> extends AbstractOrdering<T> {\n  constructor(\n    private readonly ordering: Ordering<U>,\n    private readonly f: (t: T) => U\n  ) {\n    super();\n  }\n\n  compare(x: T, y: T): number {\n    return this.ordering.compare(this.f(x), this.f(y));\n  }\n}\n\n/**\n * Ordering namespace containing utility functions and predefined orderings.\n */\nexport const Ordering = {\n  /**\n   * Ordering for numbers.\n   */\n  number: new NumberOrdering(),\n\n  /**\n   * Ordering for strings.\n   */\n  string: new StringOrdering(),\n\n  /**\n   * Ordering for booleans.\n   */\n  boolean: new BooleanOrdering(),\n\n  /**\n   * Ordering for dates.\n   */\n  date: new DateOrdering(),\n\n  /**\n   * Creates a new Ordering by mapping the values to a type with a defined ordering.\n   */\n  by<T, U>(f: (t: T) => U, ordering?: Ordering<U>): Ordering<T> {\n    const ord = ordering || Ordering.natural<U>();\n    return new MappedOrdering<T, U>(ord, f);\n  },\n\n  /**\n   * Creates a natural ordering for the given type.\n   * \n   * This assumes the type has a natural ordering (e.g., numbers, strings, dates).\n   */\n  natural<T>(): Ordering<T> {\n    return new class extends AbstractOrdering<T> {\n      compare(x: T, y: T): number {\n        if (typeof x === 'number' && typeof y === 'number') {\n          return x - y;\n        } else if (typeof x === 'string' && typeof y === 'string') {\n          return x.localeCompare(y);\n        } else if (x instanceof Date && y instanceof Date) {\n          return x.getTime() - y.getTime();\n        } else if (typeof x === 'boolean' && typeof y === 'boolean') {\n          return Number(x) - Number(y);\n        } else {\n          const valueX = String(x);\n          const valueY = String(y);\n          return valueX.localeCompare(valueY);\n        }\n      }\n    };\n  }\n};\n\n// Default export\nexport default Ordering; ","/**\n * Implementation of Scala-like resource management utilities (Using/Auto-Closeable).\n * \n * @example\n * ```ts\n * import { Using } from 'scats/using';\n * \n * // Create a resource that needs to be closed\n * class Resource implements Closeable {\n *   constructor(readonly id: string) {\n *     console.log(`Resource ${id} created`);\n *   }\n *   \n *   getData(): string {\n *     return `Data from resource ${this.id}`;\n *   }\n *   \n *   close(): void {\n *     console.log(`Resource ${this.id} closed`);\n *   }\n * }\n * \n * // Use the resource and ensure it gets closed\n * const result = Using.resource(new Resource(\"123\"), (resource) => {\n *   return resource.getData().toUpperCase();\n * });\n * \n * // Use multiple resources\n * const result2 = Using.resources(\n *   [new Resource(\"A\"), new Resource(\"B\")],\n *   ([resourceA, resourceB]) => {\n *     return resourceA.getData() + \" + \" + resourceB.getData();\n *   }\n * );\n * ```\n */\n\nimport { Option, Some, None } from '../Option';\nimport { Try, Success, Failure } from '../Try';\n\n/**\n * Interface for resources that can be closed or released.\n */\nexport interface Closeable {\n  /**\n   * Closes or releases the resource.\n   */\n  close(): void;\n}\n\n/**\n * Using is a utility class for working with resources that need\n * to be closed or released after use, like files or database connections.\n */\nexport const Using = {\n  /**\n   * Use a resource and ensure it is closed, even if an exception occurs.\n   * \n   * @param resource The resource to use\n   * @param f The function to apply to the resource\n   * @returns The result of applying f to the resource\n   */\n  resource<R extends Closeable, A>(resource: R, f: (r: R) => A): Try<A> {\n    try {\n      const result = f(resource);\n      return Success(result);\n    } catch (e) {\n      return Failure(e instanceof Error ? e : new Error(String(e)));\n    } finally {\n      try {\n        resource.close();\n      } catch (e) {\n        console.error(\"Error closing resource:\", e);\n      }\n    }\n  },\n\n  /**\n   * Use multiple resources and ensure they are all closed, even if an exception occurs.\n   * \n   * @param resources The resources to use\n   * @param f The function to apply to the resources\n   * @returns The result of applying f to the resources\n   */\n  resources<R extends Closeable, A>(resources: R[], f: (rs: R[]) => A): Try<A> {\n    try {\n      const result = f(resources);\n      return Success(result);\n    } catch (e) {\n      return Failure(e instanceof Error ? e : new Error(String(e)));\n    } finally {\n      // Close resources in reverse order (last opened first closed)\n      for (let i = resources.length - 1; i >= 0; i--) {\n        try {\n          resources[i].close();\n        } catch (e) {\n          console.error(`Error closing resource at index ${i}:`, e);\n        }\n      }\n    }\n  },\n\n  /**\n   * Use a resource asynchronously and ensure it is closed, even if an exception occurs.\n   * \n   * @param resource The resource to use\n   * @param f The function to apply to the resource\n   * @returns A promise that resolves to the result of applying f to the resource\n   */\n  async resourceAsync<R extends Closeable, A>(resource: R, f: (r: R) => Promise<A>): Promise<A> {\n    try {\n      return await f(resource);\n    } finally {\n      try {\n        resource.close();\n      } catch (e) {\n        console.error(\"Error closing resource:\", e);\n      }\n    }\n  },\n\n  /**\n   * Use multiple resources asynchronously and ensure they are all closed, even if an exception occurs.\n   * \n   * @param resources The resources to use\n   * @param f The function to apply to the resources\n   * @returns A promise that resolves to the result of applying f to the resources\n   */\n  async resourcesAsync<R extends Closeable, A>(resources: R[], f: (rs: R[]) => Promise<A>): Promise<A> {\n    try {\n      return await f(resources);\n    } finally {\n      // Close resources in reverse order (last opened first closed)\n      for (let i = resources.length - 1; i >= 0; i--) {\n        try {\n          resources[i].close();\n        } catch (e) {\n          console.error(`Error closing resource at index ${i}:`, e);\n        }\n      }\n    }\n  },\n\n  /**\n   * Creates a resource manager that can be used with a 'with' pattern.\n   * \n   * @param acquire Function to acquire the resource\n   * @param release Function to release the resource\n   * @returns A resource manager\n   */\n  manager<R, A>(acquire: () => R, release: (r: R) => void): {\n    use: <A>(f: (r: R) => A) => A;\n    useAsync: <A>(f: (r: R) => Promise<A>) => Promise<A>;\n  } {\n    return {\n      use<A>(f: (r: R) => A): A {\n        const resource = acquire();\n        try {\n          return f(resource);\n        } finally {\n          release(resource);\n        }\n      },\n\n      async useAsync<A>(f: (r: R) => Promise<A>): Promise<A> {\n        const resource = acquire();\n        try {\n          return await f(resource);\n        } finally {\n          release(resource);\n        }\n      }\n    };\n  }\n};\n\n// Default export\nexport default Using; ","/**\n * Implementation of the State monad for functional state management.\n * \n * @example\n * ```ts\n * import { State } from 'scats/monads/state';\n * \n * // Define a state type\n * type GameState = {\n *   score: number;\n *   level: number;\n * };\n * \n * // Create operations on the state\n * const incrementScore = (points: number) => State.modify<GameState>(state => ({\n *   ...state,\n *   score: state.score + points\n * }));\n * \n * const levelUp = State.modify<GameState>(state => ({\n *   ...state,\n *   level: state.level + 1\n * }));\n * \n * const getScore = State.gets<GameState, number>(state => state.score);\n * \n * // Combine operations\n * const playGame = State.sequence([\n *   incrementScore(100),\n *   incrementScore(50),\n *   levelUp,\n *   getScore\n * ]);\n * \n * // Run the state computation\n * const initialState: GameState = { score: 0, level: 1 };\n * const [finalScore, finalState] = playGame.run(initialState);\n * \n * console.log(finalScore);   // 150\n * console.log(finalState);   // { score: 150, level: 2 }\n * ```\n */\n\n/**\n * The State monad represents a computation that can read and write a state value.\n * \n * Example:\n * ```\n * // Define a game state\n * interface GameState {\n *   score: number;\n *   level: number;\n * }\n * \n * // Create state operations\n * const incrementScore = (points: number) => \n *   State.modify<GameState>(state => ({...state, score: state.score + points}));\n * \n * const levelUp = State.modify<GameState>(state => ({...state, level: state.level + 1}));\n * \n * // Combine operations\n * const winLevel = (points: number) => \n *   incrementScore(points).flatMap(() => levelUp);\n * \n * // Run the computation\n * const initialState: GameState = { score: 0, level: 1 };\n * const [_, newState] = winLevel(100).run(initialState);\n * // newState is { score: 100, level: 2 }\n * ```\n */\n\n// Class definition\nexport class StateMonad<S, A> {\n  /**\n   * Creates a new State.\n   */\n  constructor(readonly runState: (s: S) => [A, S]) { }\n\n  /**\n   * Runs this state computation with the given initial state.\n   */\n  run(initialState: S): [A, S] {\n    return this.runState(initialState);\n  }\n\n  /**\n   * Executes this state computation and returns the final value.\n   */\n  eval(initialState: S): A {\n    return this.runState(initialState)[0];\n  }\n\n  /**\n   * Executes this state computation and returns the final state.\n   */\n  exec(initialState: S): S {\n    return this.runState(initialState)[1];\n  }\n\n  /**\n   * Maps the result of this state computation using the given function.\n   */\n  map<B>(f: (a: A) => B): StateMonad<S, B> {\n    return new StateMonad<S, B>(s => {\n      const [a, s1] = this.runState(s);\n      return [f(a), s1];\n    });\n  }\n\n  /**\n   * Returns a state computation that applies the function produced by this\n   * state computation to the result of another state computation.\n   */\n  ap<B>(sf: StateMonad<S, (a: A) => B>): StateMonad<S, B> {\n    return new StateMonad<S, B>(s => {\n      const [f, s1] = sf.runState(s);\n      const [a, s2] = this.runState(s1);\n      return [f(a), s2];\n    });\n  }\n\n  /**\n   * Chains this state computation with another one.\n   */\n  flatMap<B>(f: (a: A) => StateMonad<S, B>): StateMonad<S, B> {\n    return new StateMonad<S, B>(s => {\n      const [a, s1] = this.runState(s);\n      return f(a).runState(s1);\n    });\n  }\n\n  /**\n   * Alias for flatMap.\n   */\n  chain<B>(f: (a: A) => StateMonad<S, B>): StateMonad<S, B> {\n    return this.flatMap(f);\n  }\n\n  /**\n   * Transforms both the result and the state using the given functions.\n   */\n  bimap<B, T>(f: (a: A) => B, g: (s: S) => T): StateMonad<T, B> {\n    return new StateMonad<T, B>(s => {\n      const [a, s1] = this.runState(s as any);\n      return [f(a), g(s1 as any)];\n    });\n  }\n}\n\n/**\n * State monad utilities and constructors\n */\nexport const State = {\n  /**\n   * Creates a new State computation that returns the given value without modifying the state.\n   */\n  of<S, A>(a: A): StateMonad<S, A> {\n    return new StateMonad<S, A>(s => [a, s]);\n  },\n\n  /**\n   * Creates a new State computation that returns the current state.\n   */\n  get<S>(): StateMonad<S, S> {\n    return new StateMonad<S, S>(s => [s, s]);\n  },\n\n  /**\n   * Creates a new State computation that replaces the state with a new value.\n   */\n  put<S>(newState: S): StateMonad<S, void> {\n    return new StateMonad<S, void>(_ => [undefined, newState]);\n  },\n\n  /**\n   * Creates a new State computation that modifies the state using the given function.\n   */\n  modify<S>(f: (s: S) => S): StateMonad<S, void> {\n    return new StateMonad<S, void>(s => [undefined, f(s)]);\n  },\n\n  /**\n   * Creates a new State computation that returns a part of the state using the given function.\n   */\n  gets<S, A>(f: (s: S) => A): StateMonad<S, A> {\n    return new StateMonad<S, A>(s => [f(s), s]);\n  },\n\n  /**\n   * Combines multiple state computations into a single one that returns an array of results.\n   */\n  sequence<S, A>(states: StateMonad<S, A>[]): StateMonad<S, A[]> {\n    return new StateMonad<S, A[]>(s => {\n      let currentState = s;\n      const results: A[] = [];\n\n      for (const state of states) {\n        const [result, newState] = state.runState(currentState);\n        results.push(result);\n        currentState = newState;\n      }\n\n      return [results, currentState];\n    });\n  }\n};\n\n// Type alias for convenience\nexport type State<S, A> = StateMonad<S, A>;\n\nexport default State; ","/**\n * The Writer monad represents a computation that produces a value along with a log.\n * It's useful for collecting log messages, building up computations with a log of changes, etc.\n * \n * Example:\n * ```\n * // Create a writer that logs some text and returns a value\n * const logNumber = (n: number) => \n *   Writer.tell<string, number>(`Processing ${n}`).flatMap(() => Writer.of(n * 2), Monoids.string);\n * \n * // Run computations that accumulate logs\n * const result = logNumber(5)\n *   .flatMap(n => Writer.tell(`Result is ${n}`).flatMap(() => Writer.of(n), Monoids.string), Monoids.string);\n * \n * // Extract result and logs\n * const [value, logs] = result.run();\n * // value: 10, logs: \"Processing 5Result is 10\"\n * ```\n */\n\n/**\n * Represents a semigroup that can be combined with another value of the same type.\n */\nexport interface Semigroup<T> {\n  concat(a: T, b: T): T;\n}\n\n/**\n * Represents a monoid, which is a semigroup with an identity element.\n */\nexport interface Monoid<T> extends Semigroup<T> {\n  empty(): T;\n}\n\n/**\n * A Writer monad implementation that produces a value along with a log.\n */\nexport class WriterMonad<W, A> {\n  constructor(private readonly value: A, private readonly log: W) { }\n\n  /**\n   * Runs this writer computation and returns the result value and log.\n   */\n  run(): [A, W] {\n    return [this.value, this.log];\n  }\n\n  /**\n   * Returns the value from this writer computation.\n   */\n  getValue(): A {\n    return this.value;\n  }\n\n  /**\n   * Returns the log from this writer computation.\n   */\n  getLog(): W {\n    return this.log;\n  }\n\n  /**\n   * Maps the result of this writer computation using the given function.\n   */\n  map<B>(f: (a: A) => B): WriterMonad<W, B> {\n    return new WriterMonad<W, B>(f(this.value), this.log);\n  }\n\n  /**\n   * Chains this writer computation with another one.\n   * The logs are combined using the provided monoid.\n   */\n  flatMap<B>(f: (a: A) => WriterMonad<W, B>, monoid: Monoid<W>): WriterMonad<W, B> {\n    const [b, w2] = f(this.value).run();\n    return new WriterMonad<W, B>(b, monoid.concat(this.log, w2));\n  }\n\n  /**\n   * Applies a function inside a writer to a value inside this writer.\n   * The logs are combined using the provided monoid.\n   */\n  ap<B>(wf: WriterMonad<W, (a: A) => B>, monoid: Monoid<W>): WriterMonad<W, B> {\n    const [f, w2] = wf.run();\n    return new WriterMonad<W, B>(f(this.value), monoid.concat(this.log, w2));\n  }\n\n  /**\n   * Maps both the value and the log using provided functions.\n   */\n  bimap<B, X>(f: (a: A) => B, g: (w: W) => X): WriterMonad<X, B> {\n    return new WriterMonad<X, B>(f(this.value), g(this.log));\n  }\n\n  /**\n   * Maps the log using a provided function.\n   */\n  mapLog<X>(f: (w: W) => X): WriterMonad<X, A> {\n    return new WriterMonad<X, A>(this.value, f(this.log));\n  }\n}\n\n/**\n * Commonly used monoids\n */\nexport const Monoids = {\n  /**\n   * A monoid for strings, where concat is string concatenation.\n   */\n  string: {\n    empty: () => '',\n    concat: (a: string, b: string) => a + b\n  },\n\n  /**\n   * A monoid for arrays, where concat is array concatenation.\n   */\n  array<T>(): Monoid<T[]> {\n    return {\n      empty: () => [],\n      concat: (a: T[], b: T[]) => [...a, ...b]\n    };\n  }\n};\n\n/**\n * Writer monad utilities and constructors\n */\nexport const Writer = {\n  /**\n   * Creates a new Writer that returns the given value with an empty log.\n   */\n  of<W, A>(value: A, monoid: Monoid<W>): WriterMonad<W, A> {\n    return new WriterMonad<W, A>(value, monoid.empty());\n  },\n\n  /**\n   * Creates a new Writer that adds the given log message with a default value.\n   */\n  tell<W, A = void>(log: W): WriterMonad<W, void> {\n    return new WriterMonad<W, void>(undefined, log);\n  },\n\n  /**\n   * Creates a new Writer that returns the value of the given writer without its log.\n   */\n  listen<W, A>(w: WriterMonad<W, A>): WriterMonad<W, [A, W]> {\n    const [a, log] = w.run();\n    return new WriterMonad<W, [A, W]>([a, log], log);\n  },\n\n  /**\n   * Creates a new Writer that passes both the value and log to a function to produce a new writer.\n   */\n  pass<W, A>(w: WriterMonad<W, [A, (w: W) => W]>): WriterMonad<W, A> {\n    const [[a, f], log] = w.run();\n    return new WriterMonad<W, A>(a, f(log));\n  },\n\n  /**\n   * Helper function to create a Writer with a string log.\n   */\n  withString<A>(value: A, log: string = ''): WriterMonad<string, A> {\n    return new WriterMonad<string, A>(value, log);\n  },\n\n  /**\n   * Helper function to create a Writer with an array log.\n   */\n  withArray<W, A>(value: A, log: W[] = []): WriterMonad<W[], A> {\n    return new WriterMonad<W[], A>(value, log);\n  }\n};\n\n/**\n * Type alias for convenience\n */\nexport type Writer<W, A> = WriterMonad<W, A>;\n\nexport default Writer; "],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAAA;AAAA,EAAA;AAAA,aAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,eAAAC;AAAA,EAAA,WAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC8GO,IAAM,WAAN,MAAuC;AAAA,EAC5C,YAA6BC,QAAU;AAAV,iBAAAA;AAC3B,QAAIA,WAAU,QAAQA,WAAU,QAAW;AACzC,YAAM,IAAI,MAAM,iDAAiD;AAAA,IACnE;AAAA,EACF;AAAA,EAEA,IAAI,SAAkB;AACpB,WAAO;AAAA,EACT;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KAAK,GAAG,CAAC;AAAA,EACtD;AACF;AAKO,IAAM,UAAU;AAAA;AAAA;AAAA;AAAA,EAIrB,QAAQ;AAAA,IACN,OAAO,MAAM;AAAA,IACb,QAAQ,CAAC,GAAW,MAAc,IAAI;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA,EAKA,QAAwB;AACtB,WAAO;AAAA,MACL,OAAO,MAAM,CAAC;AAAA,MACd,QAAQ,CAAC,GAAQ,MAAW,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,IACzC;AAAA,EACF;AACF;AAKO,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA,EAIpB,GAASA,QAAU,QAAsC;AACvD,WAAO,IAAI,YAAkBA,QAAO,OAAO,MAAM,CAAC;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA,EAKA,KAAkB,KAA8B;AAC9C,WAAO,IAAI,YAAqB,QAAW,GAAG;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKA,OAAa,GAA8C;AACzD,UAAM,CAAC,GAAG,GAAG,IAAI,EAAE,IAAI;AACvB,WAAO,IAAI,YAAuB,CAAC,GAAG,GAAG,GAAG,GAAG;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA,EAKA,KAAW,GAAwD;AACjE,UAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,EAAE,IAAI;AAC5B,WAAO,IAAI,YAAkB,GAAG,EAAE,GAAG,CAAC;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA,EAKA,WAAcA,QAAU,MAAc,IAA4B;AAChE,WAAO,IAAI,YAAuBA,QAAO,GAAG;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgBA,QAAU,MAAW,CAAC,GAAwB;AAC5D,WAAO,IAAI,YAAoBA,QAAO,GAAG;AAAA,EAC3C;AACF;","names":["Left","Map","Right","Set","value","Option","value","Left","Right","Either","value","Right","Left","Try","TryAsync","array","List","empty","value","Map","empty","value","empty","Set","array","Set","Map","result","value","array","value","value","For","Right","type","value","array","value"]}