Skip to main content Link Search Menu Expand Document (external link)

Covariant overview

Added in v1.0.0


Table of contents


do notation

let

Signature

export declare const let: <F extends TypeLambda>(
  F: Covariant<F>
) => {
  <N extends string, A extends object, B>(name: Exclude<N, keyof A>, f: (a: A) => B): <R, O, E>(
    self: Kind<F, R, O, E, A>
  ) => Kind<F, R, O, E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
  <R, O, E, A extends object, N extends string, B>(
    self: Kind<F, R, O, E, A>,
    name: Exclude<N, keyof A>,
    f: (a: A) => B
  ): Kind<F, R, O, E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
}

Added in v1.0.0

mapping

as

Signature

export declare const as: <F extends TypeLambda>(
  F: Covariant<F>
) => {
  <B>(b: B): <R, O, E, _>(self: Kind<F, R, O, E, _>) => Kind<F, R, O, E, B>
  <R, O, E, _, B>(self: Kind<F, R, O, E, _>, b: B): Kind<F, R, O, E, B>
}

Added in v1.0.0

asUnit

Signature

export declare const asUnit: <F extends TypeLambda>(
  F: Covariant<F>
) => <R, O, E, _>(self: Kind<F, R, O, E, _>) => Kind<F, R, O, E, void>

Added in v1.0.0

flap

Signature

export declare const flap: <F extends TypeLambda>(
  F: Covariant<F>
) => {
  <R, O, E, A, B>(self: Kind<F, R, O, E, (a: A) => B>): (a: A) => Kind<F, R, O, E, B>
  <A, R, O, E, B>(a: A, self: Kind<F, R, O, E, (a: A) => B>): Kind<F, R, O, E, B>
}

Added in v1.0.0

type class

Covariant (interface)

Signature

export interface Covariant<F extends TypeLambda> extends Invariant<F> {
  readonly map: {
    <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>
    <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>
  }
}

Added in v1.0.0

utils

imap

Returns a default imap implementation.

Signature

export declare const imap: <F extends TypeLambda>(
  map: <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B) => Kind<F, R, O, E, B>
) => {
  <A, B>(to: (a: A) => B, from: (b: B) => A): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>
  <R, O, E, A, B>(self: Kind<F, R, O, E, A>, to: (a: A) => B, from: (b: B) => A): Kind<F, R, O, E, B>
}

Added in v1.0.0

mapComposition

Returns a default map composition.

Signature

export declare const mapComposition: <F extends TypeLambda, G extends TypeLambda>(
  F: Covariant<F>,
  G: Covariant<G>
) => <FR, FO, FE, GR, GO, GE, A, B>(
  self: Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, A>>,
  f: (a: A) => B
) => Kind<F, FR, FO, FE, Kind<G, GR, GO, GE, B>>

Added in v1.0.0