|
1368 | 1368 | "takes a spec and returns a spec that has the same properties except
|
1369 | 1369 | 'conform' returns the original (not the conformed) value. Note, will specize regex ops."
|
1370 | 1370 | [spec]
|
1371 |
| - (let [spec (specize spec)] |
| 1371 | + (let [spec (delay (specize spec))] |
1372 | 1372 | (reify
|
1373 | 1373 | Specize
|
1374 | 1374 | (specize* [s] s)
|
1375 | 1375 | (specize* [s _] s)
|
1376 | 1376 |
|
1377 | 1377 | Spec
|
1378 |
| - (conform* [_ x] (let [ret (conform* spec x)] |
| 1378 | + (conform* [_ x] (let [ret (conform* @spec x)] |
1379 | 1379 | (if (invalid? ret)
|
1380 | 1380 | ::invalid
|
1381 | 1381 | x)))
|
1382 |
| - (unform* [_ x] (unform* spec x)) |
1383 |
| - (explain* [_ path via in x] (explain* spec path via in x)) |
1384 |
| - (gen* [_ overrides path rmap] (gen* spec overrides path rmap)) |
1385 |
| - (with-gen* [_ gfn] (nonconforming (with-gen* spec gfn))) |
1386 |
| - (describe* [_] `(nonconforming ~(describe* spec)))))) |
| 1382 | + (unform* [_ x] (unform* @spec x)) |
| 1383 | + (explain* [_ path via in x] (explain* @spec path via in x)) |
| 1384 | + (gen* [_ overrides path rmap] (gen* @spec overrides path rmap)) |
| 1385 | + (with-gen* [_ gfn] (nonconforming (with-gen* @spec gfn))) |
| 1386 | + (describe* [_] `(nonconforming ~(describe* @spec)))))) |
1387 | 1387 |
|
1388 | 1388 | (defn ^:skip-wiki nilable-impl
|
1389 | 1389 | "Do not call this directly, use 'nilable'"
|
1390 | 1390 | [form pred gfn]
|
1391 |
| - (let [spec (specize pred form)] |
| 1391 | + (let [spec (delay (specize pred form))] |
1392 | 1392 | (reify
|
1393 | 1393 | Specize
|
1394 | 1394 | (specize* [s] s)
|
1395 | 1395 | (specize* [s _] s)
|
1396 | 1396 |
|
1397 | 1397 | Spec
|
1398 |
| - (conform* [_ x] (if (nil? x) nil (conform* spec x))) |
1399 |
| - (unform* [_ x] (if (nil? x) nil (unform* spec x))) |
| 1398 | + (conform* [_ x] (if (nil? x) nil (conform* @spec x))) |
| 1399 | + (unform* [_ x] (if (nil? x) nil (unform* @spec x))) |
1400 | 1400 | (explain* [_ path via in x]
|
1401 |
| - (when-not (c/or (pvalid? spec x) (nil? x)) |
| 1401 | + (when-not (c/or (pvalid? @spec x) (nil? x)) |
1402 | 1402 | (conj
|
1403 | 1403 | (explain-1 form pred (conj path ::pred) via in x)
|
1404 | 1404 | {:path (conj path ::nil) :pred 'nil? :val x :via via :in in})))
|
|
0 commit comments