readonly encode: (
...typeParameters: { readonly [K in keyof P]: Schema, Schema.Encoded, never> }
) => (
input: unknown,
options: ParseOptions,
ast: AST.Declaration
) => Effect.Effect
},
annotations?: Annotations.Schema }>
): declare
} = function() {
if (Array.isArray(arguments[0])) {
const typeParameters = arguments[0]
const options = arguments[1]
const annotations = arguments[2]
return declareConstructor(typeParameters, options, annotations)
}
const is = arguments[0]
const annotations = arguments[1]
return declarePrimitive(is, annotations)
} as any
/**
* @category schema id
* @since 3.10.0
*/
export const BrandSchemaId: unique symbol = Symbol.for("effect/SchemaId/Brand")
/**
* @category constructors
* @since 3.10.0
*/
export const fromBrand = , A extends Brand.Unbranded>(
constructor: Brand.Constructor,
annotations?: Annotations.Filter
) =>
(self: Schema): BrandSchema => {
const out = makeBrandClass(
self,
new AST.Refinement(
self.ast,
function predicate(a: A, _: ParseOptions, ast: AST.AST): option_.Option {
const either = constructor.either(a)
return either_.isLeft(either) ?
option_.some(new ParseResult.Type(ast, a, either.left.map((v) => v.message).join(", "))) :
option_.none()
},
toASTAnnotations({
schemaId: BrandSchemaId,
[BrandSchemaId]: { constructor },
...annotations
})
)
)
return out as any
}
/**
* @category schema id
* @since 3.10.0
*/
export const InstanceOfSchemaId: unique symbol = Symbol.for("effect/SchemaId/InstanceOf")
/**
* @category api interface
* @since 3.10.0
*/
export interface instanceOf extends AnnotableDeclare, A> {}
/**
* @category constructors
* @since 3.10.0
*/
export const instanceOf = any>(
constructor: A,
annotations?: Annotations.Schema>
): instanceOf> =>
declare(
(u): u is InstanceType => u instanceof constructor,
{
title: constructor.name,
description: `an instance of ${constructor.name}`,
pretty: (): pretty_.Pretty> => String,
schemaId: InstanceOfSchemaId,
[InstanceOfSchemaId]: { constructor },
...annotations
}
)
/**
* @category primitives
* @since 3.10.0
*/
export class Undefined extends make(AST.undefinedKeyword) {}
/**
* @category primitives
* @since 3.10.0
*/
export class Void extends make(AST.voidKeyword) {}
/**
* @category primitives
* @since 3.10.0
*/
export class Null extends make(AST.null) {}
/**
* @category primitives
* @since 3.10.0
*/
export class Never extends make(AST.neverKeyword) {}
/**
* @category primitives
* @since 3.10.0
*/
export class Unknown extends make(AST.unknownKeyword) {}
/**
* @category primitives
* @since 3.10.0
*/
export class Any extends make(AST.anyKeyword) {}
/**
* @category primitives
* @since 3.10.0
*/
export class BigIntFromSelf extends make(AST.bigIntKeyword) {}
/**
* @category primitives
* @since 3.10.0
*/
export class SymbolFromSelf extends make(AST.symbolKeyword) {}
/** @ignore */
class String$ extends make(AST.stringKeyword) {}
/** @ignore */
class Number$ extends make(AST.numberKeyword) {}
/** @ignore */
class Boolean$ extends make(AST.booleanKeyword) {}
/** @ignore */
class Object$ extends make