fp-ts-wonka
Version:
[fp-ts](https://github.com/gcanti/fp-ts) bindings for [wonka](https://wonka.kitten.sh/)
278 lines (277 loc) • 8.38 kB
TypeScript
/**
* A “[source](https://wonka.kitten.sh/api/sources)" in Wonka is a provider of
* data. It provides data to a “sink” when the “sink” requests it. This is
* called a pull signal and for synchronous sources no time will pass between
* the sink pulling a new value and a source sending it. For asynchronous
* sources, the source may either ignore pull signals and just push values or
* send one some time after the pull signal.
*
* @since 0.1.0
*/
import { Alt1 } from 'fp-ts/Alt';
import { Alternative1 } from 'fp-ts/Alternative';
import { Applicative1 } from 'fp-ts/Applicative';
import { Apply1 } from 'fp-ts/Apply';
import { Compactable1 } from 'fp-ts/Compactable';
import { Separated } from 'fp-ts/Separated';
import * as E from 'fp-ts/Either';
import { Filterable1 } from 'fp-ts/Filterable';
import { Predicate } from 'fp-ts/Predicate';
import { Refinement } from 'fp-ts/Refinement';
import { Functor1 } from 'fp-ts/Functor';
import { Chain1 } from 'fp-ts/Chain';
import { Monad1 } from 'fp-ts/Monad';
import { MonadIO1 } from 'fp-ts/MonadIO';
import { MonadTask1 } from 'fp-ts/MonadTask';
import { Monoid } from 'fp-ts/Monoid';
import * as O from 'fp-ts/Option';
import * as Wonka from 'wonka';
import { MonadSource1 } from './MonadSource';
import { Task } from 'fp-ts/lib/Task';
import { Pointed1 } from 'fp-ts/lib/Pointed';
/**
* @since 0.1.0
* @category Model
*/
export declare type Source<A> = Wonka.Source<A>;
/**
* @since 0.1.0
* @category Natural transformations
*/
export declare const fromOption: <A>(o: O.Option<A>) => Wonka.Source<A>;
/**
* @since 0.1.0
* @category Natural transformations
*/
export declare const fromIO: MonadIO1<URI>['fromIO'];
/**
* @since 0.1.0
* @category Natural transformations
*/
export declare const fromTask: MonadTask1<URI>['fromTask'];
/**
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>)
* => F<B>` whose argument and return types use the type constructor `F` to
* represent some computational context.
*
* @since 0.1.0
* @category Functor
*/
export declare const map: <A, B>(f: (a: A) => B) => (fa: Wonka.Source<A>) => Wonka.Source<B>;
/**
* Apply a function to an argument under a type constructor.
*
* @since 0.1.0
* @category Apply
*/
export declare const ap: <A>(fa: Wonka.Source<A>) => <B>(fab: Wonka.Source<(a: A) => B>) => Wonka.Source<B>;
/**
* Apply a function to an argument under a type constructor.
*
* @since 0.1.0
* @category Apply
*/
export declare const apW: <A>(fa: Source<A>) => <B>(fab: Source<(a: A) => B>) => Source<B>;
/**
* Combine two effectful actions, keeping only the result of the first.
*
* Derivable from `Apply`.
*
* @since 0.1.0
* @category Combinators
*/
export declare const apFirst: <B>(fb: Wonka.Source<B>) => <A>(fa: Wonka.Source<A>) => Wonka.Source<A>;
/**
* Combine two effectful actions, keeping only the result of the second.
*
* Derivable from `Apply`.
*
* @since 0.1.0
* @category Combinators
*/
export declare const apSecond: <B>(fb: Wonka.Source<B>) => <A>(fa: Wonka.Source<A>) => Wonka.Source<B>;
/**
* @since 0.1.0
* @category Pointed
*/
export declare const of: Pointed1<URI>['of'];
/**
* Composes computations in sequence, using the return value of one computation
* to determine the next computation.
*
* @since 0.1.0
* @category Monad
*/
export declare const chain: <A, B>(f: (a: A) => Wonka.Source<B>) => (ma: Wonka.Source<A>) => Wonka.Source<B>;
/**
* Derivable from `Monad`.
*
* @since 0.1.0
* @category Combinators
*/
export declare const flatten: <A>(mma: Wonka.Source<Wonka.Source<A>>) => Wonka.Source<A>;
/**
* Identifies an associative operation on a type constructor. It is similar to
* `Semigroup`, except that it applies to types of kind `* -> *`.
*
* @since 0.1.0
* @category Alt
*/
export declare const alt: <A>(that: () => Wonka.Source<A>) => (fa: Wonka.Source<A>) => Wonka.Source<A>;
/**
* @since 0.1.0
* @category Filterable
*/
export declare const filterMap: <A, B>(f: (a: A) => O.Option<B>) => (fa: Wonka.Source<A>) => Wonka.Source<B>;
/**
* @since 0.1.0
* @category Compactable
*/
export declare const compact: <A>(fa: Wonka.Source<O.Option<A>>) => Wonka.Source<A>;
/**
* @since 0.1.0
* @category Filterable
*/
export declare const partitionMap: <A, B, C>(f: (a: A) => E.Either<B, C>) => (fa: Wonka.Source<A>) => Separated<Wonka.Source<B>, Wonka.Source<C>>;
/**
* @since 0.1.0
* @category Compactable
*/
export declare const separate: <A, B>(fa: Wonka.Source<E.Either<A, B>>) => Separated<Wonka.Source<A>, Wonka.Source<B>>;
/**
* @since 0.1.0
* @category Filterable
*/
export declare const filter: {
<A, B extends A>(refinement: Refinement<A, B>): (fa: Wonka.Source<A>) => Wonka.Source<B>;
<A>(predicate: Predicate<A>): (fa: Wonka.Source<A>) => Wonka.Source<A>;
};
/**
* @since 0.1.0
* @category Filterable
*/
export declare const partition: {
<A, B extends A>(refinement: Refinement<A, B>): (fa: Wonka.Source<A>) => Separated<Wonka.Source<A>, Wonka.Source<B>>;
<A>(predicate: Predicate<A>): (fa: Wonka.Source<A>) => Separated<Wonka.Source<A>, Wonka.Source<A>>;
};
/**
* @since 0.1.0
* @category Alternative
*/
export declare const zero: Alternative1<URI>['zero'];
/**
* @since 0.1.0
* @category Instances
*/
export declare const URI = "wonka/Source";
/**
* @since 0.1.0
* @category Instances
*/
export declare type URI = typeof URI;
declare module 'fp-ts/lib/HKT' {
interface URItoKind<A> {
readonly [URI]: Wonka.Source<A>;
}
}
/**
* @since 0.1.0
* @category Instances
*/
export declare const getMonoid: <A = never>() => Monoid<Wonka.Source<A>>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Functor: Functor1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Pointed: Pointed1<URI>;
/**
* Derivable from `Functor`.
*
* @since 0.1.0
* @category Combinators
*/
export declare const flap: <A>(a: A) => <B>(fab: Wonka.Source<(a: A) => B>) => Wonka.Source<B>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Apply: Apply1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Applicative: Applicative1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Chain: Chain1<URI>;
/**
* Composes computations in sequence, using the return value of one computation
* to determine the next computation and keeping only the result of the first.
*
* Derivable from `Monad`.
*
* @since 0.1.0
* @category Combinators
*/
export declare const chainFirst: <A, B>(f: (a: A) => Wonka.Source<B>) => (ma: Wonka.Source<A>) => Wonka.Source<A>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Monad: Monad1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Alt: Alt1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Alternative: Alternative1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Compactable: Compactable1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const Filterable: Filterable1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const MonadIO: MonadIO1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const MonadTask: MonadTask1<URI>;
/**
* @since 0.1.0
* @category Instances
*/
export declare const MonadSource: MonadSource1<URI>;
/** @since 0.1.0 */
export declare const Do: Wonka.Source<Record<PropertyKey, unknown>>;
/** @since 0.1.0 */
export declare const bindTo: <N extends string>(name: N) => <A>(fa: Wonka.Source<A>) => Wonka.Source<{ readonly [K in N]: A; }>;
/** @since 0.1.0 */
export declare const bind: <N extends string, A, B>(name: Exclude<N, keyof A>, f: (a: A) => Wonka.Source<B>) => (ma: Wonka.Source<A>) => Wonka.Source<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>;
/** @since 0.1.0 */
export declare const apS: <N extends string, A, B>(name: Exclude<N, keyof A>, fb: Wonka.Source<B>) => (fa: Wonka.Source<A>) => Wonka.Source<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>;
/** @since 0.1.0 */
export declare const apSW: <A, N extends string, B>(name: Exclude<N, keyof A>, fb: Source<B>) => (fa: Source<A>) => Source<{
readonly [K in keyof A | N]: K extends keyof A ? A[K] : B;
}>;
/** @since 0.1.0 */
export declare const toTask: <A>(s: Wonka.Source<A>) => Task<A>;