morphic-ts
Advanced tools
Comparing version
@@ -16,2 +16,8 @@ # Changelog | ||
## 0.8.0-rc.1 | ||
- New Feature | ||
- add Bigint (thanks @mikearnaldi) | ||
## 0.8.0-rc.0 | ||
@@ -18,0 +24,0 @@ |
@@ -36,3 +36,3 @@ import { Kind, URIS, URIS2, Kind2 } from './HKT'; | ||
export declare type MaybeUndefinedIfOptional<X> = keyof KeepNotUndefined<X> extends never ? X | undefined : X; | ||
export declare type isOptionalConfig<C, Y, N> = keyof KeepNotUndefined<ByInterp<C, URIS | URIS2>> extends never ? Y : N; | ||
export declare type isOptionalConfig<C, Y> = keyof KeepNotUndefined<ByInterp<C, URIS | URIS2>> extends never ? Y : 'config required'; | ||
/** | ||
@@ -55,3 +55,8 @@ * generates a config wrapper: | ||
*/ | ||
export declare const genConfig: <K extends typeof import("../fast-check-interpreters").FastCheckURI | typeof import("../json-schema-interpreters").JsonSchemaURI | typeof import("../eq-interpreters").EqURI | typeof import("../show-interpreters").ShowURI | typeof import("../ord-interpreters").OrdURI | typeof import("../io-ts-interpreters").IoTsURI>(k: K) => <T>(c: T extends { [k in K]?: infer C | undefined; } ? C : never) => T; | ||
export declare const genConfig: <Uri extends URIS | URIS2>(uri: Uri) => ConfigWrapper<Uri>; | ||
export interface ConfigWrapper<Uri extends URIS | URIS2> { | ||
<T>(config: T extends { | ||
[k in Uri]?: infer Config; | ||
} ? Config : never): T; | ||
} | ||
export {}; |
@@ -41,5 +41,5 @@ "use strict"; | ||
*/ | ||
exports.genConfig = function (k) { return function (c) { | ||
exports.genConfig = function (uri) { return function (config) { | ||
var _a; | ||
return (_a = {}, _a[k] = c, _a); | ||
return (_a = {}, _a[uri] = config, _a); | ||
}; }; |
@@ -13,4 +13,2 @@ import { Eq } from 'fp-ts/lib/Eq'; | ||
} | ||
export declare const eqConfig: <T>(c: T extends { | ||
[EqURI]?: infer C | undefined; | ||
} ? C : never) => T; | ||
export declare const eqConfig: import("../common/core").ConfigWrapper<typeof EqURI>; |
@@ -1,7 +0,7 @@ | ||
import * as fc from 'fast-check'; | ||
import { Arbitrary } from 'fast-check'; | ||
export declare const FastCheckURI: unique symbol; | ||
export declare type FastCheckURI = typeof FastCheckURI; | ||
export declare class FastCheckType<A> { | ||
arb: fc.Arbitrary<A>; | ||
constructor(arb: fc.Arbitrary<A>); | ||
arb: Arbitrary<A>; | ||
constructor(arb: Arbitrary<A>); | ||
} | ||
@@ -13,4 +13,2 @@ declare module '../common/HKT' { | ||
} | ||
export declare const fastCheckConfig: <T>(c: T extends { | ||
[FastCheckURI]?: infer C | undefined; | ||
} ? C : never) => T; | ||
export declare const fastCheckConfig: import("../common/core").ConfigWrapper<typeof FastCheckURI>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var fc = require("fast-check"); | ||
var fast_check_1 = require("fast-check"); | ||
var __1 = require(".."); | ||
exports.fastCheckIntersectionInterpreter = { | ||
intersection: function (items) { | ||
return new __1.FastCheckType(fc.genericTuple(items.map(function (_a) { | ||
return new __1.FastCheckType(fast_check_1.genericTuple(items.map(function (_a) { | ||
var arb = _a.arb; | ||
@@ -10,0 +10,0 @@ return arb; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var __1 = require(".."); | ||
var utils_1 = require("../../common/utils"); | ||
var fast_check_1 = require("fast-check"); | ||
exports.fastCheckObjectInterpreter = { | ||
partial: function (props) { | ||
return new __1.FastCheckType(fc.record(utils_1.projectField(props)('arb'), { | ||
return new __1.FastCheckType(fast_check_1.record(utils_1.projectField(props)('arb'), { | ||
withDeletedKeys: true | ||
@@ -13,4 +13,4 @@ })); | ||
interface: function (props) { | ||
return new __1.FastCheckType(fc.record(utils_1.projectField(props)('arb'))); | ||
return new __1.FastCheckType(fast_check_1.record(utils_1.projectField(props)('arb'))); | ||
} | ||
}; |
@@ -1,4 +0,4 @@ | ||
import * as fc from 'fast-check'; | ||
import { FastCheckURI } from '..'; | ||
import { ModelAlgebraPrimitive1 } from '../../model-algebras/primitives'; | ||
import { Arbitrary } from 'fast-check'; | ||
declare module '../../algebras/hkt' { | ||
@@ -29,5 +29,5 @@ interface PrimitiveArrayConfig<A> { | ||
interface Customize<A> { | ||
(a: fc.Arbitrary<A>): fc.Arbitrary<A>; | ||
(a: Arbitrary<A>): Arbitrary<A>; | ||
} | ||
export declare const fastCheckPrimitiveInterpreter: ModelAlgebraPrimitive1<FastCheckURI>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var __1 = require(".."); | ||
var Option_1 = require("fp-ts/lib/Option"); | ||
var function_1 = require("fp-ts/lib/function"); | ||
var fast_check_1 = require("fast-check"); | ||
var applyCustomize = function (c) { var _a; return c !== undefined ? (_a = c[__1.FastCheckURI], (_a !== null && _a !== void 0 ? _a : function_1.identity)) : function_1.identity; }; | ||
exports.fastCheckPrimitiveInterpreter = { | ||
date: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fc.integer().map(function (n) { return new Date(n); }))); }, | ||
boolean: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fc.boolean())); }, | ||
string: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fc.string())); }, | ||
number: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fc.float())); }, | ||
stringLiteral: function (l) { return new __1.FastCheckType(fc.constant(l)); }, | ||
keysOf: function (k) { return new __1.FastCheckType(fc.oneof.apply(fc, Object.keys(k).map(function (k) { return fc.constant(k); }))); }, | ||
nullable: function (T) { return new __1.FastCheckType(fc.option(T.arb).map(Option_1.fromNullable)); }, | ||
date: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.integer().map(function (n) { return new Date(n); }))); }, | ||
boolean: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.boolean())); }, | ||
string: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.string())); }, | ||
number: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.float())); }, | ||
stringLiteral: function (l) { return new __1.FastCheckType(fast_check_1.constant(l)); }, | ||
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); }))); }, | ||
nullable: function (T) { return new __1.FastCheckType(fast_check_1.option(T.arb).map(Option_1.fromNullable)); }, | ||
array: function (T, configs) { | ||
var _a; | ||
var config = configs !== undefined ? configs[__1.FastCheckURI] : undefined; | ||
return new __1.FastCheckType(config !== undefined ? fc.array(T.arb, (_a = config.minLength, (_a !== null && _a !== void 0 ? _a : 0)), config.maxLength) : fc.array(T.arb)); | ||
return new __1.FastCheckType(config !== undefined ? fast_check_1.array(T.arb, (_a = config.minLength, (_a !== null && _a !== void 0 ? _a : 0)), config.maxLength) : fast_check_1.array(T.arb)); | ||
} | ||
}; |
@@ -5,9 +5,9 @@ "use strict"; | ||
var utils_1 = require("../../common/utils"); | ||
var fc = require("fast-check"); | ||
var fast_check_1 = require("fast-check"); | ||
exports.fastCheckRecursiveInterpreter = { | ||
recursive: function (f) { | ||
var get = utils_1.memo(function () { return f(res); }); | ||
var res = new __1.FastCheckType(fc.constant(null).chain(function (_) { return get().arb; })); | ||
var res = new __1.FastCheckType(fast_check_1.constant(null).chain(function (_) { return get().arb; })); | ||
return res; | ||
} | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var fast_check_1 = require("fast-check"); | ||
var __1 = require(".."); | ||
var Set_1 = require("fp-ts/lib/Set"); | ||
exports.fastCheckSetInterpreter = { | ||
set: function (a, ord) { return new __1.FastCheckType(fc.set(a.arb).map(Set_1.fromArray(ord))); } | ||
set: function (a, ord) { return new __1.FastCheckType(fast_check_1.set(a.arb).map(Set_1.fromArray(ord))); } | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var __1 = require(".."); | ||
var fp_ts_1 = require("fp-ts"); | ||
var fast_check_1 = require("fast-check"); | ||
var strmapFromArray = function () { return fp_ts_1.record.fromFoldable(fp_ts_1.semigroup.getFirstSemigroup(), fp_ts_1.array.array); }; | ||
exports.fastCheckStrMapInterpreter = { | ||
strMap: function (codomain) { return new __1.FastCheckType(fc.array(fc.tuple(fc.string(), codomain.arb)).map(strmapFromArray())); } | ||
strMap: function (codomain) { return new __1.FastCheckType(fast_check_1.array(fast_check_1.tuple(fast_check_1.string(), codomain.arb)).map(strmapFromArray())); } | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var __1 = require(".."); | ||
var utils_1 = require("../../common/utils"); | ||
var fast_check_1 = require("fast-check"); | ||
/** | ||
@@ -10,3 +10,3 @@ * Beware: randomly generated recursive structure with high branching may not end early enough | ||
exports.fastCheckTaggedUnionInterpreter = { | ||
taggedUnion: function (_tag, dic) { return new __1.FastCheckType(fc.oneof.apply(fc, utils_1.collect(dic, function (_, _a) { | ||
taggedUnion: function (_tag, dic) { return new __1.FastCheckType(fast_check_1.oneof.apply(void 0, utils_1.collect(dic, function (_, _a) { | ||
var arb = _a.arb; | ||
@@ -13,0 +13,0 @@ return arb; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var __1 = require(".."); | ||
var fast_check_1 = require("fast-check"); | ||
exports.fastCheckUnionInterpreter = { | ||
union: function (items) { return new __1.FastCheckType(fc.oneof.apply(fc, items.map(function (v) { return v.arb; }))); } | ||
union: function (items) { return new __1.FastCheckType(fast_check_1.oneof.apply(void 0, items.map(function (v) { return v.arb; }))); } | ||
}; |
@@ -1,4 +0,4 @@ | ||
import * as fc from 'fast-check'; | ||
import { FastCheckURI } from '..'; | ||
import { ModelAlgebraUnknown1 } from '../../model-algebras/unknown'; | ||
import { Arbitrary } from 'fast-check'; | ||
declare module '../../algebras/hkt' { | ||
@@ -10,5 +10,5 @@ interface UnknownConfig { | ||
interface Customize<A> { | ||
(a: fc.Arbitrary<A>): fc.Arbitrary<A>; | ||
(a: Arbitrary<A>): Arbitrary<A>; | ||
} | ||
export declare const fastCheckUnknownInterpreter: ModelAlgebraUnknown1<FastCheckURI>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fc = require("fast-check"); | ||
var __1 = require(".."); | ||
var function_1 = require("fp-ts/lib/function"); | ||
var fast_check_1 = require("fast-check"); | ||
var applyCustomize = function (c) { var _a; return c !== undefined ? (_a = c[__1.FastCheckURI], (_a !== null && _a !== void 0 ? _a : function_1.identity)) : function_1.identity; }; | ||
exports.fastCheckUnknownInterpreter = { | ||
unknown: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fc.anything())); } | ||
unknown: function (configs) { return new __1.FastCheckType(applyCustomize(configs)(fast_check_1.anything())); } | ||
}; |
@@ -13,4 +13,2 @@ import * as t from 'io-ts'; | ||
} | ||
export declare const iotsConfig: <T>(c: T extends { | ||
[IoTsURI]?: infer C | undefined; | ||
} ? C : never) => T; | ||
export declare const iotsConfig: import("../common/core").ConfigWrapper<typeof IoTsURI>; |
@@ -21,4 +21,2 @@ import { OptionalJSONSchema, JsonSchemaError } from '../json-schema/json-schema-ctors'; | ||
} | ||
export declare const jsonSchemaConfig: <T>(c: T extends { | ||
[JsonSchemaURI]?: infer C | undefined; | ||
} ? C : never) => T; | ||
export declare const jsonSchemaConfig: import("../common/core").ConfigWrapper<typeof JsonSchemaURI>; |
@@ -20,4 +20,4 @@ "use strict"; | ||
var schema = _a.schema; | ||
return new __1.JsonSchema(StateEither_1.stateEither.chain(schema, function (v) { return SE.StateEither(json_schema_ctors_1.ArrayTypeCtor(v)); })); | ||
return new __1.JsonSchema(StateEither_1.stateEither.chain(schema, function (schemas) { return SE.StateEither(json_schema_ctors_1.ArrayTypeCtor({ schemas: schemas })); })); | ||
} | ||
}; |
@@ -15,7 +15,9 @@ "use strict"; | ||
var cache = utils_1.memo(function () { | ||
return pipeable_1.pipe(rec(new __1.JsonSchema(SE.stateEither.of(json_schema_ctors_1.notOptional(json_schema_1.Ref(name))))).schema, SE.chain(function (_) { | ||
return SE.fromPredicate(json_schema_1.isnotTypeRef, function (_) { | ||
return NonEmptyArray_1.nonEmptyArray.of(json_schema_ctors_1.JsonSchemaError('A type cannot be defined as a pure Ref')); | ||
})(_.json); | ||
}), SE.chain(utils_2.addSchema(name)), SE.chain(function (_) { return utils_2.getSchemaStrict(name); }), SE.map(json_schema_ctors_1.notOptional)); | ||
return pipeable_1.pipe(rec(new __1.JsonSchema(SE.stateEither.of(json_schema_ctors_1.notOptional(json_schema_1.Ref(name))))).schema, // call `rec` definition with brand new Ref (named as per the recursion) | ||
SE.chain(function (_) { | ||
return SE.fromPredicate(json_schema_1.isnotTypeRef, function (_) { return NonEmptyArray_1.nonEmptyArray.of(json_schema_ctors_1.JsonSchemaError('A type cannot be defined as a pure Ref')); } // A Ref should not be resolved as another Ref | ||
)(_.json); | ||
}), SE.chain(utils_2.addSchema(name)), // We add the newly created Schema to the dictionnary of Schemas | ||
SE.chain(function (_) { return utils_2.getSchemaStrict(name); }), // We resolve it and refuse to fail doing it | ||
SE.map(json_schema_ctors_1.notOptional)); | ||
}); | ||
@@ -22,0 +24,0 @@ return new __1.JsonSchema(cache()); |
@@ -15,3 +15,3 @@ import { OptionalJSONSchema, JsonSchemaError } from '../json-schema/json-schema-ctors'; | ||
export declare const resolveRefJsonSchema: (s: SubSchema) => SE.StateEither<NamedSchemas, NonEmptyArray<JsonSchemaError>, JSONSchema>; | ||
export declare const resolveSubSchema: (ns: NamedSchemas) => (ref: SubSchema) => O.Option<JSONSchema>; | ||
export declare const resolveSubSchema: (ns: NamedSchemas, ref: SubSchema) => O.Option<JSONSchema>; | ||
export declare const resolveSchema: ([{ json }, dic]: [OptionalJSONSchema, NamedSchemas]) => E.Either<NonEmptyArray<JsonSchemaError>, [JSONSchema, NamedSchemas]>; |
@@ -33,8 +33,8 @@ "use strict"; | ||
}; | ||
exports.resolveSubSchema = function (ns) { return function (ref) { | ||
exports.resolveSubSchema = function (ns, ref) { | ||
return json_schema_1.isTypeRef(ref) ? fp_ts_1.record.lookup(ref.$ref, ns) : O.some(ref); | ||
}; }; | ||
}; | ||
exports.resolveSchema = function (_a) { | ||
var json = _a[0].json, dic = _a[1]; | ||
return pipeable_1.pipe(exports.resolveSubSchema(dic)(json), O.map(function (j) { return function_1.tuple(j, dic); }), E.fromOption(function () { return fp_ts_1.nonEmptyArray.of(json_schema_ctors_1.JsonSchemaError('cannot resolve ref ')); })); | ||
return pipeable_1.pipe(exports.resolveSubSchema(dic, json), O.map(function (j) { return function_1.tuple(j, dic); }), E.fromOption(function () { return fp_ts_1.nonEmptyArray.of(json_schema_ctors_1.JsonSchemaError('cannot resolve ref ')); })); | ||
}; |
@@ -18,3 +18,7 @@ import * as js from './json-schema'; | ||
export declare const makePartialOptionalJsonObject: Endomorphism<OptionalJSONSchema>; | ||
export declare const ArrayTypeCtor: ({ optional, json }: OptionalJSONSchema) => import("fp-ts/lib/Either").Left<NEA.NonEmptyArray<JsonSchemaError>> | import("fp-ts/lib/Either").Right<OptionalJSONSchema>; | ||
export declare const ArrayTypeCtor: ({ schemas, ...rest }: { | ||
schemas: OptionalJSONSchema | OptionalJSONSchema[]; | ||
minItems?: number | undefined; | ||
maxItems?: number | undefined; | ||
}) => import("fp-ts/lib/Either").Left<NEA.NonEmptyArray<JsonSchemaError>> | import("fp-ts/lib/Either").Right<OptionalJSONSchema>; | ||
export declare const SetFromArrayTypeCtor: ({ optional, json }: OptionalJSONSchema) => import("fp-ts/lib/Either").Left<NEA.NonEmptyArray<JsonSchemaError>> | import("fp-ts/lib/Either").Right<OptionalJSONSchema>; | ||
@@ -21,0 +25,0 @@ export declare const StrMapTypeCtor: ({ optional, json }: OptionalJSONSchema) => import("fp-ts/lib/Either").Left<NEA.NonEmptyArray<JsonSchemaError>> | import("fp-ts/lib/Either").Right<OptionalJSONSchema>; |
@@ -26,9 +26,9 @@ "use strict"; | ||
exports.ArrayTypeCtor = function (_a) { | ||
var optional = _a.optional, json = _a.json; | ||
return optional | ||
var schemas = _a.schemas, rest = tslib_1.__rest(_a, ["schemas"]); | ||
var schemasArr = Array.isArray(schemas) ? schemas : [schemas]; | ||
var anyOptional = A.array.reduceRight(schemasArr, false, function (a, b) { return a.optional || b; }); | ||
var items = schemasArr.map(function (_) { return _.json; }); | ||
return anyOptional | ||
? Either_1.left(fp_ts_1.nonEmptyArray.of(exports.JsonSchemaErrors.ArrayConsumesNoOptional)) | ||
: Either_1.right(exports.notOptional({ | ||
type: 'array', | ||
items: json | ||
})); | ||
: Either_1.right(exports.notOptional(tslib_1.__assign({ type: 'array', items: items.length === 1 ? items[0] : items }, rest))); | ||
}; | ||
@@ -35,0 +35,0 @@ exports.SetFromArrayTypeCtor = function (_a) { |
@@ -57,7 +57,15 @@ import * as m from 'monocle-ts'; | ||
export declare const ArraySchema: (p: { | ||
items: SubSchema; | ||
items: StringSchema | NumberSchema | BooleanSchema | ArraySchema | ObjectSchema | (EnumSchema & { | ||
$schema?: string | undefined; | ||
}) | Ref | SubSchema[]; | ||
description?: string | undefined; | ||
minItems?: number | undefined; | ||
maxItems?: number | undefined; | ||
}) => { | ||
items: SubSchema; | ||
items: StringSchema | NumberSchema | BooleanSchema | ArraySchema | ObjectSchema | (EnumSchema & { | ||
$schema?: string | undefined; | ||
}) | Ref | SubSchema[]; | ||
description?: string | undefined; | ||
minItems?: number | undefined; | ||
maxItems?: number | undefined; | ||
type: "array"; | ||
@@ -64,0 +72,0 @@ }; |
@@ -23,3 +23,3 @@ 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>, 'Requiring some config via newtype({ <Interp>: ... })'>; | ||
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>; | ||
@@ -26,0 +26,0 @@ } |
@@ -27,3 +27,3 @@ import { URIS, Kind, URIS2, Kind2, HKT2 } from '../common/HKT'; | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>, 'Requiring some config via interface(..., { <Interp>: ... })'>; | ||
}>>; | ||
interface<Props extends AnyMProps<F>>(props: Props, name: string, config: ByInterp<ObjectInterfaceConfig, URIS | URIS2>): HKT2<F, { | ||
@@ -38,3 +38,3 @@ [k in keyof Props]: Props[k]['_E']; | ||
[k in keyof Props]: Props[k]['_A']; | ||
}>>, 'Requiring some config via partial(..., { <Interp>: ... })'>; | ||
}>>>; | ||
partial<Props extends AnyMProps<F>>(props: Props, name: string, config: ByInterp<ObjectPartialConfig, URIS | URIS2>): HKT2<F, Partial<{ | ||
@@ -41,0 +41,0 @@ [k in keyof Props]: Props[k]['_E']; |
@@ -32,35 +32,37 @@ import { Option } from 'fp-ts/lib/Option'; | ||
export interface ModelAlgebraPrimitive<F> { | ||
date(): isOptionalConfig<PrimitiveDateConfig, HKT2<F, string, Date>, 'Requiring some config via date({ <Interp>: ... })'>; | ||
date(config: ByInterp<PrimitiveDateConfig, URIS | URIS2>): HKT2<F, string, Date>; | ||
string(): isOptionalConfig<PrimitiveStringConfig, HKT2<F, string, string>, 'Requiring some config via string({ <Interp>: ... })'>; | ||
nullable: <L, A>(T: HKT2<F, L, A>) => HKT2<F, null | L, Option<A>>; | ||
boolean: { | ||
(): isOptionalConfig<PrimitiveBooleanConfig, HKT2<F, boolean, boolean>>; | ||
(config: ByInterp<PrimitiveBooleanConfig, URIS | URIS2>): HKT2<F, boolean, boolean>; | ||
}; | ||
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>; | ||
number(): isOptionalConfig<PrimitiveNumberConfig, HKT2<F, number, number>, 'Requiring some config via number({ <Interp>: ... })'>; | ||
number(config: ByInterp<PrimitiveNumberConfig, URIS | URIS2>): HKT2<F, number, number>; | ||
boolean(): isOptionalConfig<PrimitiveBooleanConfig, HKT2<F, boolean, boolean>, 'Requiring some config via boolean({ <Interp>: ... })'>; | ||
boolean(config: ByInterp<PrimitiveBooleanConfig, URIS | URIS2>): HKT2<F, boolean, boolean>; | ||
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>; | ||
nullable: <L, A>(T: HKT2<F, L, A>) => HKT2<F, null | L, Option<A>>; | ||
array<L, A>(a: HKT2<F, L, A>): isOptionalConfig<PrimitiveArrayConfig<A>, HKT2<F, Array<L>, Array<A>>, 'Requiring some config via array({ <Interp>: ... })'>; | ||
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>; | ||
} | ||
export interface ModelAlgebraPrimitive1<F extends URIS> { | ||
date(config?: ByInterp<PrimitiveDateConfig, F>): Kind<F, Date>; | ||
nullable: <A>(T: Kind<F, A>) => Kind<F, Option<A>>; | ||
boolean(config?: ByInterp<PrimitiveBooleanConfig, F>): Kind<F, boolean>; | ||
number(config?: ByInterp<PrimitiveNumberConfig, F>): Kind<F, number>; | ||
string(config?: ByInterp<PrimitiveStringConfig, F>): Kind<F, string>; | ||
number(config?: ByInterp<PrimitiveNumberConfig, F>): Kind<F, number>; | ||
boolean(config?: ByInterp<PrimitiveBooleanConfig, F>): Kind<F, boolean>; | ||
stringLiteral: <T extends string>(value: T) => Kind<F, typeof value>; | ||
keysOf: <K extends Keys>(keys: K, name?: string) => Kind<F, keyof typeof keys>; | ||
nullable: <A>(T: Kind<F, A>) => Kind<F, Option<A>>; | ||
array: <A>(a: Kind<F, A>, config?: ByInterp<PrimitiveArrayConfig<A>, F>) => Kind<F, Array<A>>; | ||
date(config?: ByInterp<PrimitiveDateConfig, F>): Kind<F, Date>; | ||
} | ||
export interface ModelAlgebraPrimitive2<F extends URIS2> { | ||
date(config?: ByInterp<PrimitiveDateConfig, F>): Kind2<F, string, Date>; | ||
nullable: <L, A>(T: Kind2<F, L, A>) => Kind2<F, null | L, Option<A>>; | ||
boolean(config?: ByInterp<PrimitiveBooleanConfig, F>): Kind2<F, boolean, boolean>; | ||
number(config?: ByInterp<PrimitiveNumberConfig, F>): Kind2<F, number, number>; | ||
string(config?: ByInterp<PrimitiveStringConfig, F>): Kind2<F, string, string>; | ||
number(config?: ByInterp<PrimitiveNumberConfig, F>): Kind2<F, number, number>; | ||
boolean(config?: ByInterp<PrimitiveBooleanConfig, F>): Kind2<F, boolean, boolean>; | ||
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>; | ||
nullable: <L, A>(T: Kind2<F, L, A>) => Kind2<F, null | L, Option<A>>; | ||
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>; | ||
} |
@@ -24,3 +24,3 @@ import { URIS2, Kind2, URIS, Kind, HKT2 } from '../common/HKT'; | ||
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>>, 'Requiring some config via refined({ <Interp>: ... })'>; | ||
}>(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 { | ||
@@ -27,0 +27,0 @@ readonly [K in N]: symbol; |
@@ -37,3 +37,3 @@ import { URIS, Kind, URIS2, Kind2, HKT2 } from '../common/HKT'; | ||
[o in keyof Types]: DecorateTag<Types[o], Tag, o>; | ||
}, name: string): isOptionalConfig<TaggedUnionConfig, HKT2<F, Types[keyof Types]['_E'], Types[keyof Types]['_A']>, 'Requiring some config via taggedUnion(..., { <Interp>: ... })'>; | ||
}, 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 & { | ||
@@ -40,0 +40,0 @@ [o in keyof Types]: DecorateTag<Types[o], Tag, o>; |
@@ -21,4 +21,6 @@ import { URIS2, Kind2, URIS, Kind, HKT2 } from '../common/HKT'; | ||
export interface ModelAlgebraUnknown<F> { | ||
unknown(): isOptionalConfig<UnknownConfig, HKT2<F, unknown, unknown>, 'Requiring some config via unknown({ <Interp>: ... })'>; | ||
unknown(config: ByInterp<UnknownConfig, URIS | URIS2>): HKT2<F, unknown, unknown>; | ||
unknown: { | ||
(): isOptionalConfig<UnknownConfig, HKT2<F, unknown, unknown>>; | ||
(config?: ByInterp<UnknownConfig, URIS | URIS2>): HKT2<F, unknown, unknown>; | ||
}; | ||
} | ||
@@ -25,0 +27,0 @@ export interface ModelAlgebraUnknown1<F extends URIS> { |
@@ -13,4 +13,2 @@ import { Ord } from 'fp-ts/lib/Ord'; | ||
} | ||
export declare const ordConfig: <T>(c: T extends { | ||
[OrdURI]?: infer C | undefined; | ||
} ? C : never) => T; | ||
export declare const ordConfig: import("../common/core").ConfigWrapper<typeof OrdURI>; |
@@ -13,4 +13,2 @@ import { Show } from 'fp-ts/lib/Show'; | ||
} | ||
export declare const showConfig: <T>(c: T extends { | ||
[ShowURI]?: infer C | undefined; | ||
} ? C : never) => T; | ||
export declare const showConfig: import("../common/core").ConfigWrapper<typeof ShowURI>; |
{ | ||
"name": "morphic-ts", | ||
"version": "0.8.0-rc.0", | ||
"version": "0.8.0-rc.1", | ||
"description": "Interpretable Generic Model Definition Encoding", | ||
@@ -5,0 +5,0 @@ "files": [ |
203591
0.28%3625
0.28%