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

DatumThese overview

Added in v3.5.0

Represents a value of one of eight possible types (a disjoint union).

An instance of DatumThese is equivalent to Datum<These<E, A>>

A common use of DatumThese is as a container for dealing with refreshable data values that can have error conditions (including partial error conditions). The full type list is:

  • Initial
  • Pending
  • Refresh<These<E, A>>
    • Refresh<Left<E>>
    • Refresh<Right<A>>
    • Refresh<Both<E, A>>
  • Replete<Either<E, A>>
    • Replete<Left<E>>
    • Replete<Right<A>>
    • Replete<Both<E, A>>

There are additional helper methods for going from refresh to replete and back.


Table of contents


utils

Bifunctor

Signature

export declare const Bifunctor: Bifunctor2<'@nll/datum/DatumThese'>

Added in v3.5.0

DatumThese (type alias)

Signature

export type DatumThese<E, A> = D.Datum<These<E, A>>

Added in v3.5.0

Failure (type alias)

Signature

export type Failure<E> = Valued<Left<E>>

Added in v3.5.0

Foldable

Signature

export declare const Foldable: Foldable2<'@nll/datum/DatumThese'>

Added in v3.5.0

Functor

Signature

export declare const Functor: Functor2<'@nll/datum/DatumThese'>

Added in v3.5.0

PartialSuccess (type alias)

Signature

export type PartialSuccess<E, A> = Valued<Both<E, A>>

Added in v3.5.0

Success (type alias)

Signature

export type Success<A> = Valued<Right<A>>

Added in v3.5.0

ToLeft (type alias)

Signature

export type ToLeft<T> = T extends DatumThese<infer L, infer _> ? L : never

Added in v3.5.0

ToRight (type alias)

Signature

export type ToRight<T> = T extends DatumThese<infer _, infer R> ? R : never

Added in v3.5.0

Traversable

Signature

export declare const Traversable: Traversable2<'@nll/datum/DatumThese'>

Added in v3.5.0

URI

Signature

export declare const URI: '@nll/datum/DatumThese'

Added in v3.5.0

URI (type alias)

Signature

export type URI = typeof URI

Added in v3.5.0

Valued (type alias)

Signature

export type Valued<A> = D.Refresh<A> | D.Replete<A>

Added in v3.5.0

bimap

Signature

export declare const bimap: <E, G, A, B>(
  f: (e: E) => G,
  g: (a: A) => B
) => (fa: D.Datum<These<E, A>>) => D.Datum<These<G, B>>

Added in v3.5.0

constInitial

Signature

export declare function constInitial<E = never, D = never>(): DatumThese<E, D>

Added in v3.5.0

constPending

Signature

export declare const constPending: <E = never, D = never>() => D.Datum<These<E, D>>

Added in v3.5.0

failure

Signature

export declare const failure: <E = never, A = never>(e: E) => D.Datum<These<E, A>>

Added in v3.5.0

failureR

Signature

export declare const failureR: <E = never, A = never>(e: E) => D.Datum<These<E, A>>

Added in v3.5.0

fold

Signature

export declare const fold: <E, A, B>(
  onInitial: Lazy<B>,
  onPending: Lazy<B>,
  onRefreshLeft: FunctionN<[E], B>,
  onRefreshRight: FunctionN<[A], B>,
  onRefreshBoth: FunctionN<[E, A], B>,
  onRepleteLeft: FunctionN<[E], B>,
  onRepleteRight: FunctionN<[A], B>,
  onRepleteBoth: FunctionN<[E, A], B>
) => (fea: D.Datum<These<E, A>>) => B

Added in v3.5.0

foldMap

Signature

export declare const foldMap: <M>(M: Monoid<M>) => <A>(f: (a: A) => M) => <E>(fa: D.Datum<These<E, A>>) => M

Added in v3.5.0

fromNullable

Takes a nullable value, if the value is not nully, turn it into a Success<A>, otherwise Initial.

Signature

export declare const fromNullable: <E, A>(a: A | null | undefined) => D.Datum<These<E, A>>

Added in v3.5.0

fromOption

Signature

export declare const fromOption: <E, A>(onNone: Lazy<E>) => (o: Option<A>) => D.Datum<These<E, A>>

Added in v3.5.0

getApplicative

Signature

export declare const getApplicative: <E>(S: Semigroup<E>) => Applicative2C<'@nll/datum/DatumThese', E>

Added in v3.5.0

getApply

Signature

export declare const getApply: <E>(S: Semigroup<E>) => Apply2C<'@nll/datum/DatumThese', E>

Added in v3.5.0

getApplySemigroup

Signature

export declare const getApplySemigroup: <E, A>(S: Semigroup<These<E, A>>) => Semigroup<D.Datum<These<E, A>>>

Added in v3.5.0

getChain

Signature

export declare const getChain: <E>(S: Semigroup<E>) => Chain2C<'@nll/datum/DatumThese', E>

Added in v3.5.0

getEq

Signature

export declare const getEq: <E, A>(EE: Eq<E>, EA: Eq<A>) => Eq<D.Datum<These<E, A>>>

Added in v3.5.0

getMonad

Signature

export declare const getMonad: <E>(S: Semigroup<E>) => Monad2C<'@nll/datum/DatumThese', E>

Added in v3.5.0

getMonadThrow

Signature

export declare const getMonadThrow: <E>(S: Semigroup<E>) => MonadThrow2C<'@nll/datum/DatumThese', E>

Added in v3.5.0

getMonoid

Signature

