morphic-ts
Advanced tools
Comparing version
@@ -16,3 +16,3 @@ # Changelog | ||
## 0.8.0-rc.1 | ||
## 0.8.0-rc.2 | ||
@@ -19,0 +19,0 @@ - New Feature |
@@ -11,2 +11,3 @@ "use strict"; | ||
number: function (_) { return new __1.EqType(Eq_1.eqNumber); }, | ||
bigint: function (_) { return new __1.EqType({ equals: Eq_1.strictEqual }); }, | ||
stringLiteral: function (_) { return new __1.EqType(Eq_1.eqString); }, | ||
@@ -13,0 +14,0 @@ keysOf: function (_keys) { return new __1.EqType({ equals: Eq_1.strictEqual }); }, |
@@ -23,2 +23,5 @@ import { FastCheckURI } from '..'; | ||
} | ||
interface PrimitiveBigIntConfig { | ||
[FastCheckURI]: Customize<bigint> | undefined; | ||
} | ||
} | ||
@@ -25,0 +28,0 @@ interface MinMaxLength { |
@@ -13,2 +13,3 @@ "use strict"; | ||
number: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.float())); }, | ||
bigint: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.bigInt())); }, | ||
stringLiteral: function (l) { return new __1.FastCheckType(fast_check_1.constant(l)); }, | ||
@@ -15,0 +16,0 @@ keysOf: function (k) { return new __1.FastCheckType(fast_check_1.oneof.apply(void 0, Object.keys(k).map(function (k) { return fast_check_1.constant(k); }))); }, |
@@ -17,2 +17,5 @@ import * as t from 'io-ts'; | ||
} | ||
interface PrimitiveBigIntConfig { | ||
[IoTsURI]: Customize<string, bigint> | undefined; | ||
} | ||
interface PrimitiveBooleanConfig { | ||
@@ -28,3 +31,6 @@ [IoTsURI]: Customize<boolean, boolean> | undefined; | ||
} | ||
export interface BigIntStringC extends t.Type<bigint, string, unknown> { | ||
} | ||
export declare const BigIntString: BigIntStringC; | ||
export declare const ioTsPrimitiveInterpreter: ModelAlgebraPrimitive2<IoTsURI>; | ||
export {}; |
@@ -8,3 +8,17 @@ "use strict"; | ||
var function_1 = require("fp-ts/lib/function"); | ||
var Either_1 = require("fp-ts/lib/Either"); | ||
var applyCustomize = function (c) { var _a; return c !== undefined ? (_a = c[__1.IoTsURI], (_a !== null && _a !== void 0 ? _a : function_1.identity)) : function_1.identity; }; | ||
exports.BigIntString = new t.Type('BigIntString', | ||
// tslint:disable-next-line: strict-type-predicates valid-typeof | ||
function (u) { return u !== undefined && u !== null && typeof u === 'bigint'; }, function (u, c) { | ||
return Either_1.either.chain(t.string.validate(u, c), function (s) { | ||
try { | ||
var d = BigInt(s); | ||
return t.success(d); | ||
} | ||
catch (_a) { | ||
return t.failure(u, c); | ||
} | ||
}); | ||
}, function (a) { return a.toString(10); }); | ||
exports.ioTsPrimitiveInterpreter = { | ||
@@ -15,6 +29,7 @@ date: function (config) { return new __1.IOTSType(applyCustomize(config)(DateFromISOString_1.DateFromISOString)); }, | ||
number: function (config) { return new __1.IOTSType(applyCustomize(config)(t.number)); }, | ||
bigint: function (config) { return new __1.IOTSType(applyCustomize(config)(exports.BigIntString)); }, | ||
stringLiteral: function (l) { return new __1.IOTSType(t.literal(l, l)); }, | ||
keysOf: function (k, name) { return new __1.IOTSType(t.keyof(k, name)); }, | ||
keysOf: function (k) { return new __1.IOTSType(t.keyof(k)); }, | ||
nullable: function (T) { return new __1.IOTSType(optionFromNullable_1.optionFromNullable(T.type)); }, | ||
array: function (T, config) { return new __1.IOTSType(applyCustomize(config)(t.array(T.type))); } | ||
}; |
@@ -11,2 +11,3 @@ "use strict"; | ||
number: function (_) { return new __1.JsonSchema(StateEither_1.stateEither.of(json_schema_ctors_1.NumberTypeCtor())); }, | ||
bigint: function (_) { return new __1.JsonSchema(StateEither_1.stateEither.of(json_schema_ctors_1.StringTypeCtor({ format: 'bigint' }))); }, | ||
boolean: function (_) { return new __1.JsonSchema(StateEither_1.stateEither.of(json_schema_ctors_1.BooleanTypeCtor())); }, | ||
@@ -13,0 +14,0 @@ stringLiteral: function (v) { return new __1.JsonSchema(StateEither_1.stateEither.of(json_schema_ctors_1.LiteralTypeCtor(v))); }, |
@@ -33,3 +33,3 @@ import * as js from './json-schema'; | ||
export declare const StringTypeCtor: (extras?: { | ||
format?: "date-time" | "date" | undefined; | ||
format?: "bigint" | "date-time" | "date" | undefined; | ||
enum?: string[] | undefined; | ||
@@ -36,0 +36,0 @@ } | undefined) => OptionalJSONSchema; |
@@ -10,3 +10,3 @@ import * as m from 'monocle-ts'; | ||
maxLength?: number; | ||
format?: 'date-time' | 'date' | 'password' | 'byte' | 'binary'; | ||
format?: 'date-time' | 'date' | 'password' | 'byte' | 'binary' | 'bigint'; | ||
} | ||
@@ -16,3 +16,3 @@ export declare const StringSchema: (x?: { | ||
maxLength?: number | undefined; | ||
format?: "date-time" | "date" | "password" | "byte" | "binary" | undefined; | ||
format?: "bigint" | "date-time" | "date" | "password" | "byte" | "binary" | undefined; | ||
description?: string | undefined; | ||
@@ -19,0 +19,0 @@ } | undefined) => StringSchema; |
@@ -17,21 +17,27 @@ import { OfType, OfType2 } from '../common/core'; | ||
export interface ModelAlgebraIntersection<F> { | ||
intersection<A, B, LA, LB>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>], name: string): HKT2<F, LA & LB, A & B>; | ||
intersection<A, B, C, LA, LB, LC>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>], name: string): HKT2<F, LA & LB & LC, A & B & C>; | ||
intersection<A, B, C, D, LA, LB, LC, LD>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>], name: string): HKT2<F, LA & LB & LC & LD, A & B & C & D>; | ||
intersection<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>, HKT2<F, LE, E>], name: string): HKT2<F, LA & LB & LC & LD & LE, A & B & C & D & E>; | ||
intersection<L, A>(types: Array<HKT2<F, L, A>>): HKT2<F, Array<L>, Array<A>>; | ||
intersection: { | ||
<A, B, LA, LB>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>], name: string): HKT2<F, LA & LB, A & B>; | ||
<A, B, C, LA, LB, LC>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>], name: string): HKT2<F, LA & LB & LC, A & B & C>; | ||
<A, B, C, D, LA, LB, LC, LD>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>], name: string): HKT2<F, LA & LB & LC & LD, A & B & C & D>; | ||
<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>, HKT2<F, LE, E>], name: string): HKT2<F, LA & LB & LC & LD & LE, A & B & C & D & E>; | ||
<L, A>(types: Array<HKT2<F, L, A>>): HKT2<F, Array<L>, Array<A>>; | ||
}; | ||
} | ||
export interface ModelAlgebraIntersection1<F extends URIS> { | ||
intersection<A, B>(types: [OfType<F, A>, OfType<F, B>], name: string): Kind<F, A & B>; | ||
intersection<A, B, C>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>], name: string): Kind<F, A & B & C>; | ||
intersection<A, B, C, D>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>], name: string): Kind<F, A & B & C & D>; | ||
intersection<A, B, C, D, E>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>, OfType<F, E>], name: string): Kind<F, A & B & C & D & E>; | ||
intersection<A>(types: Array<OfType<F, A>>, name: string): Kind<F, Array<A>>; | ||
intersection: { | ||
<A, B>(types: [OfType<F, A>, OfType<F, B>], name: string): Kind<F, A & B>; | ||
<A, B, C>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>], name: string): Kind<F, A & B & C>; | ||
<A, B, C, D>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>], name: string): Kind<F, A & B & C & D>; | ||
<A, B, C, D, E>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>, OfType<F, E>], name: string): Kind<F, A & B & C & D & E>; | ||
<A>(types: Array<OfType<F, A>>, name: string): Kind<F, Array<A>>; | ||
}; | ||
} | ||
export interface ModelAlgebraIntersection2<F extends URIS2> { | ||
intersection<A, B, LA, LB>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>], name: string): Kind2<F, LA & LB, A & B>; | ||
intersection<A, B, C, LA, LB, LC>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>], name: string): Kind2<F, LA & LB & LC, A & B & C>; | ||
intersection<A, B, C, D, LA, LB, LC, LD>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>], name: string): Kind2<F, LA & LB & LC & LD, A & B & C & D>; | ||
intersection<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>, OfType2<F, LE, E>], name: string): Kind2<F, LA & LB & LC & LD & LE, A & B & C & D & E>; | ||
intersection<L, A>(types: Array<OfType2<F, L, A>>, name: string): Kind2<F, Array<L>, Array<A>>; | ||
intersection: { | ||
<A, B, LA, LB>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>], name: string): Kind2<F, LA & LB, A & B>; | ||
<A, B, C, LA, LB, LC>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>], name: string): Kind2<F, LA & LB & LC, A & B & C>; | ||
<A, B, C, D, LA, LB, LC, LD>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>], name: string): Kind2<F, LA & LB & LC & LD, A & B & C & D>; | ||
<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>, OfType2<F, LE, E>], name: string): Kind2<F, LA & LB & LC & LD & LE, A & B & C & D & E>; | ||
<L, A>(types: Array<OfType2<F, L, A>>, name: string): Kind2<F, Array<L>, Array<A>>; | ||
}; | ||
} |
@@ -23,4 +23,6 @@ import { URIS2, Kind2, URIS, Kind, HKT2 } from '../common/HKT'; | ||
export interface ModelAlgebraNewtype<F> { | ||
newtype<N extends AnyNewtype = never>(name: string): <E>(a: HKT2<F, E, NewtypeA<N>>) => isOptionalConfig<NewtypeConfig, HKT2<F, NewtypeA<N>, N>>; | ||
newtype<N extends AnyNewtype = never>(name: string): <E>(a: HKT2<F, E, NewtypeA<N>>, config: ByInterp<NewtypeConfig, URIS | URIS2>) => HKT2<F, E, N>; | ||
newtype: { | ||
<N extends AnyNewtype = never>(name: string): <E>(a: HKT2<F, E, NewtypeA<N>>) => isOptionalConfig<NewtypeConfig, HKT2<F, NewtypeA<N>, N>>; | ||
<N extends AnyNewtype = never>(name: string): <E>(a: HKT2<F, E, NewtypeA<N>>, config: ByInterp<NewtypeConfig, URIS | URIS2>) => HKT2<F, E, N>; | ||
}; | ||
} | ||
@@ -27,0 +29,0 @@ export interface ModelAlgebraNewtype1<F extends URIS> { |
@@ -23,22 +23,26 @@ import { URIS, Kind, URIS2, Kind2, HKT2 } from '../common/HKT'; | ||
export interface ModelAlgebraObject<F> { | ||
interface<Props extends AnyMProps<F>>(props: Props, name: string): isOptionalConfig<ObjectInterfaceConfig, HKT2<F, { | ||
[k in keyof Props]: Props[k]['_E']; | ||
}, { | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>; | ||
interface<Props extends AnyMProps<F>>(props: Props, name: string, config: ByInterp<ObjectInterfaceConfig, URIS | URIS2>): HKT2<F, { | ||
[k in keyof Props]: Props[k]['_E']; | ||
}, { | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>; | ||
partial<Props extends AnyMProps<F>>(props: Props, name: string): isOptionalConfig<ObjectPartialConfig, HKT2<F, Partial<{ | ||
[k in keyof Props]: Props[k]['_E']; | ||
}>, Partial<{ | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>>; | ||
partial<Props extends AnyMProps<F>>(props: Props, name: string, config: ByInterp<ObjectPartialConfig, URIS | URIS2>): HKT2<F, Partial<{ | ||
[k in keyof Props]: Props[k]['_E']; | ||
}>, Partial<{ | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>; | ||
interface: { | ||
<Props extends AnyMProps<F>>(props: Props, name: string): isOptionalConfig<ObjectInterfaceConfig, HKT2<F, { | ||
[k in keyof Props]: Props[k]['_E']; | ||
}, { | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>; | ||
<Props extends AnyMProps<F>>(props: Props, name: string, config: ByInterp<ObjectInterfaceConfig, URIS | URIS2>): HKT2<F, { | ||
[k in keyof Props]: Props[k]['_E']; | ||
}, { | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>; | ||
}; | ||
partial: { | ||
<Props extends AnyMProps<F>>(props: Props, name: string): isOptionalConfig<ObjectPartialConfig, HKT2<F, Partial<{ | ||
[k in keyof Props]: Props[k]['_E']; | ||
}>, Partial<{ | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>>; | ||
<Props extends AnyMProps<F>>(props: Props, name: string, config: ByInterp<ObjectPartialConfig, URIS | URIS2>): HKT2<F, Partial<{ | ||
[k in keyof Props]: Props[k]['_E']; | ||
}>, Partial<{ | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>; | ||
}; | ||
} | ||
@@ -45,0 +49,0 @@ export declare type PropsKind1<F extends URIS, PropsA> = { |
import { Option } from 'fp-ts/lib/Option'; | ||
import { URIS2, Kind2, URIS, Kind, HKT2 } from '../common/HKT'; | ||
import { PrimitiveArrayConfig, PrimitiveStringConfig, PrimitiveDateConfig, PrimitiveNumberConfig, PrimitiveBooleanConfig, PrimitiveArrayConfig2 } from '../algebras/hkt'; | ||
import { PrimitiveArrayConfig, PrimitiveStringConfig, PrimitiveDateConfig, PrimitiveNumberConfig, PrimitiveBooleanConfig, PrimitiveArrayConfig2, PrimitiveBigIntConfig, PrimitiveStringLiteralConfig, PrimitiveKeysOfConfig } from '../algebras/hkt'; | ||
import { ByInterp, isOptionalConfig } from '../common/core'; | ||
@@ -22,4 +22,10 @@ export declare type Keys = Record<string, null>; | ||
} | ||
interface PrimitiveStringLiteralConfig { | ||
} | ||
interface PrimitiveKeysOfConfig { | ||
} | ||
interface PrimitiveNumberConfig { | ||
} | ||
interface PrimitiveBigIntConfig { | ||
} | ||
interface PrimitiveBooleanConfig { | ||
@@ -38,12 +44,30 @@ } | ||
}; | ||
number(): isOptionalConfig<PrimitiveNumberConfig, HKT2<F, number, number>>; | ||
number(config: ByInterp<PrimitiveNumberConfig, URIS | URIS2>): HKT2<F, number, number>; | ||
string(): isOptionalConfig<PrimitiveStringConfig, HKT2<F, string, string>>; | ||
string(config: ByInterp<PrimitiveStringConfig, URIS | URIS2>): HKT2<F, string, string>; | ||
stringLiteral: <T extends string>(value: T) => HKT2<F, string, typeof value>; | ||
keysOf: <K extends Keys>(keys: K, name?: string) => HKT2<F, string, keyof typeof keys>; | ||
array<L, A>(a: HKT2<F, L, A>): isOptionalConfig<PrimitiveArrayConfig<A>, HKT2<F, Array<L>, Array<A>>>; | ||
array<L, A>(a: HKT2<F, L, A>, config: ByInterp<PrimitiveArrayConfig<A>, URIS | URIS2>): HKT2<F, Array<L>, Array<A>>; | ||
date(): isOptionalConfig<PrimitiveDateConfig, HKT2<F, string, Date>>; | ||
date(config: ByInterp<PrimitiveDateConfig, URIS | URIS2>): HKT2<F, string, Date>; | ||
number: { | ||
(): isOptionalConfig<PrimitiveNumberConfig, HKT2<F, number, number>>; | ||
(config: ByInterp<PrimitiveNumberConfig, URIS | URIS2>): HKT2<F, number, number>; | ||
}; | ||
bigint: { | ||
(): isOptionalConfig<PrimitiveBigIntConfig, HKT2<F, string, bigint>>; | ||
(config: ByInterp<PrimitiveBigIntConfig, URIS | URIS2>): HKT2<F, string, bigint>; | ||
}; | ||
string: { | ||
(): isOptionalConfig<PrimitiveStringConfig, HKT2<F, string, string>>; | ||
(config: ByInterp<PrimitiveStringConfig, URIS | URIS2>): HKT2<F, string, string>; | ||
}; | ||
stringLiteral: { | ||
<T extends string>(value: T): isOptionalConfig<PrimitiveStringLiteralConfig, HKT2<F, string, typeof value>>; | ||
<T extends string>(value: T, config: ByInterp<PrimitiveStringLiteralConfig, URIS | URIS2>): HKT2<F, string, typeof value>; | ||
}; | ||
keysOf: { | ||
<K extends Keys>(keys: K): isOptionalConfig<PrimitiveKeysOfConfig, HKT2<F, string, keyof typeof keys>>; | ||
<K extends Keys>(keys: K, config: ByInterp<PrimitiveKeysOfConfig, URIS | URIS2>): HKT2<F, string, keyof typeof keys>; | ||
}; | ||
array: { | ||
<L, A>(a: HKT2<F, L, A>): isOptionalConfig<PrimitiveArrayConfig<A>, HKT2<F, Array<L>, Array<A>>>; | ||
<L, A>(a: HKT2<F, L, A>, config: ByInterp<PrimitiveArrayConfig<A>, URIS | URIS2>): HKT2<F, Array<L>, Array<A>>; | ||
}; | ||
date: { | ||
(): isOptionalConfig<PrimitiveDateConfig, HKT2<F, string, Date>>; | ||
(config: ByInterp<PrimitiveDateConfig, URIS | URIS2>): HKT2<F, string, Date>; | ||
}; | ||
} | ||
@@ -54,5 +78,6 @@ export interface ModelAlgebraPrimitive1<F extends URIS> { | ||
number(config?: ByInterp<PrimitiveNumberConfig, F>): Kind<F, number>; | ||
bigint(config?: ByInterp<PrimitiveBigIntConfig, F>): Kind<F, bigint>; | ||
string(config?: ByInterp<PrimitiveStringConfig, F>): Kind<F, string>; | ||
stringLiteral: <T extends string>(value: T) => Kind<F, typeof value>; | ||
keysOf: <K extends Keys>(keys: K, name?: string) => Kind<F, keyof typeof keys>; | ||
keysOf: <K extends Keys>(keys: K, config?: ByInterp<PrimitiveStringConfig, F>) => Kind<F, keyof typeof keys>; | ||
array: <A>(a: Kind<F, A>, config?: ByInterp<PrimitiveArrayConfig<A>, F>) => Kind<F, Array<A>>; | ||
@@ -65,7 +90,8 @@ date(config?: ByInterp<PrimitiveDateConfig, F>): Kind<F, Date>; | ||
number(config?: ByInterp<PrimitiveNumberConfig, F>): Kind2<F, number, number>; | ||
bigint(config?: ByInterp<PrimitiveBigIntConfig, F>): Kind2<F, string, bigint>; | ||
string(config?: ByInterp<PrimitiveStringConfig, F>): Kind2<F, string, string>; | ||
stringLiteral: <T extends string>(value: T) => Kind2<F, string, typeof value>; | ||
keysOf: <K extends Keys>(keys: K, name?: string) => Kind2<F, string, keyof typeof keys>; | ||
keysOf: <K extends Keys>(keys: K, config?: ByInterp<PrimitiveStringConfig, F>) => Kind2<F, string, keyof typeof keys>; | ||
array: <L, A>(a: Kind2<F, L, A>, config?: ByInterp<PrimitiveArrayConfig2<L, A>, F>) => Kind2<F, Array<L>, Array<A>>; | ||
date(config?: ByInterp<PrimitiveDateConfig, F>): Kind2<F, string, Date>; | ||
} |
@@ -22,8 +22,10 @@ import { URIS2, Kind2, URIS, Kind, HKT2 } from '../common/HKT'; | ||
export interface ModelAlgebraRefined<F> { | ||
refined<E, A, N extends string, B extends { | ||
readonly [K in N]: symbol; | ||
}>(a: HKT2<F, E, A>, refinement: Refinement<A, Branded<A, B>>, name: N): isOptionalConfig<Refinedfig, HKT2<F, E, Branded<A, B>>>; | ||
refined<E, A, N extends string, B extends { | ||
readonly [K in N]: symbol; | ||
}>(a: HKT2<F, E, A>, refinement: Refinement<A, Branded<A, B>>, name: N, config: ByInterp<Refinedfig, URIS | URIS2>): HKT2<F, E, Branded<A, B>>; | ||
refined: { | ||
<E, A, N extends string, B extends { | ||
readonly [K in N]: symbol; | ||
}>(a: HKT2<F, E, A>, refinement: Refinement<A, Branded<A, B>>, name: N): isOptionalConfig<Refinedfig, HKT2<F, E, Branded<A, B>>>; | ||
<E, A, N extends string, B extends { | ||
readonly [K in N]: symbol; | ||
}>(a: HKT2<F, E, A>, refinement: Refinement<A, Branded<A, B>>, name: N, config: ByInterp<Refinedfig, URIS | URIS2>): HKT2<F, E, Branded<A, B>>; | ||
}; | ||
} | ||
@@ -30,0 +32,0 @@ export interface ModelAlgebraRefined1<F extends URIS> { |
@@ -35,8 +35,10 @@ import { URIS, Kind, URIS2, Kind2, HKT2 } from '../common/HKT'; | ||
export interface ModelAlgebraTaggedUnions<F> { | ||
taggedUnion<Tag extends string, Types extends TaggedTypes<F, Tag, any, any>>(tag: Tag, types: Types & { | ||
[o in keyof Types]: DecorateTag<Types[o], Tag, o>; | ||
}, name: string): isOptionalConfig<TaggedUnionConfig, HKT2<F, Types[keyof Types]['_E'], Types[keyof Types]['_A']>>; | ||
taggedUnion<Tag extends string, Types extends TaggedTypes<F, Tag, any, any>>(tag: Tag, types: Types & { | ||
[o in keyof Types]: DecorateTag<Types[o], Tag, o>; | ||
}, name: string, config: ByInterp<TaggedUnionConfig, URIS | URIS2>): HKT2<F, Types[keyof Types]['_E'], Types[keyof Types]['_A']>; | ||
taggedUnion: { | ||
<Tag extends string, Types extends TaggedTypes<F, Tag, any, any>>(tag: Tag, types: Types & { | ||
[o in keyof Types]: DecorateTag<Types[o], Tag, o>; | ||
}, name: string): isOptionalConfig<TaggedUnionConfig, HKT2<F, Types[keyof Types]['_E'], Types[keyof Types]['_A']>>; | ||
<Tag extends string, Types extends TaggedTypes<F, Tag, any, any>>(tag: Tag, types: Types & { | ||
[o in keyof Types]: DecorateTag<Types[o], Tag, o>; | ||
}, name: string, config: ByInterp<TaggedUnionConfig, URIS | URIS2>): HKT2<F, Types[keyof Types]['_E'], Types[keyof Types]['_A']>; | ||
}; | ||
} | ||
@@ -43,0 +45,0 @@ export declare type TaggedTypes1<F extends URIS, Tag extends string, O> = { |
@@ -17,22 +17,28 @@ import { OfType, OfType2 } from '../common/core'; | ||
export interface ModelAlgebraUnions<F> { | ||
union<A, B, LA, LB>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>], name: string): HKT2<F, LA | LB, A | B>; | ||
union<A, B, C, LA, LB, LC>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>], name: string): HKT2<F, LA | LB | LC, A | B | C>; | ||
union<A, B, C, D, LA, LB, LC, LD>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>], name: string): HKT2<F, LA | LB | LC | LD, A | B | C | D>; | ||
union<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>, HKT2<F, LE, E>], name: string): HKT2<F, LA | LB | LC | LD | LE, A | B | C | D | E>; | ||
union<L, A>(types: Array<HKT2<F, L, A>>, name: string): HKT2<F, Array<L>, Array<A>>; | ||
union: { | ||
<A, B, LA, LB>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>], name: string): HKT2<F, LA | LB, A | B>; | ||
<A, B, C, LA, LB, LC>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>], name: string): HKT2<F, LA | LB | LC, A | B | C>; | ||
<A, B, C, D, LA, LB, LC, LD>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>], name: string): HKT2<F, LA | LB | LC | LD, A | B | C | D>; | ||
<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [HKT2<F, LA, A>, HKT2<F, LB, B>, HKT2<F, LC, C>, HKT2<F, LD, D>, HKT2<F, LE, E>], name: string): HKT2<F, LA | LB | LC | LD | LE, A | B | C | D | E>; | ||
<L, A>(types: Array<HKT2<F, L, A>>, name: string): HKT2<F, Array<L>, Array<A>>; | ||
}; | ||
} | ||
export interface ModelAlgebraUnions1<F extends URIS> { | ||
union<A, B>(types: [OfType<F, A>, OfType<F, B>], name: string): Kind<F, A | B>; | ||
union<A, B, C>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>], name: string): Kind<F, A | B | C>; | ||
union<A, B, C, D>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>], name: string): Kind<F, A | B | C | D>; | ||
union<A, B, C, D, E>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>, OfType<F, E>], name: string): Kind<F, A | B | C | D | E>; | ||
union<A>(types: Array<OfType<F, A>>, name: string): Kind<F, Array<A>>; | ||
union: { | ||
<A, B>(types: [OfType<F, A>, OfType<F, B>], name: string): Kind<F, A | B>; | ||
<A, B, C>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>], name: string): Kind<F, A | B | C>; | ||
<A, B, C, D>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>], name: string): Kind<F, A | B | C | D>; | ||
<A, B, C, D, E>(types: [OfType<F, A>, OfType<F, B>, OfType<F, C>, OfType<F, D>, OfType<F, E>], name: string): Kind<F, A | B | C | D | E>; | ||
<A>(types: Array<OfType<F, A>>, name: string): Kind<F, Array<A>>; | ||
}; | ||
} | ||
export interface ModelAlgebraUnions2<F extends URIS2> { | ||
union<A, B, LA, LB>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>], name: string): Kind2<F, LA | LB, A | B>; | ||
union<A, B, C, LA, LB, LC>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>], name: string): Kind2<F, LA | LB | LC, A | B | C>; | ||
union<A, B, C, D, LA, LB, LC, LD>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>], name: string): Kind2<F, LA | LB | LC | LD, A | B | C | D>; | ||
union<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>, OfType2<F, LE, E>], name: string): Kind2<F, LA | LB | LC | LD | LE, A | B | C | D | E>; | ||
union<L, A>(types: Array<OfType2<F, L, A>>, name: string): Kind2<F, Array<L>, Array<A>>; | ||
union: { | ||
<A, B, LA, LB>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>], name: string): Kind2<F, LA | LB, A | B>; | ||
<A, B, C, LA, LB, LC>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>], name: string): Kind2<F, LA | LB | LC, A | B | C>; | ||
<A, B, C, D, LA, LB, LC, LD>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>], name: string): Kind2<F, LA | LB | LC | LD, A | B | C | D>; | ||
<A, B, C, D, E, LA, LB, LC, LD, LE>(types: [OfType2<F, LA, A>, OfType2<F, LB, B>, OfType2<F, LC, C>, OfType2<F, LD, D>, OfType2<F, LE, E>], name: string): Kind2<F, LA | LB | LC | LD | LE, A | B | C | D | E>; | ||
<L, A>(types: Array<OfType2<F, L, A>>, name: string): Kind2<F, Array<L>, Array<A>>; | ||
}; | ||
} | ||
export declare type ArrayType<X> = X extends Array<infer A> ? A : never; |
@@ -7,2 +7,3 @@ "use strict"; | ||
var __1 = require(".."); | ||
var Eq_1 = require("fp-ts/lib/Eq"); | ||
exports.ordPrimitiveInterpreter = { | ||
@@ -13,2 +14,3 @@ date: function (_) { return new __1.OrdType(Ord_1.ord.contramap(Ord_1.ordNumber, function (date) { return date.getTime(); })); }, | ||
number: function (_) { return new __1.OrdType(Ord_1.ordNumber); }, | ||
bigint: function (_) { return new __1.OrdType({ equals: Eq_1.strictEqual, compare: function (x, y) { return (x < y ? -1 : x > y ? 1 : 0); } }); }, | ||
stringLiteral: function (_) { return new __1.OrdType(Ord_1.ordString); }, | ||
@@ -15,0 +17,0 @@ keysOf: function (_keys) { return new __1.OrdType(Ord_1.ord.contramap(Ord_1.ordString, function (k) { return k; })); }, |
@@ -12,2 +12,3 @@ "use strict"; | ||
number: function (_) { return new __1.ShowType(Show_1.showNumber); }, | ||
bigint: function (_) { return new __1.ShowType({ show: function (a) { return JSON.stringify(a); } }); }, | ||
stringLiteral: function (_) { return new __1.ShowType(Show_1.showString); }, | ||
@@ -14,0 +15,0 @@ keysOf: function (_keys) { return new __1.ShowType(Show_1.showString); }, |
{ | ||
"name": "morphic-ts", | ||
"version": "0.8.0-rc.1", | ||
"version": "0.8.0-rc.2", | ||
"description": "Interpretable Generic Model Definition Encoding", | ||
@@ -5,0 +5,0 @@ "files": [ |
206451
1.4%3703
2.15%