@ark/schema
Advanced tools
Comparing version 0.29.0 to 0.30.0
@@ -41,3 +41,5 @@ import { Callable, type array, type Hkt, type JsonStructure } from "@ark/util"; | ||
baseInstantiation: BaseRoot; | ||
constructor(paramDefs: array<GenericParamDef>, bodyDef: bodyDef, $: BaseScope, arg$: BaseScope); | ||
hkt: Hkt.constructor | null; | ||
description: string; | ||
constructor(paramDefs: array<GenericParamDef>, bodyDef: bodyDef, $: BaseScope, arg$: BaseScope, hkt: Hkt.constructor | null); | ||
defIsLazy(): this is GenericRoot<params, LazyGenericBody>; | ||
@@ -44,0 +46,0 @@ protected cacheGetter<name extends keyof this>(name: name, value: this[name]): this[name]; |
import { Callable, flatMorph, snapshot, throwParseError } from "@ark/util"; | ||
import { $ark } from "./shared/registry.js"; | ||
import { arkKind } from "./shared/utils.js"; | ||
export const parseGeneric = (paramDefs, bodyDef, $) => new GenericRoot(paramDefs, bodyDef, $, $); | ||
export const parseGeneric = (paramDefs, bodyDef, $) => new GenericRoot(paramDefs, bodyDef, $, $, null); | ||
export class LazyGenericBody extends Callable { | ||
@@ -14,3 +14,5 @@ } | ||
baseInstantiation; | ||
constructor(paramDefs, bodyDef, $, arg$) { | ||
hkt; | ||
description; | ||
constructor(paramDefs, bodyDef, $, arg$, hkt) { | ||
super((...args) => { | ||
@@ -34,2 +36,7 @@ const argNodes = flatMorph(this.names, (i, name) => { | ||
this.arg$ = arg$; | ||
this.hkt = hkt; | ||
this.description = | ||
hkt ? | ||
(new hkt().description ?? `a generic type for ${hkt.constructor.name}`) | ||
: "a generic type"; | ||
this.baseInstantiation = this(...this.constraints); | ||
@@ -36,0 +43,0 @@ } |
@@ -91,3 +91,3 @@ import { ParseError, flatMorph, hasDomain, isArray, isThunk, printable, throwInternalError, throwParseError } from "@ark/util"; | ||
const $ = this; | ||
return (def, possibleHkt) => new GenericRoot(params, possibleHkt ? new LazyGenericBody(def) : def, $, $); | ||
return (def, possibleHkt) => new GenericRoot(params, possibleHkt ? new LazyGenericBody(def) : def, $, $, possibleHkt ?? null); | ||
}; | ||
@@ -157,3 +157,3 @@ units = (values, opts) => { | ||
new reference.constructor(reference.attachments, this) | ||
: new GenericRoot(reference.params, reference.bodyDef, reference.$, this); | ||
: new GenericRoot(reference.params, reference.bodyDef, reference.$, this, reference.hkt); | ||
if (!this.resolved) { | ||
@@ -160,0 +160,0 @@ // we're still parsing the scope itself, so defer compilation but |
{ | ||
"name": "@ark/schema", | ||
"version": "0.29.0", | ||
"version": "0.30.0", | ||
"license": "MIT", | ||
@@ -32,3 +32,3 @@ "author": { | ||
"dependencies": { | ||
"@ark/util": "0.29.0" | ||
"@ark/util": "0.30.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "publishConfig": { |
359702
8403
+ Added@ark/util@0.30.0(transitive)
- Removed@ark/util@0.29.0(transitive)
Updated@ark/util@0.30.0