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

Flatten overview

Added in v1.0.0


Table of contents


constructors

alreadyFlat

Signature

export declare const alreadyFlat: Flatten<never>

Added in v1.0.0

flattened

Signature

export declare const flattened: <A>(value: A) => Flatten<A>

Added in v1.0.0

neverFlat

Signature

export declare const neverFlat: Flatten<never>

Added in v1.0.0

mapping

map

Signature

export declare const map: {
  <A, B>(f: (a: A) => B): (self: Flatten<A>) => Flatten<B>
  <A, B>(self: Flatten<A>, f: (a: A) => B): Flatten<B>
}

Added in v1.0.0

model

AlreadyFlat (interface)

Represents a FlattenResult where the input was already flat.

Signature

export interface AlreadyFlat<A> extends Flatten.Variance<A> {
  readonly _tag: "AlreadyFlat"
}

Added in v1.0.0

Flatten (type alias)

Because certain documents do not change after removal of newlines, etc, there is no point in creating a Union of the flattened and unflattened versions. All this leads to is the introduction of two possible branches for a layout algorithm to take, resulting in potentially exponential behavior on deeply nested examples.

Signature

export type Flatten<A> = Flattened<A> | AlreadyFlat<A> | NeverFlat<A>

Added in v1.0.0

FlattenTypeLambda (interface)

Signature

export interface FlattenTypeLambda extends TypeLambda {
  readonly type: Flatten<this["Target"]>
}

Added in v1.0.0

Flattened (interface)

Represents a FlattenResult where A is likely flatter than the input.

Signature

export interface Flattened<A> extends Flatten.Variance<A> {
  readonly _tag: "Flattened"
  readonly value: A
}

Added in v1.0.0

NeverFlat (interface)

Represents a FlattenResult where the input cannot be flattened.

Signature

export interface NeverFlat<A> extends Flatten.Variance<A> {
  readonly _tag: "NeverFlat"
}

Added in v1.0.0

refinements

isAlreadyFlat

Returns true if the specified Flatten is an AlreadyFlat, false otherwise.

Signature

export declare const isAlreadyFlat: <A>(a: Flatten<A>) => a is AlreadyFlat<A>

Added in v1.0.0

isFlatten

Returns true if the specified value is a Flatten, false otherwise.

Signature

export declare const isFlatten: (u: unknown) => u is Flatten<unknown>

Added in v1.0.0

isFlattened

Returns true if the specified Flatten is a Flattened, false otherwise.

Signature

export declare const isFlattened: <A>(a: Flatten<A>) => a is Flattened<A>

Added in v1.0.0

isNeverFlat

Returns true if the specified Flatten is a NeverFlat, false otherwise.

Signature

export declare const isNeverFlat: <A>(a: Flatten<A>) => a is NeverFlat<A>

Added in v1.0.0

symbol

FlattenTypeId

Signature

export declare const FlattenTypeId: typeof FlattenTypeId

Added in v1.0.0

FlattenTypeId (type alias)

Signature

export type FlattenTypeId = typeof FlattenTypeId

Added in v1.0.0

utils

Flatten (namespace)

Added in v1.0.0

Variance (interface)

Signature

export interface Variance<A> extends Equal {
  readonly [FlattenTypeId]: {
    readonly _A: (_: never) => A
  }
}

Added in v1.0.0

TypeLambda (type alias)

Signature

export type TypeLambda = FlattenTypeLambda

Added in v1.0.0