A histogram reading (cumulative buckets).
export class class HistogramDatumclass HistogramDatum {
_tag: 'Histogram';
id: string;
labels: { readonly [x: string]: string };
buckets: ReadonlyArray<HistogramBucket>;
count: number;
sum: number;
}
A histogram reading (cumulative buckets).
HistogramDatum extends import SchemaSchema.const TaggedClass: <HistogramDatum, {}>(identifier?: string) => {
<Tag, Fields>(tag: Tag, fields: Fields, annotations?: Schema.Annotations.Declaration<HistogramDatum, readonly [Schema.TaggedStruct<Tag, Fields>]> | undefined): Schema.Class<HistogramDatum, Schema.TaggedStruct<Tag, Fields>, {}>;
<Tag, S>(tag: Tag, schema: S, annotations?: Schema.Annotations.Declaration<HistogramDatum, readonly [Schema.Struct<{ [K in keyof ({
readonly _tag: Schema.tag<Tag>;
} & S["fields"])]: ({
readonly _tag: Schema.tag<Tag>;
} & S["fields"])[K]; }>]> | undefined): Schema.Class<...>;
}
Defines a schema-backed class with an automatically populated _tag field.
When to use
Use to define class instances that are validated by a schema and participate
in tagged union matching.
Details
The optional identifier parameter overrides the schema identifier;
it defaults to the tag value.
Example (Defining a tagged class)
import { Schema } from "effect"
class Circle extends Schema.TaggedClass<Circle>()("Circle", {
radius: Schema.Number
}) {}
const c = new Circle({ radius: 5 })
console.log(c._tag) // "Circle"
console.log(c.radius) // 5
TaggedClass<class HistogramDatumclass HistogramDatum {
_tag: 'Histogram';
id: string;
labels: { readonly [x: string]: string };
buckets: ReadonlyArray<HistogramBucket>;
count: number;
sum: number;
}
A histogram reading (cumulative buckets).
HistogramDatum>()("Histogram", {
id: Schema.String(property) id: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
id: import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.Effect<string, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String,
labels: Schema.$Record<
Schema.String,
Schema.String
>
(property) labels: {
Type: Record.Type<Key, Value>;
Encoded: Record.Encoded<Key, Value>;
DecodingServices: Record.DecodingServices<Key, Value>;
EncodingServices: Record.EncodingServices<Key, Value>;
Iso: Record.Iso<Key, Value>;
key: Key;
value: Value;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<{ readonly [x: string]: string; }, readonly []>) => Schema.$Record<Schema.String, Schema.String>;
annotateKey: (annotations: Schema.Annotations.Key<{ readonly [x: string]: string }>) => Schema.$Record<Schema.String, Schema.String>;
check: (checks_0: Check<{ readonly [x: string]: string }>, ...checks: Array<Check<{ readonly [x: string]: string }>>) => Schema.$Record<Schema.String, Schema.String>;
rebuild: (ast: Objects) => Schema.$Record<Schema.String, Schema.String>;
make: (input: { readonly [x: string]: string }, options?: Schema.MakeOptions) => { readonly [x: string]: string };
makeOption: (input: { readonly [x: string]: string }, options?: Schema.MakeOptions) => Option<{ readonly [x: string]: string }>;
makeEffect: (input: { readonly [x: string]: string }, options?: Schema.MakeOptions) => Effect.Effect<{ readonly [x: string]: string }, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
labels: const metricLabels: Schema.$Record<
Schema.String,
Schema.String
>
const metricLabels: {
Type: Record.Type<Key, Value>;
Encoded: Record.Encoded<Key, Value>;
DecodingServices: Record.DecodingServices<Key, Value>;
EncodingServices: Record.EncodingServices<Key, Value>;
Iso: Record.Iso<Key, Value>;
key: Key;
value: Value;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<{ readonly [x: string]: string; }, readonly []>) => Schema.$Record<Schema.String, Schema.String>;
annotateKey: (annotations: Schema.Annotations.Key<{ readonly [x: string]: string }>) => Schema.$Record<Schema.String, Schema.String>;
check: (checks_0: Check<{ readonly [x: string]: string }>, ...checks: Array<Check<{ readonly [x: string]: string }>>) => Schema.$Record<Schema.String, Schema.String>;
rebuild: (ast: Objects) => Schema.$Record<Schema.String, Schema.String>;
make: (input: { readonly [x: string]: string }, options?: Schema.MakeOptions) => { readonly [x: string]: string };
makeOption: (input: { readonly [x: string]: string }, options?: Schema.MakeOptions) => Option<{ readonly [x: string]: string }>;
makeEffect: (input: { readonly [x: string]: string }, options?: Schema.MakeOptions) => Effect.Effect<{ readonly [x: string]: string }, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
metricLabels,
buckets: Schema.$Array<typeof HistogramBucket>(property) buckets: {
Type: ReadonlyArray<S["Type"]>;
Encoded: ReadonlyArray<S["Encoded"]>;
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: ReadonlyArray<S["Iso"]>;
value: S;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<ReadonlyArray<HistogramBucket>, readonly []>) => Schema.$Array<typeof HistogramBucket>;
annotateKey: (annotations: Schema.Annotations.Key<ReadonlyArray<HistogramBucket>>) => Schema.$Array<typeof HistogramBucket>;
check: (checks_0: Check<ReadonlyArray<HistogramBucket>>, ...checks: Array<Check<ReadonlyArray<HistogramBucket>>>) => Schema.$Array<typeof HistogramBucket>;
rebuild: (ast: Arrays) => Schema.$Array<typeof HistogramBucket>;
make: (input: ReadonlyArray<HistogramBucket>, options?: Schema.MakeOptions) => ReadonlyArray<HistogramBucket>;
makeOption: (input: ReadonlyArray<HistogramBucket>, options?: Schema.MakeOptions) => Option<ReadonlyArray<HistogramBucket>>;
makeEffect: (input: ReadonlyArray<HistogramBucket>, options?: Schema.MakeOptions) => Effect.Effect<ReadonlyArray<HistogramBucket>, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
buckets: import SchemaSchema.Array<typeof HistogramBucket>(self: typeof HistogramBucket): Schema.$Array<typeof HistogramBucket>
export Array
Defines a ReadonlyArray schema for a given element schema.
Example (Defining an array of strings)
import { Schema } from "effect"
const schema = Schema.Array(Schema.String)
const result = Schema.decodeUnknownSync(schema)(["a", "b", "c"])
console.log(result)
// [ 'a', 'b', 'c' ]
Array(class HistogramBucketclass HistogramBucket {
Type: Self;
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
identifier: string;
fields: S["fields"];
mapFields: (f: (fields: { readonly le: Schema.Number; readonly count: Schema.Number }) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefined) => Schema.Struct<{ [K in keyof Readonly<To>]: Readonly<To>[K]; }>;
extend: (identifier: string) => { (fields: NewFields, annotations?: Schema.Annotations.Declaration<Extended, readonly [Schema.Struct<{ [K in keyof { [K in keyof (('le' | 'count') & keyof NewFields extends never ? { readonly le: Schema.Number; read…;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<HistogramBucket, readonly [Schema.Struct<{ readonly le: Schema.Number; readonly count: Schema.Number }>]>) => Schema.decodeTo<Schema.declareConstructor<HistogramBucket, Schema.Struct.ReadonlySide<{ r…;
annotateKey: (annotations: Schema.Annotations.Key<HistogramBucket>) => Schema.decodeTo<Schema.declareConstructor<HistogramBucket, Schema.Struct.ReadonlySide<{ readonly le: Schema.Number; readonly count: Schema.Number }, 'Encoded'>, readonly [Schema.Str…;
check: (checks_0: Check<HistogramBucket>, ...checks: Array<Check<HistogramBucket>>) => Schema.decodeTo<Schema.declareConstructor<HistogramBucket, Schema.Struct.ReadonlySide<{ readonly le: Schema.Number; readonly count: Schema.Number }, 'Encoded'>…;
rebuild: (ast: Declaration) => Schema.decodeTo<Schema.declareConstructor<HistogramBucket, Schema.Struct.ReadonlySide<{ readonly le: Schema.Number; readonly count: Schema.Number }, 'Encoded'>, readonly [Schema.Struct<{ readonly le: Schema.Number; re…;
make: (input: Schema.Struct.ReadonlyMakeIn<{ readonly le: Schema.Number; readonly count: Schema.Number }>, options?: Schema.MakeOptions) => HistogramBucket;
makeOption: (input: Schema.Struct.ReadonlyMakeIn<{ readonly le: Schema.Number; readonly count: Schema.Number }>, options?: Schema.MakeOptions) => Option<HistogramBucket>;
makeEffect: (input: Schema.Struct.ReadonlyMakeIn<{ readonly le: Schema.Number; readonly count: Schema.Number }>, options?: Schema.MakeOptions) => Effect.Effect<HistogramBucket, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
One cumulative histogram bucket: observations <= le.
HistogramBucket),
count: Schema.Number(property) count: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
count: import SchemaSchema.const Number: Schema.Numberconst Number: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
Number
.
Schema for number values, including NaN, Infinity, and -Infinity.
Details
Default JSON serializer:
- Finite numbers are serialized as numbers.
- Non-finite values are serialized as strings (
"NaN", "Infinity", "-Infinity").
Number,
sum: Schema.Number(property) sum: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
sum: import SchemaSchema.const Number: Schema.Numberconst Number: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<number, readonly []>) => Schema.Number;
annotateKey: (annotations: Schema.Annotations.Key<number>) => Schema.Number;
check: (checks_0: Check<number>, ...checks: Array<Check<number>>) => Schema.Number;
rebuild: (ast: Number) => Schema.Number;
make: (input: number, options?: Schema.MakeOptions) => number;
makeOption: (input: number, options?: Schema.MakeOptions) => Option<number>;
makeEffect: (input: number, options?: Schema.MakeOptions) => Effect.Effect<number, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
Number
.
Schema for number values, including NaN, Infinity, and -Infinity.
Details
Default JSON serializer:
- Finite numbers are serialized as numbers.
- Non-finite values are serialized as strings (
"NaN", "Infinity", "-Infinity").
Number,
}) {}