DocStream
Annotations
alterAnnotations
Signature
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>;
};reAnnotate
Modify the annotations of a document.
Signature
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>;
};unAnnotate
Remove all annotations from a document.
Signature
declare const unAnnotate: <A>(self: DocStream<A>) => DocStream<never>;Constructors
Signature
declare const char: {
(char: string): <A>(self: DocStream<A>) => DocStream<A>;
<A>(self: DocStream<A>, char: string): DocStream<A>;
};Signature
declare const empty: DocStream<never>;Signature
declare const failed: DocStream<never>;Signature
declare const line: {
(indentation: number): <A>(self: DocStream<A>) => DocStream<A>;
<A>(self: DocStream<A>, indentation: number): DocStream<A>;
};popAnnotation
Signature
declare const popAnnotation: <A>(stream: DocStream<A>) => DocStream<A>;pushAnnotation
Signature
declare const pushAnnotation: {
<B>(annotation: B): <A>(self: DocStream<A>) => DocStream<B | A>;
<A, B>(self: DocStream<A>, annotation: B): DocStream<A | B>;
};Signature
declare const text: {
(text: string): <A>(self: DocStream<A>) => DocStream<A>;
<A>(self: DocStream<A>, text: string): DocStream<A>;
};Folding
Signature
declare const foldMap: {
<A, M>(M: Monoid<M>, f: (a: A) => M): (self: DocStream<A>) => M;
<A, M>(self: DocStream<A>, M: Monoid<M>, f: (a: A) => M): M;
};Signature
declare const match: {
<A, R>(patterns: {
readonly CharStream: (char: string, stream: DocStream<A>) => R;
readonly EmptyStream: () => R;
readonly FailedStream: () => R;
readonly LineStream: (indentation: number, stream: DocStream<A>) => R;
readonly PopAnnotationStream: (stream: DocStream<A>) => R;
readonly PushAnnotationStream: (annotation: A, stream: DocStream<A>) => R;
readonly TextStream: (text: string, stream: DocStream<A>) => R;
}): (self: DocStream<A>) => R;
<A, R>(
self: DocStream<A>,
patterns: {
readonly CharStream: (char: string, stream: DocStream<A>) => R;
readonly EmptyStream: () => R;
readonly FailedStream: () => R;
readonly LineStream: (indentation: number, stream: DocStream<A>) => R;
readonly PopAnnotationStream: (stream: DocStream<A>) => R;
readonly PushAnnotationStream: (annotation: A, stream: DocStream<A>) => R;
readonly TextStream: (text: string, stream: DocStream<A>) => R;
},
): R;
};Instances
Mapping
Model
CharStream interface
Represents a Doc containing a single character.
Signature
interface CharStream<A> extends Variance<A> {
readonly _tag: "CharStream";
readonly char: string;
readonly stream: DocStream<A>;
}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
type DocStream<A> =
| FailedStream<A>
| EmptyStream<A>
| CharStream<A>
| TextStream<A>
| LineStream<A>
| PushAnnotationStream<A>
| PopAnnotationStream<A>;DocStreamTypeLambda interface
Signature
interface DocStreamTypeLambda extends TypeLambda {
readonly type: DocStream<unknown>;
}EmptyStream interface
Represents the an empty Doc.
Signature
interface EmptyStream<A> extends Variance<A> {
readonly _tag: "EmptyStream";
}FailedStream interface
Represents a Doc that failed to be laid out.
Signature
interface FailedStream<A> extends Variance<A> {
readonly _tag: "FailedStream";
}LineStream interface
Represents a Doc containing a single line. The indentation represents the indentation level for the subsequent line in the Doc.
Signature
interface LineStream<A> extends Variance<A> {
readonly _tag: "LineStream";
readonly indentation: number;
readonly stream: DocStream<A>;
}PopAnnotationStream interface
Represents the removal of a previously pushed annotation from a Doc.
Signature
interface PopAnnotationStream<A> extends Variance<A> {
readonly _tag: "PopAnnotationStream";
readonly stream: DocStream<A>;
}PushAnnotationStream interface
Represents the addition of an annotation of type A to a Doc.
Signature
interface PushAnnotationStream<A> extends Variance<A> {
readonly _tag: "PushAnnotationStream";
readonly annotation: A;
readonly stream: DocStream<A>;
}TextStream interface
Represents a Doc containing a string of text.
Signature
interface TextStream<A> extends Variance<A> {
readonly _tag: "TextStream";
readonly stream: DocStream<A>;
readonly text: string;
}Other
Refinements
isCharStream
Returns true if the specified DocStream is a CharStream, false otherwise.
Signature
declare const isCharStream: <A>(self: DocStream<A>) => self is CharStream<A>;isDocStream
Returns true if the specified value is a DocStream, false otherwise.
Signature
declare const isDocStream: (u: unknown) => u is DocStream<unknown>;isEmptyStream
Returns true if the specified DocStream is a EmptyStream, false otherwise.
Signature
declare const isEmptyStream: <A>(self: DocStream<A>) => self is EmptyStream<A>;isFailedStream
Returns true if the specified DocStream is a FailedStream, false otherwise.
Signature
declare const isFailedStream: <A>(self: DocStream<A>) => self is FailedStream<A>;isLineStream
Returns true if the specified DocStream is a LineStream, false otherwise.
Signature
declare const isLineStream: <A>(self: DocStream<A>) => self is LineStream<A>;isPopAnnotationStream
Returns true if the specified DocStream is a PopAnnotationStream, false otherwise.
Signature
declare const isPopAnnotationStream: <A>(self: DocStream<A>) => self is PopAnnotationStream<A>;isPushAnnotationStream
Returns true if the specified DocStream is a PushAnnotationStream, false otherwise.
Signature
declare const isPushAnnotationStream: <A>(self: DocStream<A>) => self is PushAnnotationStream<A>;isTextStream
Returns true if the specified DocStream is a TextStream, false otherwise.
Signature
declare const isTextStream: <A>(self: DocStream<A>) => self is TextStream<A>;Symbol
DocStreamTypeId
Signature
declare const DocStreamTypeId: unique symbol;DocStreamTypeId type
Signature
type DocStreamTypeId = typeof DocStreamTypeId;
Changes the annotation of a document to a different annotation, or to none at all.