/*! * Copyright (c) 2017 by The Funfix Project Developers. * Some rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Try, Option, Either, Throwable } from "funfix-core"; import { Eval, IO } from "funfix-effect"; import { Future } from "funfix-exec"; import { HK } from "./kinds"; import { Monad, MonadError } from "./monad"; import { Comonad, CoflatMap } from "./comonad"; import { Eq } from "./eq"; /** * Alias used for encoding higher-kinded types when implementing * type class instances. */ export declare type OptionK = HK, A>; /** * Type class instances provided by default for `Option`. */ export declare class OptionInstances implements Monad>, Eq>, CoflatMap> { private __unit; eqv(lh: Option, rh: Option): boolean; pure(a: A): Option; unit(): Option; ap(fa: OptionK, ff: OptionK<(a: A) => B>): Option; map(fa: OptionK, f: (a: A) => B): Option; map2(fa: OptionK, fb: OptionK, f: (a: A, b: B) => Z): Option; product(fa: OptionK, fb: OptionK): Option<[A, B]>; flatMap(fa: OptionK, f: (a: A) => OptionK): Option; tailRecM(a: A, f: (a: A) => OptionK>): Option; coflatMap(fa: OptionK, ff: (a: OptionK) => B): Option; coflatten(fa: OptionK): Option>; followedBy: (fa: OptionK, fb: OptionK) => Option; followedByL: (fa: OptionK, fb: () => OptionK) => Option; forEffect: (fa: OptionK, fb: OptionK) => Option; forEffectL: (fa: OptionK, fb: () => OptionK) => Option; static readonly global: OptionInstances; } /** * Alias used for encoding higher-kinded types when implementing * type class instances. */ export declare type TryK = HK, A>; /** * Type class instances provided by default for `Option`. */ export declare class TryInstances implements MonadError, Throwable>, Eq>, CoflatMap> { eqv(lh: Try, rh: Try): boolean; pure(a: A): Try; unit(): Try; ap(fa: TryK, ff: TryK<(a: A) => B>): Try; map(fa: TryK, f: (a: A) => B): Try; map2(fa: TryK, fb: TryK, f: (a: A, b: B) => Z): Try; product(fa: TryK, fb: TryK): Try<[A, B]>; flatMap(fa: TryK, f: (a: A) => TryK): Try; tailRecM(a: A, f: (a: A) => TryK>): Try; raise(e: any): Try; attempt(fa: TryK): Try>; recoverWith(fa: TryK, f: (e: Throwable) => TryK): Try; recover(fa: TryK, f: (e: Throwable) => A): Try; coflatMap(fa: TryK, ff: (a: TryK) => B): Try; coflatten(fa: TryK): Try>; followedBy: (fa: TryK, fb: TryK) => Try; followedByL: (fa: TryK, fb: () => TryK) => Try; forEffect: (fa: TryK, fb: TryK) => Try; forEffectL: (fa: TryK, fb: () => TryK) => Try; static global: TryInstances; } /** * Alias used for encoding higher-kinded types when implementing * type class instances. */ export declare type EitherK = HK, R>; /** * Type class instances provided by default for `Either`. */ export declare class EitherInstances implements Monad>, Eq>, CoflatMap> { private __unit; eqv(lh: Either, rh: Either): boolean; pure(a: A): Either; unit(): Either; ap(fa: EitherK, ff: EitherK B>): Either; map(fa: EitherK, f: (a: A) => B): Either; map2(fa: EitherK, fb: EitherK, f: (a: A, b: B) => Z): Either; product(fa: EitherK, fb: EitherK): Either; flatMap(fa: HK, A>, f: (a: A) => HK, B>): HK, B>; tailRecM(a: A, f: (a: A) => HK, Either>): HK, B>; coflatMap(fa: EitherK, ff: (a: EitherK) => B): Either; coflatten(fa: EitherK): Either>; followedBy: (fa: EitherK, fb: EitherK) => Either; followedByL: (fa: EitherK, fb: () => EitherK) => Either; forEffect: (fa: EitherK, fb: EitherK) => Either; forEffectL: (fa: EitherK, fb: () => EitherK) => Either; static global: EitherInstances; } /** * Alias used for encoding higher-kinded types when implementing * type class instances. */ export declare type EvalK = HK, A>; /** * Type class instances provided by default for `Eval`. */ export declare class EvalInstances implements Monad>, Comonad> { pure(a: A): Eval; flatMap(fa: EvalK, f: (a: A) => EvalK): Eval; tailRecM(a: A, f: (a: A) => EvalK>): Eval; ap(fa: EvalK, ff: EvalK<(a: A) => B>): Eval; map(fa: EvalK, f: (a: A) => B): Eval; unit(): Eval; coflatMap(fa: EvalK, ff: (a: EvalK) => B): Eval; coflatten(fa: EvalK): Eval>; extract(fa: EvalK): A; map2: (fa: EvalK, fb: EvalK, f: (a: A, b: B) => Z) => Eval; product: (fa: EvalK, fb: EvalK) => EvalK<[A, B]>; followedBy: (fa: EvalK, fb: EvalK) => Eval; followedByL: (fa: EvalK, fb: () => EvalK) => Eval; forEffect: (fa: EvalK, fb: EvalK) => Eval; forEffectL: (fa: EvalK, fb: () => EvalK) => Eval; static global: EvalInstances; } /** * Alias used for encoding higher-kinded types when implementing * type class instances. */ export declare type FutureK = HK, A>; /** * Type class instances provided by default for `Future`. */ export declare class FutureInstances implements MonadError, Throwable>, CoflatMap> { pure(a: A): Future; flatMap(fa: FutureK, f: (a: A) => FutureK): Future; tailRecM(a: A, f: (a: A) => FutureK>): Future; ap(fa: FutureK, ff: FutureK<(a: A) => B>): Future; map(fa: FutureK, f: (a: A) => B): Future; unit(): Future; raise(e: Throwable): Future; attempt(fa: FutureK): Future>; recoverWith(fa: FutureK, f: (e: Throwable) => FutureK): Future; recover(fa: FutureK, f: (e: Throwable) => A): Future; map2(fa: FutureK, fb: FutureK, f: (a: A, b: B) => Z): Future; coflatMap(fa: FutureK, ff: (a: FutureK) => B): Future; coflatten(fa: FutureK): Future>; product: (fa: FutureK, fb: FutureK) => FutureK<[A, B]>; followedBy: (fa: FutureK, fb: FutureK) => Future; followedByL: (fa: FutureK, fb: () => FutureK) => Future; forEffect: (fa: FutureK, fb: FutureK) => Future; forEffectL: (fa: FutureK, fb: () => FutureK) => Future; static global: FutureInstances; } /** * Alias used for encoding higher-kinded types when implementing * type class instances. */ export declare type IOK = HK, A>; /** * Type class instances provided by default for `IO`. */ export declare class IOInstances implements MonadError, Throwable>, CoflatMap> { pure(a: A): IO; flatMap(fa: IOK, f: (a: A) => IOK): IO; tailRecM(a: A, f: (a: A) => IOK>): IO; ap(fa: IOK, ff: IOK<(a: A) => B>): IO; map(fa: IOK, f: (a: A) => B): IO; unit(): IO; raise(e: Throwable): IO; attempt(fa: IOK): IO>; recoverWith(fa: IOK, f: (e: Throwable) => IOK): IO; recover(fa: IOK, f: (e: Throwable) => A): IO; map2(fa: IOK, fb: IOK, f: (a: A, b: B) => Z): IO; followedBy(fa: IOK, fb: IOK): IO; followedByL(fa: IOK, fb: () => IOK): IO; forEffect(fa: IOK, fb: IOK): IO; forEffectL(fa: IOK, fb: () => IOK): IO; product(fa: IOK, fb: IOK): IO<[A, B]>; coflatMap(fa: IOK, ff: (a: IOK) => B): IO; coflatten(fa: IOK): IO>; static global: IOInstances; }