export declare const getMonoid: <E, A>(S: Semigroup<These<E, A>>) => Monoid<D.Datum<These<E, A>>>

Added in v4.0.0

getSemigroup

Signature

export declare const getSemigroup: <E, A>(S: Semigroup<These<E, A>>) => Semigroup<D.Datum<These<E, A>>>

Added in v4.0.0

getShow

Signature

export declare const getShow: <E, A>(SE: Show<E>, SA: Show<A>) => Show<D.Datum<These<E, A>>>

Added in v3.5.0

initial

Signature

export declare const initial: D.Datum<These<never, never>>

Added in v3.5.0

isFailure

Signature

export declare const isFailure: <E, A>(fea: D.Datum<These<E, A>>) => fea is Valued<Left<E>>

Added in v3.5.0

isInitial

Signature

export declare const isInitial: <A>(ma: D.Datum<A>) => ma is D.Initial

Added in v3.5.0

isPartialSuccess

Signature

export declare const isPartialSuccess: <E, A>(fea: D.Datum<These<E, A>>) => fea is Valued<Both<E, A>>

Added in v3.5.0

isPending

Signature

export declare const isPending: <A>(ma: D.Datum<A>) => ma is D.Pending

Added in v3.5.0

isRefresh

Signature

export declare const isRefresh: <A>(ma: D.Datum<A>) => ma is D.Refresh<A>

Added in v3.5.0

isRefreshBoth

Signature

export declare const isRefreshBoth: <E, A>(fea: D.Datum<These<E, A>>) => fea is D.Refresh<Both<E, A>>

Added in v3.5.0

isRefreshLeft

Signature

export declare const isRefreshLeft: <E, A>(fea: D.Datum<These<E, A>>) => fea is D.Refresh<Left<E>>

Added in v3.5.0

isRefreshRight

Signature

export declare const isRefreshRight: <E, A>(fea: D.Datum<These<E, A>>) => fea is D.Refresh<Right<A>>

Added in v3.5.0

isReplete

Signature

export declare const isReplete: <A>(ma: D.Datum<A>) => ma is D.Replete<A>

Added in v3.5.0

isRepleteBoth

Signature

export declare const isRepleteBoth: <E, A>(fea: D.Datum<These<E, A>>) => fea is D.Replete<Both<E, A>>

Added in v3.5.0

isRepleteLeft

Signature

export declare const isRepleteLeft: <E, A>(fea: D.Datum<These<E, A>>) => fea is D.Replete<Left<E>>

Added in v3.5.0

isRepleteRight

Signature

export declare const isRepleteRight: <E, A>(fea: D.Datum<These<E, A>>) => fea is D.Replete<Right<A>>

Added in v3.5.0

isSuccess

Signature

export declare const isSuccess: <E, A>(fea: D.Datum<These<E, A>>) => fea is Valued<Right<A>>

Added in v3.5.0

isValued

Signature

export declare const isValued: <A>(ma: D.Datum<A>) => ma is D.Refresh<A> | D.Replete<A>

Added in v3.5.0

map

Signature

export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: D.Datum<These<E, A>>) => D.Datum<These<E, B>>

Added in v3.5.0

mapLeft

Signature

export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: D.Datum<These<E, A>>) => D.Datum<These<G, A>>

Added in v3.5.0

partialSuccess

Signature

export declare const partialSuccess: <E = never, A = never>(e: E, a: A) => D.Datum<These<E, A>>

Added in v3.5.0

partialSuccessR

Signature

export declare const partialSuccessR: <E = never, A = never>(e: E, a: A) => D.Datum<These<E, A>>

Added in v3.5.0

pending

Signature

export declare const pending: D.Datum<These<never, never>>

Added in v3.5.0

reduce

Signature

export declare const reduce: <A, B>(b: B, f: (b: B, a: A) => B) => <E>(fa: D.Datum<These<E, A>>) => B

Added in v3.5.0

reduceRight

Signature

export declare const reduceRight: <A, B>(b: B, f: (a: A, b: B) => B) => <E>(fa: D.Datum<These<E, A>>) => B

Added in v3.5.0

refreshFold

Signature

export declare const refreshFold: <E, A, B>(
  onInitial: () => B,
  onPending: () => B,
  onFailure: (e: E, r?: boolean | undefined) => B,
  onSuccess: (a: A, r?: boolean | undefined) => B,
  onPartialSuccess: (e: E, a: A, r?: boolean | undefined) => B
) => (fea: D.Datum<These<E, A>>) => B

Added in v3.5.0

squash

Signature

export declare const squash: <E, A, B>(
  onNone: (r?: boolean | undefined) => B,
  onFailure: (e: E, r?: boolean | undefined) => B,
  onSuccess: (a: A, r?: boolean | undefined) => B,
  onPartialSuccess: (e: E, a: A, r?: boolean | undefined) => B
) => (fea: D.Datum<These<E, A>>) => B

Added in v3.5.0

success

Signature

export declare const success: <E = never, A = never>(a: A) => D.Datum<These<E, A>>

Added in v3.5.0

successR

Signature

export declare const successR: <E = never, A = never>(a: A) => D.Datum<These<E, A>>

Added in v3.5.0

toRefresh

Signature

export declare const toRefresh: <E, A>(fea: D.Datum<These<E, A>>) => D.Datum<These<E, A>>

Added in v3.5.0

toReplete

Signature

export declare const toReplete: <E, A>(fea: D.Datum<These<E, A>>) => D.Datum<These<E, A>>

Added in v3.5.0