DocStream overview
Added in v1.0.0
Table of contents
annotations
alterAnnotations
Changes the annotation of a document to a different annotation, or to none at all.
Signature
export declare const alterAnnotations: {
<A, B>(f: (a: A) => Option<B>): (self: DocStream<A>) => DocStream<B>
<A, B>(self: DocStream<A>, f: (a: A) => Option<B>): DocStream<B>
}
Added in v1.0.0
reAnnotate
Modify the annotations of a document.
Signature
export declare const reAnnotate: {
<A, B>(f: (a: A) => B): (self: DocStream<A>) => DocStream<B>
<A, B>(self: DocStream<A>, f: (a: A) => B): DocStream<B>
}
Added in v1.0.0
unAnnotate
Remove all annotations from a document.
Signature
export declare const unAnnotate: <A>(self: DocStream<A>) => DocStream<never>
Added in v1.0.0
constructors
char
Signature
export declare const char: {
(char: string): <A>(self: DocStream<A>) => DocStream<A>
<A>(self: DocStream<A>, char: string): DocStream<A>
}
Added in v1.0.0
empty
Signature
export declare const empty: DocStream<never>
Added in v1.0.0
failed
Signature
export declare const failed: DocStream<never>
Added in v1.0.0
line
Signature
export declare const line: {
(indentation: number): <A>(self: DocStream<A>) => DocStream<A>
<A>(self: DocStream<A>, indentation: number): DocStream<A>
}
Added in v1.0.0
popAnnotation
Signature
export declare const popAnnotation: <A>(stream: DocStream<A>) => DocStream<A>
Added in v1.0.0
pushAnnotation
Signature
export declare const pushAnnotation: {
<B>(annotation: B): <A>(self: DocStream<A>) => DocStream<B | A>
<A, B>(self: DocStream<A>, annotation: B): DocStream<A | B>
}
Added in v1.0.0
text
Signature
export declare const text: {
(text: string): <A>(self: DocStream<A>) => DocStream<A>
<A>(self: DocStream<A>, text: string): DocStream<A>
}
Added in v1.0.0
folding
foldMap
Signature
export declare const foldMap: {
<A, M>(M: monoid.Monoid<M>, f: (a: A) => M): (self: DocStream<A>) => M
<A, M>(self: DocStream<A>, M: monoid.Monoid<M>, f: (a: A) => M): M
}
Added in v1.0.0
match
Signature
export declare const match: {
<A, R>(patterns: {
readonly FailedStream: () => R
readonly EmptyStream: () => R
readonly CharStream: (char: string, stream: DocStream<A>) => R
readonly TextStream: (text: string, stream: DocStream<A>) => R
readonly LineStream: (indentation: number, stream: DocStream<A>) => R
readonly PushAnnotationStream: (annotation: A, stream: DocStream<A>) => R
readonly PopAnnotationStream: (stream: DocStream<A>) => R
}): (self: DocStream<A>) => R
<A, R>(
self: DocStream<A>,
patterns: {
readonly FailedStream: () => R
readonly EmptyStream: () => R
readonly CharStream: (char: string, stream: DocStream<A>) => R
readonly TextStream: (text: string, stream: DocStream<A>) => R
readonly LineStream: (indentation: number, stream: DocStream<A>) => R
readonly PushAnnotationStream: (annotation: A, stream: DocStream<A>) => R
readonly PopAnnotationStream: (stream: DocStream<A>) => R
}
): R
}
Added in v1.0.0
instances
Functor
Signature
export declare const Functor: covariant.Covariant<DocStreamTypeLambda>
Added in v1.0.0
Invariant
Signature
export declare const Invariant: invariant.Invariant<DocStreamTypeLambda>
Added in v1.0.0
mapping
map
Signature
export declare const map: {
<A, B>(f: (a: A) => B): (self: DocStream<A>) => DocStream<B>
<A, B>(self: DocStream<A>, f: (a: A) => B): DocStream<B>
}
Added in v1.0.0
model
CharStream (interface)
Represents a Doc
containing a single character.
Signature
export interface CharStream<A> extends DocStream.Variance<A> {
readonly _tag: "CharStream"
readonly char: string
readonly stream: DocStream<A>
}
Added in v1.0.0
DocStream (type alias)
Represents a document that has been laid out and can be processed used by the rendering algorithms.
A simplified view is that a Doc
is equivalent to an array of DocStream
, and the layout algorithms simply pick a DocStream
based upon which instance best fits the layout constraints. Therefore, a DocStream
has all complexity contained in a Doc
resolved, making it very easy to convert to other formats, such as plaintext or terminal output.
Signature
export type DocStream<A> =
| FailedStream<A>
| EmptyStream<A>
| CharStream<A>
| TextStream<A>
| LineStream<A>
| PushAnnotationStream<A>
| PopAnnotationStream<A>
Added in v1.0.0
DocStreamTypeLambda (interface)
Signature
export interface DocStreamTypeLambda extends TypeLambda {
readonly type: DocStream<this["Target"]>
}
Added in v1.0.0
EmptyStream (interface)
Represents the an empty Doc
.
Signature
export interface EmptyStream<A> extends DocStream.Variance<A> {
readonly _tag: "EmptyStream"
}
Added in v1.0.0
FailedStream (interface)
Represents a Doc
that failed to be laid out.
Signature
export interface FailedStream<A> extends DocStream.Variance<A> {
readonly _tag: "FailedStream"
}
Added in v1.0.0
LineStream (interface)
Represents a Doc
containing a single line. The indentation
represents the indentation level for the subsequent line in the Doc
.
Signature
export interface LineStream<A> extends DocStream.Variance<A> {
readonly _tag: "LineStream"
readonly indentation: number
readonly stream: DocStream<A>
}
Added in v1.0.0
PopAnnotationStream (interface)
Represents the removal of a previously pushed annotation from a Doc
.
Signature
export interface PopAnnotationStream<A> extends DocStream.Variance<A> {
readonly _tag: "PopAnnotationStream"
readonly stream: DocStream<A>
}
Added in v1.0.0
PushAnnotationStream (interface)
Represents the addition of an annotation of type A
to a Doc
.
Signature
export interface PushAnnotationStream<A> extends DocStream.Variance<A> {
readonly _tag: "PushAnnotationStream"
readonly annotation: A
readonly stream: DocStream<A>
}
Added in v1.0.0
TextStream (interface)
Represents a Doc
containing a string of text.
Signature
export interface TextStream<A> extends DocStream.Variance<A> {
readonly _tag: "TextStream"
readonly text: string
readonly stream: DocStream<A>
}
Added in v1.0.0
refinements
isCharStream
Returns true
if the specified DocStream
is a CharStream
, false
otherwise.
Signature
export declare const isCharStream: <A>(self: DocStream<A>) => self is CharStream<A>
Added in v1.0.0
isDocStream
Returns true
if the specified value is a DocStream
, false
otherwise.
Signature
export declare const isDocStream: (u: unknown) => u is DocStream<unknown>
Added in v1.0.0
isEmptyStream
Returns true
if the specified DocStream
is a EmptyStream
, false
otherwise.
Signature
export declare const isEmptyStream: <A>(self: DocStream<A>) => self is EmptyStream<A>
Added in v1.0.0
isFailedStream
Returns true
if the specified DocStream
is a FailedStream
, false
otherwise.
Signature
export declare const isFailedStream: <A>(self: DocStream<A>) => self is FailedStream<A>
Added in v1.0.0
isLineStream
Returns true
if the specified DocStream
is a LineStream
, false
otherwise.
Signature
export declare const isLineStream: <A>(self: DocStream<A>) => self is LineStream<A>
Added in v1.0.0
isPopAnnotationStream
Returns true
if the specified DocStream
is a PopAnnotationStream
, false
otherwise.
Signature
export declare const isPopAnnotationStream: <A>(self: DocStream<A>) => self is PopAnnotationStream<A>
Added in v1.0.0
isPushAnnotationStream
Returns true
if the specified DocStream
is a PushAnnotationStream
, false
otherwise.
Signature
export declare const isPushAnnotationStream: <A>(self: DocStream<A>) => self is PushAnnotationStream<A>
Added in v1.0.0
isTextStream
Returns true
if the specified DocStream
is a TextStream
, false
otherwise.
Signature
export declare const isTextStream: <A>(self: DocStream<A>) => self is TextStream<A>
Added in v1.0.0
symbol
DocStreamTypeId
Signature
export declare const DocStreamTypeId: typeof DocStreamTypeId
Added in v1.0.0
DocStreamTypeId (type alias)
Signature
export type DocStreamTypeId = typeof DocStreamTypeId
Added in v1.0.0
utils
DocStream (namespace)
Added in v1.0.0
Variance (interface)
Signature
export interface Variance<A> extends Equal {
readonly [DocStreamTypeId]: {
readonly _A: (_: never) => A
}
}
Added in v1.0.0
TypeLambda (type alias)
Signature
export type TypeLambda = DocStreamTypeLambda
Added in v1.0.0