import { AnyFunction } from "../types/global.cjs";

//#region src/modules/fp.d.ts
/**
 * pipe方法，用于串联函数的，实现流水线管道，需要传入的函数入参和出参都是一个(一元函数)。
 * 执行从左到右的函数组合。第一个参数可以有任意数量；其余参数必须是一元的。
 * @param functions - 要组合的函数列表
 * @returns 组合后的函数
 * @public
 */
declare function pipe<OUT = any>(...functions: AnyFunction[]): (...args: any) => OUT;
/**
 * 组合函数
 * 和pipe类似，但是先执行的函数放在最后，更接近数学的函数。
 * 最后一个参数可以有任意数量,其余参数必须是一元的。
 * @param functions - 要组合的函数列表
 * @returns 组合后的函数
 * @public
 */
declare function compose<OUT = any>(...functions: AnyFunction[]): (...args: any) => OUT;
/**
 * 通用柯里化，将任意参数的函数，转化为嵌套调用
 * @param func - 要柯里化的函数
 * @param arity - 函数的参数数量
 * @returns 柯里化后的函数
 * @public
 */
declare function curry(func: (...args: any) => any, arity?: number): (...args: any[]) => any;
/**
 * 恒等函数，返回传入的参数
 * @param x - 要返回的值
 * @returns 传入的值
 * @public
 */
declare function identity<T>(x: T): T;
declare abstract class AbstractFunctor<T = any> {
  abstract map<R = any>(f: (val: T) => R): AbstractFunctor<R>;
}
declare abstract class AbstractMonad<T = any> extends AbstractFunctor<T> {
  abstract flatMap<R = any>(f: (arg: T) => R): AbstractMonad<R>;
}
/**
 *
 *Monad是带有flatMap方法的Functor
 * @class Monad
 * @template T
 * @public
 */
declare class Monad<T = any> extends AbstractMonad<T> {
  private val;
  constructor(x: T);
  static of<U = any>(val: U): Monad<U>;
  map(f: (arg: T) => any): Monad<any>;
  /**
   * Monda使用flatMap函数可以解决Functor嵌套的问题
   * @param f - 映射函数
   * @returns 展平后的结果
   */
  flatMap(f: (arg0: T) => any): any;
  valueOf(): T;
  /**
   * 展示内部数据
   * @returns 内部数据的字符串表示
   */
  inspect(): string;
}
//#endregion
export { Monad, compose, curry, identity, pipe };