functionalscript 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/fjs/asn.1/module.f.mjs +8 -1
- package/fjs/asn.1/proof.f.d.mts +15 -0
- package/fjs/asn.1/proof.f.mjs +31 -3
- package/fjs/asserts/module.f.d.mts +14 -0
- package/fjs/asserts/module.f.mjs +20 -0
- package/fjs/asserts/proof.f.d.mts +3 -0
- package/fjs/asserts/proof.f.mjs +15 -1
- package/fjs/basen/base128/module.f.mjs +22 -5
- package/fjs/basen/base128/proof.f.d.mts +3 -1
- package/fjs/basen/base128/proof.f.mjs +3 -1
- package/fjs/basen/base64/module.f.mjs +7 -3
- package/fjs/basen/base64/proof.f.d.mts +3 -1
- package/fjs/basen/base64/proof.f.mjs +7 -4
- package/fjs/basen/cbase32/proof.f.d.mts +3 -1
- package/fjs/basen/cbase32/proof.f.mjs +3 -1
- package/fjs/bnf/data/module.f.d.mts +32 -6
- package/fjs/bnf/data/module.f.mjs +112 -7
- package/fjs/bnf/data/proof.f.d.mts +2 -0
- package/fjs/bnf/data/proof.f.mjs +74 -4
- package/fjs/bnf/data/types.d.ts +20 -2
- package/fjs/bnf/descent/module.f.d.mts +34 -5
- package/fjs/bnf/descent/module.f.mjs +176 -54
- package/fjs/bnf/descent/proof.f.d.mts +3 -0
- package/fjs/bnf/descent/proof.f.mjs +189 -27
- package/fjs/bnf/descent/types.d.ts +24 -18
- package/fjs/bnf/ll1/module.f.d.mts +74 -6
- package/fjs/bnf/ll1/module.f.mjs +297 -95
- package/fjs/bnf/ll1/proof.f.d.mts +17 -2
- package/fjs/bnf/ll1/proof.f.mjs +372 -137
- package/fjs/bnf/ll1/types.d.ts +25 -27
- package/fjs/bnf/matcher/module.f.d.mts +66 -0
- package/fjs/bnf/matcher/module.f.mjs +81 -0
- package/fjs/bnf/matcher/proof.f.d.mts +10 -0
- package/fjs/bnf/matcher/proof.f.mjs +79 -0
- package/fjs/bnf/matcher/types.d.ts +54 -0
- package/fjs/bnf/module.f.d.mts +15 -6
- package/fjs/bnf/module.f.mjs +52 -11
- package/fjs/bnf/proof.f.d.mts +2 -0
- package/fjs/bnf/proof.f.mjs +79 -3
- package/fjs/bnf/testlib.f.d.mts +31 -0
- package/fjs/bnf/testlib.f.mjs +80 -0
- package/fjs/bnf/token_symbol/module.f.d.mts +4 -3
- package/fjs/bnf/token_symbol/module.f.mjs +7 -6
- package/fjs/bnf/token_symbol/proof.f.mjs +5 -2
- package/fjs/bnf/token_symbol/types.d.ts +2 -2
- package/fjs/bnf/types.d.ts +10 -3
- package/fjs/cas/cli/module.f.d.mts +1 -1
- package/fjs/cas/cli/module.f.mjs +14 -20
- package/fjs/cas/cli/proof.f.d.mts +4 -4
- package/fjs/cas/cli/proof.f.mjs +47 -34
- package/fjs/cas/evo/module.f.d.mts +71 -31
- package/fjs/cas/evo/module.f.mjs +223 -138
- package/fjs/cas/evo/proof.f.d.mts +10 -1
- package/fjs/cas/evo/proof.f.mjs +311 -226
- package/fjs/cas/evo/types.d.ts +45 -9
- package/fjs/cas/module.f.d.mts +18 -32
- package/fjs/cas/module.f.mjs +164 -176
- package/fjs/cas/proof.f.d.mts +11 -8
- package/fjs/cas/proof.f.mjs +259 -147
- package/fjs/cas/types.d.ts +24 -10
- package/fjs/ci/common/module.f.d.mts +1 -1
- package/fjs/ci/common/module.f.mjs +1 -0
- package/fjs/ci/config/module.f.d.mts +3 -3
- package/fjs/ci/config/module.f.mjs +3 -3
- package/fjs/ci/module.f.d.mts +5 -5
- package/fjs/ci/module.f.mjs +8 -7
- package/fjs/ci/nix/module.f.d.mts +7 -5
- package/fjs/ci/nix/module.f.mjs +13 -12
- package/fjs/ci/nix/proof.f.d.mts +2 -0
- package/fjs/ci/nix/proof.f.mjs +4 -4
- package/fjs/ci/proof.f.d.mts +4 -2
- package/fjs/ci/proof.f.mjs +13 -8
- package/fjs/cli/module.f.d.mts +4 -6
- package/fjs/cli/module.f.mjs +4 -8
- package/fjs/cli/proof.f.d.mts +4 -2
- package/fjs/cli/proof.f.mjs +21 -18
- package/fjs/cli/types.d.ts +2 -3
- package/fjs/common/monoid/module.f.d.mts +70 -12
- package/fjs/common/monoid/module.f.mjs +177 -14
- package/fjs/common/monoid/proof.f.d.mts +12 -1
- package/fjs/common/monoid/proof.f.mjs +88 -4
- package/fjs/common/monoid/types.d.ts +23 -0
- package/fjs/crypto/hmac/module.f.mjs +2 -2
- package/fjs/crypto/secp/proof.f.d.mts +3 -1
- package/fjs/crypto/secp/proof.f.mjs +3 -1
- package/fjs/crypto/sha2/module.f.mjs +3 -1
- package/fjs/crypto/sha2/proof.f.d.mts +4 -1
- package/fjs/crypto/sha2/proof.f.mjs +27 -1
- package/fjs/crypto/sha2/types.d.ts +11 -0
- package/fjs/crypto/sign/module.f.mjs +2 -2
- package/fjs/crypto/vdf/module.f.d.mts +23 -4
- package/fjs/crypto/vdf/module.f.mjs +6 -4
- package/fjs/dev/module.f.d.mts +17 -5
- package/fjs/dev/module.f.mjs +60 -30
- package/fjs/dev/update/module.f.d.mts +11 -3
- package/fjs/dev/update/module.f.mjs +16 -11
- package/fjs/dev/update/proof.f.d.mts +4 -3
- package/fjs/dev/update/proof.f.mjs +11 -7
- package/fjs/djs/module.f.d.mts +13 -5
- package/fjs/djs/module.f.mjs +31 -16
- package/fjs/djs/parser/module.f.d.mts +16 -3
- package/fjs/djs/parser/module.f.mjs +135 -16
- package/fjs/djs/parser/proof.f.d.mts +8 -1
- package/fjs/djs/parser/proof.f.mjs +287 -13
- package/fjs/djs/parser/types.d.ts +7 -1
- package/fjs/djs/proof.f.d.mts +20 -1
- package/fjs/djs/proof.f.mjs +190 -12
- package/fjs/djs/serializer/module.f.d.mts +25 -8
- package/fjs/djs/serializer/module.f.mjs +66 -19
- package/fjs/djs/serializer/proof.f.d.mts +5 -0
- package/fjs/djs/serializer/proof.f.mjs +23 -1
- package/fjs/djs/tokenizer/module.f.d.mts +17 -5
- package/fjs/djs/tokenizer/module.f.mjs +120 -73
- package/fjs/djs/tokenizer/proof.f.d.mts +3 -0
- package/fjs/djs/tokenizer/proof.f.mjs +86 -67
- package/fjs/djs/transpiler/module.f.d.mts +13 -19
- package/fjs/djs/transpiler/module.f.mjs +79 -72
- package/fjs/djs/transpiler/types.d.ts +29 -0
- package/fjs/djs/types.d.ts +7 -1
- package/fjs/effects/list/module.f.d.mts +23 -12
- package/fjs/effects/list/module.f.mjs +16 -12
- package/fjs/effects/list/types.d.ts +27 -7
- package/fjs/effects/memory/module.f.d.mts +6 -3
- package/fjs/effects/memory/module.f.mjs +7 -7
- package/fjs/effects/memory/proof.f.d.mts +4 -0
- package/fjs/effects/memory/proof.f.mjs +18 -9
- package/fjs/effects/memory/types.d.ts +4 -3
- package/fjs/effects/mock/module.f.d.mts +28 -4
- package/fjs/effects/mock/module.f.mjs +39 -5
- package/fjs/effects/mock/types.d.ts +10 -1
- package/fjs/effects/module.d.mts +12 -2
- package/fjs/effects/module.f.d.mts +469 -281
- package/fjs/effects/module.f.mjs +538 -299
- package/fjs/effects/module.mjs +11 -2
- package/fjs/effects/node/memory/module.d.mts +7 -2
- package/fjs/effects/node/memory/module.mjs +9 -5
- package/fjs/effects/node/memory/proof.d.mts +2 -0
- package/fjs/effects/node/memory/proof.mjs +12 -5
- package/fjs/effects/node/module.d.mts +8 -2
- package/fjs/effects/node/module.f.d.mts +183 -43
- package/fjs/effects/node/module.f.mjs +260 -62
- package/fjs/effects/node/module.mjs +61 -50
- package/fjs/effects/node/proof.f.d.mts +28 -2
- package/fjs/effects/node/proof.f.mjs +161 -42
- package/fjs/effects/node/types.d.ts +106 -18
- package/fjs/effects/node/virtual/module.f.d.mts +21 -4
- package/fjs/effects/node/virtual/module.f.mjs +113 -70
- package/fjs/effects/node/virtual/proof.f.d.mts +31 -2
- package/fjs/effects/node/virtual/proof.f.mjs +201 -8
- package/fjs/effects/proof.f.d.mts +69 -34
- package/fjs/effects/proof.f.mjs +413 -130
- package/fjs/effects/types.d.ts +161 -33
- package/fjs/emergent_testing/all.test.d.mts +8 -0
- package/fjs/emergent_testing/all.test.mjs +14 -0
- package/fjs/emergent_testing/module.f.d.mts +22 -10
- package/fjs/emergent_testing/module.f.mjs +119 -85
- package/fjs/emergent_testing/proof.f.d.mts +21 -7
- package/fjs/emergent_testing/proof.f.mjs +169 -35
- package/fjs/emergent_testing/types.d.ts +22 -4
- package/fjs/fsc/bnf.f.d.mts +3 -0
- package/fjs/fsc/bnf.f.mjs +4 -1
- package/fjs/fsc/json.f.d.mts +3 -0
- package/fjs/fsc/json.f.mjs +4 -1
- package/fjs/fsc/module.f.d.mts +9 -0
- package/fjs/fsc/module.f.mjs +5 -3
- package/fjs/fsm/module.f.d.mts +14 -4
- package/fjs/fsm/module.f.mjs +54 -37
- package/fjs/fsm/proof.f.d.mts +5 -0
- package/fjs/fsm/proof.f.mjs +87 -115
- package/fjs/js/keywords/module.f.d.mts +52 -0
- package/fjs/js/keywords/module.f.mjs +72 -0
- package/fjs/{emergent_testing/scenarios/return-value.pass.d.ts → js/keywords/proof.f.d.mts} +1 -1
- package/fjs/js/keywords/proof.f.mjs +13 -0
- package/fjs/js/tokenizer/module.f.d.mts +30 -3
- package/fjs/js/tokenizer/module.f.mjs +161 -211
- package/fjs/js/tokenizer/proof.f.d.mts +1 -0
- package/fjs/js/tokenizer/proof.f.mjs +54 -24
- package/fjs/js/tokenizer/types.d.ts +33 -24
- package/fjs/mcp/cas/module.f.d.mts +1 -6
- package/fjs/mcp/cas/module.f.mjs +55 -51
- package/fjs/mcp/cas/proof.f.d.mts +15 -0
- package/fjs/mcp/cas/proof.f.mjs +174 -0
- package/fjs/mcp/evo/module.f.d.mts +19 -10
- package/fjs/mcp/evo/module.f.mjs +48 -27
- package/fjs/mcp/evo/proof.f.d.mts +6 -1
- package/fjs/mcp/evo/proof.f.mjs +115 -31
- package/fjs/mcp/module.f.d.mts +39 -4
- package/fjs/mcp/module.f.mjs +14 -12
- package/fjs/mcp/proof.f.d.mts +13 -1
- package/fjs/mcp/proof.f.mjs +120 -61
- package/fjs/media/html/module.f.d.mts +12 -0
- package/fjs/media/html/module.f.mjs +7 -5
- package/fjs/media/html/proof.f.d.mts +3 -0
- package/fjs/media/html/proof.f.mjs +4 -1
- package/fjs/media/json/extended/module.f.d.mts +82 -0
- package/fjs/media/json/extended/module.f.mjs +153 -0
- package/fjs/media/json/extended/proof.f.d.mts +42 -0
- package/fjs/media/json/extended/proof.f.mjs +127 -0
- package/fjs/media/json/extended/types.d.ts +23 -0
- package/fjs/media/json/module.f.d.mts +8 -2
- package/fjs/media/json/module.f.mjs +43 -41
- package/fjs/media/json/number/module.f.d.mts +59 -0
- package/fjs/media/json/number/module.f.mjs +136 -0
- package/fjs/media/json/number/proof.f.d.mts +24 -0
- package/fjs/media/json/number/proof.f.mjs +86 -0
- package/fjs/media/json/number/types.d.ts +28 -0
- package/fjs/media/json/parser/module.f.d.mts +25 -13
- package/fjs/media/json/parser/module.f.mjs +133 -72
- package/fjs/media/json/parser/proof.f.d.mts +5 -0
- package/fjs/media/json/parser/proof.f.mjs +31 -1
- package/fjs/media/json/parser/types.d.ts +38 -14
- package/fjs/media/json/rtti/module.f.d.mts +1 -1
- package/fjs/media/json/rtti/module.f.mjs +1 -1
- package/fjs/media/json/rtti/proof.f.d.mts +3 -0
- package/fjs/media/json/rtti/proof.f.mjs +12 -12
- package/fjs/media/json/schema/module.f.d.mts +61 -27
- package/fjs/media/json/schema/module.f.mjs +218 -63
- package/fjs/media/json/schema/proof.f.d.mts +41 -1
- package/fjs/media/json/schema/proof.f.mjs +220 -9
- package/fjs/media/json/serializer/module.f.d.mts +44 -0
- package/fjs/media/json/serializer/module.f.mjs +71 -9
- package/fjs/media/json/tokenizer/module.f.d.mts +8 -0
- package/fjs/media/json/tokenizer/module.f.mjs +31 -8
- package/fjs/media/json/tokenizer/proof.f.d.mts +6 -0
- package/fjs/media/json/tokenizer/proof.f.mjs +62 -21
- package/fjs/media/json/types.d.ts +36 -10
- package/fjs/media/lock/module.f.d.mts +100 -0
- package/fjs/media/lock/module.f.mjs +125 -0
- package/fjs/media/lock/proof.f.d.mts +33 -0
- package/fjs/media/lock/proof.f.mjs +196 -0
- package/fjs/media/lock/types.d.ts +15 -0
- package/fjs/media/module.f.d.mts +6 -5
- package/fjs/media/module.f.mjs +8 -7
- package/fjs/media/nix/module.f.d.mts +13 -0
- package/fjs/media/nix/module.f.mjs +4 -2
- package/fjs/media/nix/proof.f.d.mts +3 -0
- package/fjs/media/nix/proof.f.mjs +4 -1
- package/fjs/media/note/module.f.d.mts +121 -0
- package/fjs/media/note/module.f.mjs +131 -0
- package/fjs/media/note/proof.f.d.mts +29 -0
- package/fjs/media/note/proof.f.mjs +150 -0
- package/fjs/media/note/types.d.ts +10 -0
- package/fjs/media/proof.f.d.mts +4 -1
- package/fjs/media/proof.f.mjs +40 -21
- package/fjs/media/revision/module.f.d.mts +83 -7
- package/fjs/media/revision/module.f.mjs +127 -23
- package/fjs/media/revision/proof.f.d.mts +14 -0
- package/fjs/media/revision/proof.f.mjs +93 -2
- package/fjs/media/revision/types.d.ts +34 -5
- package/fjs/media/type/module.f.d.mts +53 -18
- package/fjs/media/type/module.f.mjs +87 -97
- package/fjs/media/type/proof.f.d.mts +17 -0
- package/fjs/media/type/proof.f.mjs +73 -13
- package/fjs/module.d.mts +5 -0
- package/fjs/module.f.d.mts +8 -0
- package/fjs/module.f.mjs +33 -10
- package/fjs/module.mjs +6 -0
- package/fjs/nanvm/proof.f.mjs +3 -3
- package/fjs/nanvm/rust/module.f.mjs +1 -1
- package/fjs/nanvm/update/module.f.d.mts +4 -4
- package/fjs/nanvm/update/module.f.mjs +8 -9
- package/fjs/nanvm/update/proof.f.mjs +4 -3
- package/fjs/path/module.f.d.mts +8 -0
- package/fjs/path/module.f.mjs +4 -2
- package/fjs/proof.f.d.mts +7 -3
- package/fjs/proof.f.mjs +41 -12
- package/fjs/protocol/json_rpc/module.f.d.mts +3 -3
- package/fjs/protocol/json_rpc/module.f.mjs +10 -7
- package/fjs/protocol/json_rpc/proof.f.d.mts +6 -0
- package/fjs/protocol/json_rpc/proof.f.mjs +26 -5
- package/fjs/protocol/mcp/module.f.d.mts +10 -13
- package/fjs/protocol/mcp/module.f.mjs +74 -58
- package/fjs/protocol/mcp/proof.f.d.mts +16 -3
- package/fjs/protocol/mcp/proof.f.mjs +224 -69
- package/fjs/protocol/mcp/stdio/module.f.d.mts +17 -11
- package/fjs/protocol/mcp/stdio/module.f.mjs +39 -33
- package/fjs/protocol/mcp/stdio/proof.f.d.mts +5 -3
- package/fjs/protocol/mcp/stdio/proof.f.mjs +46 -13
- package/fjs/protocol/mcp/stdio/types.d.ts +14 -0
- package/fjs/protocol/mcp/types.d.ts +17 -6
- package/fjs/sul/id/module.f.d.mts +4 -0
- package/fjs/sul/id/module.f.mjs +6 -6
- package/fjs/sul/level/hash/module.f.d.mts +4 -1
- package/fjs/sul/level/hash/module.f.mjs +6 -4
- package/fjs/sul/level/hash/proof.f.d.mts +4 -0
- package/fjs/sul/level/hash/proof.f.mjs +7 -4
- package/fjs/sul/level/literal/module.f.d.mts +4 -1
- package/fjs/sul/level/literal/module.f.mjs +4 -3
- package/fjs/sul/level/literal/proof.f.d.mts +3 -0
- package/fjs/sul/level/literal/proof.f.mjs +4 -1
- package/fjs/sul/module.f.d.mts +5 -3
- package/fjs/sul/module.f.mjs +23 -17
- package/fjs/sul/proof.f.d.mts +4 -0
- package/fjs/sul/proof.f.mjs +5 -2
- package/fjs/text/ascii/module.f.d.mts +26 -0
- package/fjs/text/ascii/module.f.mjs +49 -1
- package/fjs/text/ascii/proof.f.d.mts +10 -0
- package/fjs/text/ascii/proof.f.mjs +33 -1
- package/fjs/text/code_point/module.f.d.mts +29 -3
- package/fjs/text/code_point/module.f.mjs +32 -9
- package/fjs/text/code_point/proof.f.d.mts +2 -0
- package/fjs/text/code_point/proof.f.mjs +39 -0
- package/fjs/text/module.f.d.mts +4 -2
- package/fjs/text/module.f.mjs +4 -3
- package/fjs/text/proof.f.d.mts +3 -0
- package/fjs/text/proof.f.mjs +4 -1
- package/fjs/text/sgr/module.f.d.mts +6 -5
- package/fjs/text/sgr/module.f.mjs +8 -8
- package/fjs/text/sgr/proof.f.d.mts +3 -0
- package/fjs/text/sgr/proof.f.mjs +4 -1
- package/fjs/text/utf16/module.f.d.mts +5 -1
- package/fjs/text/utf16/module.f.mjs +38 -35
- package/fjs/text/utf16/proof.f.d.mts +3 -1
- package/fjs/text/utf16/proof.f.mjs +19 -2
- package/fjs/text/utf8/module.f.d.mts +9 -5
- package/fjs/text/utf8/module.f.mjs +20 -20
- package/fjs/types/array/module.f.d.mts +2 -1
- package/fjs/types/array/module.f.mjs +16 -4
- package/fjs/types/bigfloat/module.f.d.mts +21 -1
- package/fjs/types/bigfloat/module.f.mjs +33 -7
- package/fjs/types/bigfloat/proof.f.d.mts +1 -0
- package/fjs/types/bigfloat/proof.f.mjs +46 -0
- package/fjs/types/bigint/module.f.d.mts +4 -0
- package/fjs/types/bigint/module.f.mjs +4 -3
- package/fjs/types/bit_vec/module.f.d.mts +10 -16
- package/fjs/types/bit_vec/module.f.mjs +99 -95
- package/fjs/types/bit_vec/proof.f.d.mts +6 -0
- package/fjs/types/bit_vec/proof.f.mjs +31 -5
- package/fjs/types/btree/find/module.f.d.mts +5 -1
- package/fjs/types/btree/find/module.f.mjs +5 -5
- package/fjs/types/btree/find/proof.f.d.mts +5 -1
- package/fjs/types/btree/find/proof.f.mjs +5 -3
- package/fjs/types/btree/module.f.d.mts +3 -0
- package/fjs/types/btree/module.f.mjs +3 -2
- package/fjs/types/btree/proof.f.d.mts +5 -1
- package/fjs/types/btree/proof.f.mjs +5 -3
- package/fjs/types/btree/remove/module.f.d.mts +11 -0
- package/fjs/types/btree/remove/module.f.mjs +10 -10
- package/fjs/types/btree/remove/proof.f.d.mts +3 -0
- package/fjs/types/btree/remove/proof.f.mjs +4 -1
- package/fjs/types/btree/set/module.f.d.mts +9 -0
- package/fjs/types/btree/set/module.f.mjs +14 -17
- package/fjs/types/btree/set/proof.f.d.mts +3 -0
- package/fjs/types/btree/set/proof.f.mjs +16 -1
- package/fjs/types/btree/types/module.f.d.mts +2 -1
- package/fjs/types/btree/types/module.f.mjs +2 -1
- package/fjs/types/byte_set/module.f.d.mts +20 -4
- package/fjs/types/byte_set/module.f.mjs +18 -8
- package/fjs/types/byte_set/proof.f.d.mts +3 -1
- package/fjs/types/byte_set/proof.f.mjs +10 -8
- package/fjs/types/function/compare/module.f.d.mts +3 -2
- package/fjs/types/function/compare/module.f.mjs +13 -5
- package/fjs/types/function/module.f.d.mts +8 -1
- package/fjs/types/function/module.f.mjs +8 -1
- package/fjs/types/function/operator/module.f.d.mts +2 -1
- package/fjs/types/function/operator/module.f.mjs +2 -2
- package/fjs/types/list/module.f.d.mts +10 -3
- package/fjs/types/list/module.f.mjs +6 -4
- package/fjs/types/list/proof.f.d.mts +4 -1
- package/fjs/types/list/proof.f.mjs +4 -2
- package/fjs/types/nibble_set/module.f.d.mts +2 -1
- package/fjs/types/nibble_set/module.f.mjs +2 -2
- package/fjs/types/nominal/module.f.d.mts +2 -1
- package/fjs/types/nominal/module.f.mjs +2 -1
- package/fjs/types/nullable/module.f.d.mts +26 -6
- package/fjs/types/nullable/module.f.mjs +25 -6
- package/fjs/types/nullable/proof.f.d.mts +4 -0
- package/fjs/types/nullable/proof.f.mjs +15 -0
- package/fjs/types/number/module.f.d.mts +4 -0
- package/fjs/types/number/module.f.mjs +4 -3
- package/fjs/types/object/module.f.d.mts +26 -4
- package/fjs/types/object/module.f.mjs +26 -7
- package/fjs/types/object/proof.f.d.mts +5 -2
- package/fjs/types/object/proof.f.mjs +6 -3
- package/fjs/types/object/structurally_same/module.f.d.mts +39 -0
- package/fjs/types/object/structurally_same/module.f.mjs +59 -0
- package/fjs/types/object/structurally_same/proof.f.d.mts +6 -0
- package/fjs/types/object/structurally_same/proof.f.mjs +73 -0
- package/fjs/types/ordered_map/module.f.d.mts +5 -0
- package/fjs/types/ordered_map/module.f.mjs +5 -4
- package/fjs/types/ordered_map/proof.f.d.mts +3 -0
- package/fjs/types/ordered_map/proof.f.mjs +4 -1
- package/fjs/types/patricia_trie/module.f.d.mts +2 -1
- package/fjs/types/patricia_trie/module.f.mjs +27 -12
- package/fjs/types/patricia_trie/proof.f.d.mts +3 -0
- package/fjs/types/patricia_trie/proof.f.mjs +4 -1
- package/fjs/types/prime_field/module.f.d.mts +3 -1
- package/fjs/types/prime_field/module.f.mjs +3 -2
- package/fjs/types/range/module.f.d.mts +2 -1
- package/fjs/types/range/module.f.mjs +2 -2
- package/fjs/types/range_map/module.f.d.mts +6 -0
- package/fjs/types/range_map/module.f.mjs +6 -9
- package/fjs/types/range_map/proof.f.d.mts +5 -1
- package/fjs/types/range_map/proof.f.mjs +5 -3
- package/fjs/types/range_set/module.f.d.mts +5 -0
- package/fjs/types/range_set/module.f.mjs +1 -0
- package/fjs/types/range_set/proof.f.d.mts +3 -0
- package/fjs/types/range_set/proof.f.mjs +4 -1
- package/fjs/types/result/module.d.mts +8 -0
- package/fjs/types/result/module.f.d.mts +37 -7
- package/fjs/types/result/module.f.mjs +38 -8
- package/fjs/types/result/module.mjs +9 -1
- package/fjs/types/result/proof.f.d.mts +5 -0
- package/fjs/types/result/proof.f.mjs +22 -2
- package/fjs/types/rtti/common/module.f.d.mts +44 -14
- package/fjs/types/rtti/common/module.f.mjs +42 -36
- package/fjs/types/rtti/common/proof.f.d.mts +4 -0
- package/fjs/types/rtti/common/proof.f.mjs +10 -7
- package/fjs/types/rtti/data/module.f.d.mts +134 -0
- package/fjs/types/rtti/data/module.f.mjs +1053 -0
- package/fjs/types/rtti/data/proof.f.d.mts +76 -0
- package/fjs/types/rtti/data/proof.f.mjs +589 -0
- package/fjs/types/rtti/data/types.d.ts +83 -0
- package/fjs/types/rtti/module.f.d.mts +12 -5
- package/fjs/types/rtti/module.f.mjs +7 -5
- package/fjs/types/rtti/parse/module.f.d.mts +48 -0
- package/fjs/types/rtti/parse/module.f.mjs +45 -34
- package/fjs/types/rtti/parse/proof.f.d.mts +3 -2
- package/fjs/types/rtti/parse/proof.f.mjs +51 -52
- package/fjs/types/rtti/proof.f.d.mts +3 -1
- package/fjs/types/rtti/proof.f.mjs +6 -2
- package/fjs/types/rtti/ts/module.f.d.mts +68 -9
- package/fjs/types/rtti/ts/module.f.mjs +258 -30
- package/fjs/types/rtti/ts/proof.f.d.mts +44 -0
- package/fjs/types/rtti/ts/proof.f.mjs +152 -4
- package/fjs/types/rtti/ts/types.d.ts +25 -1
- package/fjs/types/rtti/types.d.ts +40 -0
- package/fjs/types/sorted_list/module.f.d.mts +4 -1
- package/fjs/types/sorted_list/module.f.mjs +21 -12
- package/fjs/types/sorted_list/proof.f.d.mts +3 -1
- package/fjs/types/sorted_list/proof.f.mjs +3 -1
- package/fjs/types/sorted_set/module.f.d.mts +49 -1
- package/fjs/types/sorted_set/module.f.mjs +26 -2
- package/fjs/types/sorted_set/proof.f.d.mts +4 -1
- package/fjs/types/sorted_set/proof.f.mjs +19 -2
- package/fjs/types/string/module.f.d.mts +4 -0
- package/fjs/types/string/module.f.mjs +4 -3
- package/fjs/types/string_set/module.f.d.mts +3 -1
- package/fjs/types/string_set/module.f.mjs +3 -2
- package/fjs/types/ts/module.f.d.mts +2 -0
- package/fjs/types/ts/module.f.mjs +3 -3
- package/fjs/types/ts/proof.f.d.mts +1 -0
- package/fjs/types/ts/proof.f.mjs +5 -0
- package/fjs/types/ts/types.d.ts +6 -1
- package/fjs/types/uint8array/module.f.d.mts +13 -2
- package/fjs/types/uint8array/module.f.mjs +20 -15
- package/fjs/website/module.f.d.mts +5 -2
- package/fjs/website/module.f.mjs +6 -8
- package/fjs/website/proof.f.mjs +2 -1
- package/package.json +3 -3
- package/fjs/asn.1/types.js +0 -6
- package/fjs/asserts/types.js +0 -6
- package/fjs/basen/types.js +0 -6
- package/fjs/bnf/data/types.js +0 -6
- package/fjs/bnf/descent/types.js +0 -6
- package/fjs/bnf/ll1/types.js +0 -6
- package/fjs/bnf/token_symbol/types.js +0 -6
- package/fjs/bnf/types.js +0 -6
- package/fjs/cas/evo/types.js +0 -7
- package/fjs/cas/types.js +0 -6
- package/fjs/ci/common/types.js +0 -1
- package/fjs/ci/nix/types.js +0 -6
- package/fjs/ci/types.js +0 -6
- package/fjs/cli/types.js +0 -6
- package/fjs/common/monoid/types.js +0 -6
- package/fjs/crypto/pow/types.js +0 -6
- package/fjs/crypto/secp/types.js +0 -6
- package/fjs/crypto/sha2/types.js +0 -6
- package/fjs/crypto/sign/types.js +0 -6
- package/fjs/crypto/vdf/types.js +0 -6
- package/fjs/dev/package_json/module.f.d.mts +0 -32
- package/fjs/dev/package_json/module.f.mjs +0 -37
- package/fjs/dev/package_json/proof.f.d.mts +0 -6
- package/fjs/dev/package_json/proof.f.mjs +0 -32
- package/fjs/dev/types.js +0 -6
- package/fjs/djs/ast/types.js +0 -8
- package/fjs/djs/parser/types.js +0 -7
- package/fjs/djs/tokenizer/types.js +0 -7
- package/fjs/djs/types.js +0 -7
- package/fjs/effects/eff/module.f.d.mts +0 -10
- package/fjs/effects/eff/module.f.mjs +0 -68
- package/fjs/effects/eff/proof.f.d.mts +0 -12
- package/fjs/effects/eff/proof.f.mjs +0 -66
- package/fjs/effects/eff/types.d.ts +0 -71
- package/fjs/effects/eff/types.js +0 -6
- package/fjs/effects/list/types.js +0 -6
- package/fjs/effects/memory/types.js +0 -6
- package/fjs/effects/mock/types.js +0 -6
- package/fjs/effects/node/types.js +0 -6
- package/fjs/effects/node/virtual/types.js +0 -7
- package/fjs/effects/types.js +0 -6
- package/fjs/emergent_testing/all.test.d.ts +0 -1
- package/fjs/emergent_testing/all.test.js +0 -5
- package/fjs/emergent_testing/scenarios/all.d.ts +0 -1
- package/fjs/emergent_testing/scenarios/all.js +0 -1
- package/fjs/emergent_testing/scenarios/async-subtests.fail.d.ts +0 -6
- package/fjs/emergent_testing/scenarios/async-subtests.fail.js +0 -9
- package/fjs/emergent_testing/scenarios/async-subtests.pass.d.ts +0 -6
- package/fjs/emergent_testing/scenarios/async-subtests.pass.js +0 -9
- package/fjs/emergent_testing/scenarios/async.fail.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/async.fail.js +0 -6
- package/fjs/emergent_testing/scenarios/async.pass.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/async.pass.js +0 -5
- package/fjs/emergent_testing/scenarios/fail.fail.d.ts +0 -3
- package/fjs/emergent_testing/scenarios/fail.fail.js +0 -3
- package/fjs/emergent_testing/scenarios/return-value.pass.js +0 -4
- package/fjs/emergent_testing/scenarios/thenable.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/thenable.pass.js +0 -11
- package/fjs/emergent_testing/scenarios/thenable2.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/thenable2.pass.js +0 -3
- package/fjs/emergent_testing/scenarios/throw.pass.d.ts +0 -5
- package/fjs/emergent_testing/scenarios/throw.pass.js +0 -3
- package/fjs/emergent_testing/types.js +0 -6
- package/fjs/js/tokenizer/types.js +0 -6
- package/fjs/media/html/types.js +0 -6
- package/fjs/media/json/parser/types.js +0 -6
- package/fjs/media/json/tokenizer/types.js +0 -6
- package/fjs/media/json/types.js +0 -13
- package/fjs/media/nix/types.js +0 -6
- package/fjs/media/revision/types.js +0 -8
- package/fjs/media/type/types.js +0 -6
- package/fjs/media/types.js +0 -7
- package/fjs/nanvm/types.js +0 -11
- package/fjs/protocol/json_rpc/types.js +0 -8
- package/fjs/protocol/mcp/types.js +0 -8
- package/fjs/sul/id/types.js +0 -6
- package/fjs/sul/level/hash/types.js +0 -6
- package/fjs/sul/level/literal/types.js +0 -6
- package/fjs/sul/types.js +0 -6
- package/fjs/text/sgr/types.js +0 -6
- package/fjs/text/types.js +0 -6
- package/fjs/text/utf16/types.js +0 -6
- package/fjs/text/utf8/types.js +0 -6
- package/fjs/types/array/types.js +0 -6
- package/fjs/types/bigfloat/types.js +0 -6
- package/fjs/types/bigint/types.js +0 -6
- package/fjs/types/bit_vec/types.js +0 -6
- package/fjs/types/btree/find/types.js +0 -6
- package/fjs/types/btree/types/types.js +0 -6
- package/fjs/types/byte_set/types.js +0 -6
- package/fjs/types/function/compare/types.js +0 -6
- package/fjs/types/function/operator/types.js +0 -6
- package/fjs/types/function/types.js +0 -6
- package/fjs/types/list/types.js +0 -6
- package/fjs/types/nibble_set/types.js +0 -6
- package/fjs/types/nominal/types.js +0 -6
- package/fjs/types/nullable/types.js +0 -6
- package/fjs/types/object/types.js +0 -8
- package/fjs/types/option/types.js +0 -6
- package/fjs/types/ordered_map/types.js +0 -6
- package/fjs/types/patricia_trie/types.js +0 -6
- package/fjs/types/phantom/types.js +0 -11
- package/fjs/types/prime_field/types.js +0 -6
- package/fjs/types/range/types.js +0 -6
- package/fjs/types/range_map/types.js +0 -6
- package/fjs/types/result/types.js +0 -6
- package/fjs/types/rtti/common/types.js +0 -1
- package/fjs/types/rtti/parse/types.js +0 -1
- package/fjs/types/rtti/ts/types.js +0 -1
- package/fjs/types/rtti/types.js +0 -1
- package/fjs/types/rtti/validate/module.f.d.mts +0 -6
- package/fjs/types/rtti/validate/module.f.mjs +0 -169
- package/fjs/types/rtti/validate/proof.f.d.mts +0 -125
- package/fjs/types/rtti/validate/proof.f.mjs +0 -437
- package/fjs/types/rtti/validate/types.d.ts +0 -6
- package/fjs/types/rtti/validate/types.js +0 -1
- package/fjs/types/sorted_list/types.js +0 -6
- package/fjs/types/sorted_set/types.js +0 -6
- package/fjs/types/string_set/types.js +0 -6
- package/fjs/types/ts/types.js +0 -8
|
@@ -1,23 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
2
|
+
* The effect system: the representation, its interpreters, and the combinators
|
|
3
|
+
* that compose it.
|
|
4
|
+
*
|
|
5
|
+
* An `Effect<O, T, E>` **is** the raw value — a `Pure` thunk
|
|
6
|
+
* (`() => Result<T, E>`) or a `Do` node (`{ command, payload, continuation }`).
|
|
7
|
+
* It is plain data with no methods; see [`./types.ts`](./types.ts) for the
|
|
8
|
+
* type-level API and [`./README.md`](./README.md) for why the error channel is
|
|
9
|
+
* part of it.
|
|
10
|
+
*
|
|
11
|
+
* **The three branch-aware operations are the whole composition vocabulary:**
|
|
12
|
+
*
|
|
13
|
+
* - {@link step} — continue on `ok`, propagate the `error`. The normal path.
|
|
14
|
+
* - {@link catchStep} — continue on `error`, preserve the `ok`. The error path.
|
|
15
|
+
* - {@link resultStep} — continue with the complete `Result`. Both paths.
|
|
16
|
+
*
|
|
17
|
+
* Around them: {@link pure} and the two lifts {@link pureOk} / {@link pureError}
|
|
18
|
+
* that enter the layer, the projections {@link mapStep} and
|
|
19
|
+
* {@link resultMapStep} that end a chain, {@link history} /
|
|
20
|
+
* {@link historyStep} for a chain whose later links read earlier values, and
|
|
21
|
+
* {@link foldStep} / {@link forEachStep} for iteration. The operation
|
|
22
|
+
* constructor is {@link do_}, and the eliminators are {@link match},
|
|
23
|
+
* {@link partialMatch} and {@link runPure}.
|
|
24
|
+
*
|
|
25
|
+
* **The error channel is unioned, not unified**, following `okThen`
|
|
26
|
+
* (`fjs/types/result/module.f.mjs`), the pure sibling of this bind: neither
|
|
27
|
+
* side is pre-widened, and a branch that is passed through stays the very tuple
|
|
28
|
+
* it arrived as rather than being rebuilt to retag it into a wider type.
|
|
29
|
+
* {@link step} unions the error channel and replaces the success type;
|
|
30
|
+
* {@link catchStep} mirrors it, unioning the success channel and replacing the
|
|
31
|
+
* error type.
|
|
32
|
+
*
|
|
33
|
+
* Recovery therefore never needs `try`/`catch` — which FunctionalScript does
|
|
34
|
+
* not offer, and whose `throw` stays reserved for panics. Escalating an error
|
|
35
|
+
* to a panic is a decision the program makes explicitly, by `unwrap`ping what
|
|
36
|
+
* {@link resultStep} hands it.
|
|
37
|
+
*
|
|
38
|
+
* **This was two modules, and briefly two of each combinator.** A `./io/`
|
|
39
|
+
* directory held the branch-aware set while this file held a `Result`-blind
|
|
40
|
+
* `step`, `mapStep`, `history`, `historyStep`, `foldStep` and `forEachStep`
|
|
41
|
+
* beside the representation. Those were traps rather than a layer: an operation
|
|
42
|
+
* must return a `Result`, so every effect carries one, and a `step` that ran
|
|
43
|
+
* its continuation whether or not the previous effect failed described no case
|
|
44
|
+
* worth having. They are gone — {@link resultStep} *is* that former general
|
|
45
|
+
* `step`, at the type that says what its continuation receives — and with the
|
|
46
|
+
* name collision went the only reason for two modules. The directory was called
|
|
47
|
+
* `io` because it was the fallible layer over a raw one; nothing in it was ever
|
|
48
|
+
* specific to IO.
|
|
49
|
+
*
|
|
50
|
+
* **Three functions discriminate `Pure` from `Do`** — {@link resultStep},
|
|
51
|
+
* {@link _matchWith} and {@link runPure} — plus the node proof in
|
|
52
|
+
* `./proof.f.mjs` that pins the representation on purpose. Everything else,
|
|
53
|
+
* interpreters included, goes through `match`, {@link partialMatch}, or
|
|
54
|
+
* `runPure`. The count is the point: a `typeof e === 'function'` check
|
|
55
|
+
* appearing in a fourth place is a review flag, because the representation is
|
|
56
|
+
* only cheap to change while its readers stay enumerable. It used to be a
|
|
57
|
+
* cross-module claim, with one of the three on the far side of the boundary.
|
|
58
|
+
*
|
|
59
|
+
* `match` and `partialMatch` are two entry points, not two discriminators:
|
|
60
|
+
* they differ only in what a missing handler means and share `_matchWith` for
|
|
61
|
+
* the shape test, so adding the partial variant left the count where it was.
|
|
62
|
+
*
|
|
63
|
+
* A `decode` function (`(e: Effect<O, T, E>) => Decoded<O, T, E>`) once funnelled
|
|
64
|
+
* all of that through a single `{ done, result }` / `{ done, command, payload,
|
|
19
65
|
* continuation }` record, so that exactly one function held the shape test. It
|
|
20
|
-
* has been removed.
|
|
66
|
+
* has been removed. An effect is a function type unioned with an object type, so
|
|
21
67
|
* `typeof e === 'function'` is already a complete discriminant: `decode` bought
|
|
22
68
|
* no narrowing, it re-encoded that narrowing as a `done` flag to be re-narrowed
|
|
23
69
|
* one indirection later, and its `Decoded` record was declared in terms of the
|
|
@@ -26,325 +72,467 @@
|
|
|
26
72
|
* the same nothing — and with {@link Do} now carrying named fields there is not
|
|
27
73
|
* even a positional layout left for it to insulate anyone from.
|
|
28
74
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* {@link historyStep}. {@link mapStep} is the variant for the end of a chain:
|
|
33
|
-
* a pure projection over an effect's result, which is a `step` that continues
|
|
34
|
-
* with no further effect.
|
|
75
|
+
* **The composition rules:** bind each link in a sequence to its own name at one
|
|
76
|
+
* level, do not nest steps, and break a call that does not fit one line after
|
|
77
|
+
* `(` with one argument per line.
|
|
35
78
|
*
|
|
36
|
-
*
|
|
37
|
-
* sequence reads top-to-bottom in evaluation order:
|
|
79
|
+
* @module
|
|
38
80
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
81
|
+
* @import { List } from '../types/list/types.ts'
|
|
82
|
+
* @import { Fold } from '../types/function/operator/types.ts'
|
|
83
|
+
* @import { Option } from '../types/option/types.ts'
|
|
84
|
+
* @import { Result } from '../types/result/types.ts'
|
|
85
|
+
* @import { Commands, Effect, ErrOf, Func, MatchResult, NotImplemented, OkOf, Operation, OperationMap, PartialOperationMap } from './types.ts'
|
|
86
|
+
*/
|
|
87
|
+
import type { List } from '../types/list/types.ts';
|
|
88
|
+
import type { Option } from '../types/option/types.ts';
|
|
89
|
+
import type { Result } from '../types/result/types.ts';
|
|
90
|
+
import type { Commands, Effect, ErrOf, Func, MatchResult, NotImplemented, OkOf, Operation, OperationMap, PartialOperationMap } from './types.ts';
|
|
91
|
+
/**
|
|
92
|
+
* Lifts an already-computed {@link Result} into an effect that performs no
|
|
93
|
+
* command.
|
|
94
|
+
*
|
|
95
|
+
* It takes the `Result` rather than a bare value because that is what a `Pure`
|
|
96
|
+
* holds: the two channels are the representation's, so a constructor that took
|
|
97
|
+
* only a success would be `pureOk`, which is exactly what
|
|
98
|
+
* [`./module.f.mjs`](./module.f.mjs) exports alongside `pureError`. Reach
|
|
99
|
+
* for those; this one is for the `Result` you already have in your hand — a
|
|
100
|
+
* branch passing an incoming error through unchanged, or a runner's answer.
|
|
101
|
+
*
|
|
102
|
+
* **Both channels are read off the argument**, via {@link OkOf} / {@link ErrOf}
|
|
103
|
+
* rather than by matching `Result<T, E>` directly. Inference against the union
|
|
104
|
+
* cannot tell which half a one-sided argument belongs to — `pure(ok(v))` would
|
|
105
|
+
* infer the error channel as `T` as readily as `never` — so the halves are
|
|
106
|
+
* projected out of the concrete type instead. That is what makes `pureOk` land
|
|
107
|
+
* on `Effect<never, T, never>` and `pureError` on `Effect<never, never, E>`.
|
|
108
|
+
*
|
|
109
|
+
* @type {<R extends Result<unknown, unknown>>(r: R) => Effect<never, OkOf<R>, ErrOf<R>>}
|
|
110
|
+
*/
|
|
111
|
+
export declare const pure: <R extends Result<unknown, unknown>>(r: R) => Effect<never, OkOf<R>, ErrOf<R>>;
|
|
112
|
+
/**
|
|
113
|
+
* @type {<O extends Operation>(command: O[0]) => Func<O>}
|
|
114
|
+
*/
|
|
115
|
+
export declare const do_: <O extends Operation>(command: O[0]) => Func<O>;
|
|
116
|
+
/**
|
|
117
|
+
* Runs an effect that reaches its result without performing a command: `[r]`
|
|
118
|
+
* for a {@link Pure}, empty for a {@link Do}. Forces the thunk in the `Pure`
|
|
119
|
+
* case, which {@link Pure}'s contract makes free of consequence.
|
|
42
120
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* const x1 = step(x0, g)
|
|
46
|
-
* return step(x1, h)
|
|
47
|
-
* ```
|
|
121
|
+
* The eliminator for callers that expect no operations at all — the other side
|
|
122
|
+
* of {@link match}, which is for callers that intend to perform them.
|
|
48
123
|
*
|
|
49
|
-
* **
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* `do` notation: the arguments are a statement list in execution order, so each
|
|
55
|
-
* one gets a line and the sequence reads down the page. Packing the leading
|
|
56
|
-
* effect onto the `(` line and wrapping the rest beneath it hides which of them
|
|
57
|
-
* runs first. The closing `)` may sit on its own line or trail the last
|
|
58
|
-
* argument:
|
|
124
|
+
* **The result is tagged on purpose**, and the tag is not the `Result`'s. An
|
|
125
|
+
* `Option` distinguishes "reached a value" from "stopped at a command";
|
|
126
|
+
* the `Result` inside it distinguishes success from failure. Collapsing them
|
|
127
|
+
* would lose the case this exists to rule out — an effect that unexpectedly
|
|
128
|
+
* stopped at a `Do` node — so `[r]` is a pure result and `[]` is a `Do`.
|
|
59
129
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
130
|
+
* `O` stays generic rather than narrowing to `Effect<never, T, E>`. An effect is
|
|
131
|
+
* covariant in `O`, so `Effect<never, T, E>` is assignable to `Effect<O, T, E>`
|
|
132
|
+
* and not the reverse — a continuation's result is always the wider type and
|
|
133
|
+
* would be rejected. `Do<never, T, E>` is uninhabited besides, which would make
|
|
134
|
+
* the empty case unreachable without a cast.
|
|
65
135
|
*
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
136
|
+
* @type {<O extends Operation, T, E>(e: Effect<O, T, E>) => Option<Result<T, E>>}
|
|
137
|
+
*/
|
|
138
|
+
export declare const runPure: <O extends Operation, T, E>(e: Effect<O, T, E>) => Option<Result<T, E>>;
|
|
139
|
+
/**
|
|
140
|
+
* Decodes an effect's next step and dispatches its command to `map`,
|
|
141
|
+
* returning either the final result or the operation's output `R` paired
|
|
142
|
+
* with the continuation. The one world-specific step — `await` for async
|
|
143
|
+
* runners, state threading for sync ones — is left to the caller, so every
|
|
144
|
+
* interpreter loop is this skeleton plus a single eliminator line.
|
|
70
145
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
146
|
+
* **An interpreter sees the whole `Result` and must not short-circuit on it.**
|
|
147
|
+
* A runner answers a failed command through the *ordinary* continuation — that
|
|
148
|
+
* is what makes `error(notImplemented)` recoverable — so the `done` payload
|
|
149
|
+
* here is `Result<T, E>` rather than the `ok` half. Separating the channels is
|
|
150
|
+
* the composition layer's job, one level up.
|
|
74
151
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
152
|
+
* **The handler is looked up with `at`, never with `map[command]`.**
|
|
153
|
+
* `OperationMap<O, R>` pins `command` to `O[0]` at the type level, but a `Do`
|
|
154
|
+
* node's `command` is runtime data — it can reach an interpreter from a decoded
|
|
155
|
+
* payload or a deserialized continuation, where no type ever constrained it.
|
|
156
|
+
* `map` is an ordinary object, so a plain index read resolves an inherited name
|
|
157
|
+
* (`'constructor'`, `'toString'`, `'hasOwnProperty'`) to the `Object.prototype`
|
|
158
|
+
* member instead of `undefined`, and the line below would then call it with the
|
|
159
|
+
* node's payload: a value the type system promised was `(...payload) => R` turns
|
|
160
|
+
* out to be an arbitrary inherited function, chosen by the same input that
|
|
161
|
+
* supplies its arguments. `at` reads through `getOwnPropertyDescriptor`, which
|
|
162
|
+
* only ever sees own properties, so such a command yields `null` and never a
|
|
163
|
+
* callable.
|
|
79
164
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
165
|
+
* **A `null` handler means one of two different things**, and this is the only
|
|
166
|
+
* place that can still tell them apart. With a total {@link OperationMap} every
|
|
167
|
+
* `O1 extends O` the signature admits has its command in `map`, so a miss means
|
|
168
|
+
* the node's `command` was never the `O1[0]` it claimed to be — a malformed
|
|
169
|
+
* node, and a panic. With a {@link PartialOperationMap} a miss may instead be an
|
|
170
|
+
* operation the runner deliberately does not implement, which is an *outcome*: a
|
|
171
|
+
* program receives `error(notImplemented)` through the ordinary continuation and
|
|
172
|
+
* decides for itself whether to recover, fall back, or panic. {@link partialMatch}
|
|
173
|
+
* is the variant that distinguishes the two; this one keeps the strict reading,
|
|
174
|
+
* because a total map has no second case to distinguish.
|
|
83
175
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* cannot be bound to an effect that has not been produced yet, so `f(param)`
|
|
87
|
-
* cannot become a `const` until `e` resolves. {@link step} recurses into
|
|
88
|
-
* itself inside the continuation it rebuilds, {@link foldStep} composes one
|
|
89
|
-
* step per item, and {@link historyStep} runs `f` inside `e`'s continuation.
|
|
90
|
-
* Each writes that nesting down **once**, in one line, so that no caller ever
|
|
91
|
-
* writes it again — that is what a combinator here is *for*. Without
|
|
92
|
-
* {@link historyStep} the flat form would be unavailable the moment a later
|
|
93
|
-
* link needed an earlier link's value.
|
|
176
|
+
* The two share {@link _matchWith}, so `typeof e === 'function'` still appears
|
|
177
|
+
* in exactly the three places the module header names.
|
|
94
178
|
*
|
|
95
|
-
*
|
|
179
|
+
* @template {Operation} O
|
|
180
|
+
* @template R
|
|
181
|
+
* @param {OperationMap<O, R>} map
|
|
182
|
+
*/
|
|
183
|
+
export declare const match: <O extends Operation, R>(map: OperationMap<O, R>) => <O1 extends O, T, E>(e: Effect<O1, T, E>) => MatchResult<O1, T, E, R>;
|
|
184
|
+
/**
|
|
185
|
+
* {@link match} for a runner that is *meant* to lack operations.
|
|
186
|
+
*
|
|
187
|
+
* A command in `commands` with no handler in `map` is a capability this runner
|
|
188
|
+
* does not have: `onMissing` builds the answer and the program resumes with it,
|
|
189
|
+
* which is what lets `O` mean "the operations a computation may request" rather
|
|
190
|
+
* than "the operations every runner implements". A command outside `commands`
|
|
191
|
+
* is still a malformed node and still panics — an omitted handler and a garbled
|
|
192
|
+
* `command` are not the same failure, and collapsing them would turn a probable
|
|
193
|
+
* bug into a routine outcome.
|
|
194
|
+
*
|
|
195
|
+
* **`onMissing` is supplied by the caller because only the caller can build an
|
|
196
|
+
* `R`.** `R` is the *runner's* wrapper — `Promise<…>` for an async loop,
|
|
197
|
+
* `(state) => [state, …]` for a state-threading one — not the operation's
|
|
198
|
+
* return type, so this function has no way to construct one. Each runner writes
|
|
199
|
+
* the injector once, next to the loop that defines the shape.
|
|
96
200
|
*
|
|
97
|
-
* @
|
|
201
|
+
* @template {Operation} O
|
|
202
|
+
* @template R
|
|
203
|
+
* @param {Commands<O>} commands
|
|
204
|
+
* @param {(command: O[0]) => R} onMissing
|
|
98
205
|
*/
|
|
99
|
-
|
|
100
|
-
import type { Option } from '../types/option/types.ts';
|
|
101
|
-
import type { Result } from '../types/result/types.ts';
|
|
102
|
-
import type { Effect, History, MatchResult, Operation, OperationMap, Param, Return } from './types.ts';
|
|
103
|
-
/** @import { Option } from '../types/option/types.ts' */
|
|
104
|
-
/** @import { Result } from '../types/result/types.ts' */
|
|
105
|
-
/** @import { Fold } from '../types/function/operator/types.ts' */
|
|
106
|
-
/** @import { Cont, Do, Effect, F, History, MatchResult, Operation, OperationMap, Param, Pr, Pure, Return, ToAsyncOperationMap } from './types.ts' */
|
|
107
|
-
/** @type {<T>(v: T) => Effect<never, T>} */
|
|
108
|
-
export declare const pure: <T>(v: T) => Effect<never, T>;
|
|
206
|
+
export declare const partialMatch: <O extends Operation, R>(commands: Commands<O>, onMissing: (command: O[0]) => R) => (map: PartialOperationMap<O, R>) => <O1 extends O, T, E>(e: Effect<O1, T, E>) => MatchResult<O1, T, E, R>;
|
|
109
207
|
/**
|
|
110
|
-
*
|
|
111
|
-
* The data-first primitive — raw `Effect` in, raw `Effect` out. Chains as
|
|
112
|
-
* `step(step(e, f), g)`.
|
|
208
|
+
* Lifts a value into a successful `Effect` — `pure(ok(v))` written once.
|
|
113
209
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* run. Only the `Do` case defers — the continuation rebuilt around `f` runs
|
|
118
|
-
* when a runner reaches that node.
|
|
210
|
+
* One of the two entry points into the layer: {@link step} and its siblings
|
|
211
|
+
* compose `Effect`s but cannot produce the first one, and the only other source
|
|
212
|
+
* is an operation's own `Result`.
|
|
119
213
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* throw nothing. `step` never performs a `Do` node, which is where anything
|
|
124
|
-
* real lives. Break the contract — hide work behind the thunk — and merely
|
|
125
|
-
* composing a chain starts running the program.
|
|
214
|
+
* The error channel is `never`, which is not a special case to handle but the
|
|
215
|
+
* ordinary consequence of the union rules: `never | E` is `E`, so a lifted
|
|
216
|
+
* value composes with any chain without widening its errors.
|
|
126
217
|
*
|
|
127
|
-
*
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
218
|
+
* @type {<T>(v: T) => Effect<never, T, never>}
|
|
219
|
+
*/
|
|
220
|
+
export declare const pureOk: <T>(v: T) => Effect<never, T, never>;
|
|
221
|
+
/**
|
|
222
|
+
* Lifts an error into a failed `Effect` — `pure(error(e))` written once, and
|
|
223
|
+
* the mirror of {@link pureOk}, with the success channel `never` instead.
|
|
224
|
+
*
|
|
225
|
+
* This is how a program *originates* a failure: a fallback that has run out of
|
|
226
|
+
* options, or a guard that rejects its input before performing anything. A
|
|
227
|
+
* runner producing `error(notImplemented)` does not go through here — that
|
|
228
|
+
* error arrives through an operation's own continuation.
|
|
135
229
|
*
|
|
136
|
-
* @type {<
|
|
230
|
+
* @type {<E>(e: E) => Effect<never, never, E>}
|
|
137
231
|
*/
|
|
138
|
-
export declare const
|
|
232
|
+
export declare const pureError: <E>(e: E) => Effect<never, never, E>;
|
|
139
233
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* **The operation set does not widen.** The result is `Effect<O, R>`, not
|
|
150
|
-
* `Effect<O | Q, R>`, because a pure projection issues no commands — nothing a
|
|
151
|
-
* runner has to know how to interpret is added by `f`. That is what separates
|
|
152
|
-
* this from `step`, beyond the shorter spelling.
|
|
153
|
-
*
|
|
154
|
-
* A constant variant (`constStep(e, v)`) is deliberately absent: `mapStep(e,
|
|
155
|
-
* () => v)` already reads clearly, and it keeps `v`'s evaluation inside the
|
|
156
|
-
* continuation where `step` puts it, rather than moving it to where the
|
|
157
|
-
* composition is written.
|
|
158
|
-
*
|
|
159
|
-
* @type {<O extends Operation, T, R>(e: Effect<O, T>, f: (t: T) => R) => Effect<O, R>}
|
|
234
|
+
* Builds the {@link NotImplemented} a runner answers with when it cannot
|
|
235
|
+
* dispatch `command`.
|
|
236
|
+
*
|
|
237
|
+
* It names the command and nothing else. A `Do` node's payload may hold
|
|
238
|
+
* functions — `createServer`'s listener, `sandbox`'s thunk, `test`'s body — so
|
|
239
|
+
* carrying it would break the serializability this error type promises, and the
|
|
240
|
+
* command name is the part a program can act on anyway.
|
|
241
|
+
*
|
|
242
|
+
* @type {(command: string) => NotImplemented}
|
|
160
243
|
*/
|
|
161
|
-
export declare const
|
|
244
|
+
export declare const notImplemented: (command: string) => NotImplemented;
|
|
162
245
|
/**
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* `[r, ...p]` — the same history with `r` prepended.
|
|
246
|
+
* The normal path: run `e`, and continue with `f` **only** if it succeeded. An
|
|
247
|
+
* `error` short-circuits the rest of the chain and is passed through unchanged.
|
|
166
248
|
*
|
|
167
|
-
* This is
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
249
|
+
* This is the default error propagation the migration exists to provide — the
|
|
250
|
+
* structured replacement for exception-style propagation, analogous to Rust's
|
|
251
|
+
* `?`. A sequence therefore reads as its success path, and mentions errors only
|
|
252
|
+
* where it intentionally handles them:
|
|
171
253
|
*
|
|
172
254
|
* ```js
|
|
173
|
-
* const
|
|
174
|
-
* const
|
|
255
|
+
* const a = writeFile(...)
|
|
256
|
+
* const b = step(a, () => console('written'))
|
|
175
257
|
* ```
|
|
176
258
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
259
|
+
* `'written'` is printed only when `writeFile` returned `ok`. Written with the
|
|
260
|
+
* `Result`-blind `step` this replaced, the same line printed it either way —
|
|
261
|
+
* and note that it was the *value-discarding* continuation that hid the
|
|
262
|
+
* hazard, since one that read the value would not have compiled.
|
|
181
263
|
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
* const h2 = historyStep(h1, (revision, hash) => ...)
|
|
186
|
-
* ```
|
|
264
|
+
* **The error types are unioned** (`E | F`), so `f` may fail in its own way
|
|
265
|
+
* without either side being pre-widened; the operation sets union too, since
|
|
266
|
+
* `f` performs effects of its own.
|
|
187
267
|
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* `Readonly<P>` on `f`'s rest parameter is load-bearing: inferring `P` from a
|
|
196
|
-
* bare rest parameter yields a *mutable*, labelled tuple (`[next: string]`),
|
|
197
|
-
* which then rejects the `readonly` tuples every history is built from.
|
|
198
|
-
*
|
|
199
|
-
* @type {<O extends Operation, P extends readonly unknown[], Q extends Operation, R>(
|
|
200
|
-
* e: History<O, P>,
|
|
201
|
-
* f: (...p: Readonly<P>) => Effect<Q, R>
|
|
202
|
-
* ) => History<O | Q, readonly[R, ...P]>}
|
|
203
|
-
*/
|
|
204
|
-
export declare const historyStep: <O extends Operation, P extends readonly unknown[], Q extends Operation, R>(e: History<O, P>, f: (...p: Readonly<P>) => Effect<Q, R>) => History<O | Q, readonly [R, ...P]>;
|
|
205
|
-
/**
|
|
206
|
-
* Starts a history, lifting a plain result into a one-element tuple so that
|
|
207
|
-
* {@link historyStep} can extend it.
|
|
268
|
+
* The body is {@link resultStep} over the one branch this layer is named for:
|
|
269
|
+
* an `error` is handed back as the very tuple it arrived as rather than rebuilt
|
|
270
|
+
* to retag it into a wider type, which is what makes `E | F` expressible instead
|
|
271
|
+
* of forcing both sides to one error type. The continuation is annotated for
|
|
272
|
+
* that reason — its two branches have different types, and the annotation
|
|
273
|
+
* states the union they belong to rather than leaving the compiler to infer it
|
|
274
|
+
* from whichever it reads first.
|
|
208
275
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
* flattening it, so link two would have to be spelled differently from link
|
|
214
|
-
* three.
|
|
276
|
+
* This used to route through an `okStep` exported by the representation
|
|
277
|
+
* module. Nothing
|
|
278
|
+
* else ever called it: the adapter *was* this function's body, one indirection
|
|
279
|
+
* away, so it is written here now and that module has one export fewer.
|
|
215
280
|
*
|
|
216
|
-
* @
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
* @
|
|
281
|
+
* @template {Operation} O
|
|
282
|
+
* @template T
|
|
283
|
+
* @template E
|
|
284
|
+
* @template {Operation} Q
|
|
285
|
+
* @template R
|
|
286
|
+
* @template F
|
|
287
|
+
* @param {Effect<O, T, E>} e
|
|
288
|
+
* @param {(t: T) => Effect<Q, R, F>} f
|
|
289
|
+
* @returns {Effect<O | Q, R, E | F>}
|
|
221
290
|
*/
|
|
222
|
-
export declare const
|
|
291
|
+
export declare const step: <O extends Operation, T, E, Q extends Operation, R, F>(e: Effect<O, T, E>, f: (t: T) => Effect<Q, R, F>) => Effect<O | Q, R, E | F>;
|
|
223
292
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
293
|
+
* The error path: run `e`, and continue with `f` **only** if it failed. An `ok`
|
|
294
|
+
* is preserved unchanged, so the recovery is the only branch that mentions the
|
|
295
|
+
* failure.
|
|
226
296
|
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
297
|
+
* The exact mirror of {@link step}: where that unions the error channel and
|
|
298
|
+
* replaces the success type, this unions the success channel (`T | R` — the
|
|
299
|
+
* preserved value or the recovery's) and replaces the error type with `f`'s.
|
|
300
|
+
* Recovering from every error therefore leaves `F` uninhabited, and the type
|
|
301
|
+
* says so.
|
|
230
302
|
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
303
|
+
* Use it for *intentional* recovery — a fallback operation after a
|
|
304
|
+
* `NotImplemented`, a default for a missing file — never as a blanket
|
|
305
|
+
* "continue anyway"; that is what {@link step}'s propagation already prevents.
|
|
233
306
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
* Taking the plain list would force every such caller to open a continuation
|
|
239
|
-
* just to name the list (`step(cas.list(), foldStep(…))`), which is the nesting
|
|
240
|
-
* this module exists to keep out of call sites. A caller that already holds the
|
|
241
|
-
* list lifts it with `pure`, which costs a wrapper but no indentation.
|
|
242
|
-
*
|
|
243
|
-
* `O` and `Q` are separate on purpose: the operations needed to produce the list
|
|
244
|
-
* are rarely the ones the body performs, and the result unions them.
|
|
245
|
-
*
|
|
246
|
-
* **The argument order is deliberately not `fold`'s** from `fjs/types/list`, and
|
|
247
|
-
* the difference is what the two combinators are *for*. `fold` is a data
|
|
248
|
-
* pipeline: it is curried `f`-first because the list is the thing being threaded
|
|
249
|
-
* through, and nothing about it happens in time. A step variant is a sequencing
|
|
250
|
-
* construct — it is this module's `do` notation, and reading one top-to-bottom
|
|
251
|
-
* is reading the order the program executes in. The effect therefore has to come
|
|
252
|
-
* first, because it is what happens first. Currying `f` ahead of `items` would
|
|
253
|
-
* put the *body* of the loop above the thing it loops over, which is exactly the
|
|
254
|
-
* inversion `do` exists to remove.
|
|
255
|
-
*
|
|
256
|
-
* That is also why the whole family — `step`, `historyStep`, `foldStep`,
|
|
257
|
-
* `forEachStep` — takes its effect first and breaks one argument per line when
|
|
258
|
-
* it wraps (see this module's header): every such call is a statement list, and
|
|
259
|
-
* each line is one statement in execution order.
|
|
307
|
+
* The local continuation is annotated for the same reason {@link step}'s is:
|
|
308
|
+
* its two branches have different types — `f`'s effect and the untouched `ok`
|
|
309
|
+
* tuple — and the annotation states the union they belong to instead of
|
|
310
|
+
* leaving the compiler to infer it from whichever branch it reads first.
|
|
260
311
|
*
|
|
261
312
|
* @template {Operation} O
|
|
262
313
|
* @template T
|
|
314
|
+
* @template E
|
|
263
315
|
* @template {Operation} Q
|
|
264
|
-
* @template
|
|
265
|
-
* @
|
|
266
|
-
* @param {
|
|
267
|
-
* @param {(
|
|
268
|
-
* @returns {Effect<O | Q,
|
|
316
|
+
* @template R
|
|
317
|
+
* @template F
|
|
318
|
+
* @param {Effect<O, T, E>} e
|
|
319
|
+
* @param {(err: E) => Effect<Q, R, F>} f
|
|
320
|
+
* @returns {Effect<O | Q, T | R, F>}
|
|
269
321
|
*/
|
|
270
|
-
export declare const
|
|
322
|
+
export declare const catchStep: <O extends Operation, T, E, Q extends Operation, R, F>(e: Effect<O, T, E>, f: (err: E) => Effect<Q, R, F>) => Effect<O | Q, T | R, F>;
|
|
271
323
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* a
|
|
324
|
+
* Both paths: run `e` and hand `f` the complete `Result`, which then decides
|
|
325
|
+
* what the outcome is. Use it where both branches genuinely matter — a report
|
|
326
|
+
* that records the failure, a retry policy, or the point where a program
|
|
327
|
+
* escalates an error to a panic by `unwrap`ping it.
|
|
328
|
+
*
|
|
329
|
+
* **This is the layer's primitive**, and {@link step} and {@link catchStep} are
|
|
330
|
+
* written in terms of it — each is this function with a continuation that
|
|
331
|
+
* inspects the tag first. It used to be the other way round: a `step` in the
|
|
332
|
+
* representation module composed effects with opaque payloads, and this was
|
|
333
|
+
* that function re-exported under a narrower type. Since every effect carries a
|
|
334
|
+
* `Result`, the opaque spelling described nothing the `Result`-shaped one does
|
|
335
|
+
* not, so the general function lives here now, at the type that says what its
|
|
336
|
+
* continuation receives.
|
|
337
|
+
*
|
|
338
|
+
* `finallyStep` is declined on the principle that a derivable form earns a name
|
|
339
|
+
* by being canonical vocabulary, and that one has not shown it is. It is
|
|
340
|
+
* `resultStep` plus a policy, and adds no expressive power until real consumers
|
|
341
|
+
* demonstrate a repeated policy worth naming.
|
|
342
|
+
*
|
|
343
|
+
* **It is not lazy.** It reads `e`'s shape immediately, so a `Pure` head is
|
|
344
|
+
* forced and `f` is called right there: `resultStep(pure(r), f)` *is* `f(r)`,
|
|
345
|
+
* evaluated where the composition is written rather than where the effect is
|
|
346
|
+
* run. Only the `Do` case defers — the continuation rebuilt around `f` runs
|
|
347
|
+
* when a runner reaches that node.
|
|
275
348
|
*
|
|
276
|
-
*
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* `r[0] === 'error' ? pure(r) : f(r[1])` check that recurs at every site
|
|
283
|
-
* chaining `Effect<O, Result<T, E>>` steps.
|
|
349
|
+
* That is sound rather than an oversight, and it is sound only because of
|
|
350
|
+
* `Pure`'s contract: a `Pure` holds a result that has already been computed, so
|
|
351
|
+
* forcing it early observes nothing, repeats nothing, and can throw nothing.
|
|
352
|
+
* Composing never performs a `Do` node, which is where anything real lives.
|
|
353
|
+
* Break the contract — hide work behind the thunk — and merely composing a
|
|
354
|
+
* chain starts running the program.
|
|
284
355
|
*
|
|
285
|
-
*
|
|
356
|
+
* A composition cannot be suspended, and no combinator can fix that:
|
|
357
|
+
* `defer: (() => Effect<O, T, E>) => Effect<O, T, E>` cannot be written, because
|
|
358
|
+
* the `Pure` / `Do` tag must be known before anything runs and the union has no
|
|
359
|
+
* third case meaning "not yet decided". That is inherent to the representation,
|
|
360
|
+
* not a gap in this module's API. A caller that needs to name a composition
|
|
361
|
+
* without performing it yet has to keep the ingredients and defer the step
|
|
362
|
+
* itself.
|
|
363
|
+
*
|
|
364
|
+
* @type {<O extends Operation, T, E, Q extends Operation, R, F>(
|
|
365
|
+
* e: Effect<O, T, E>,
|
|
366
|
+
* f: (r: Result<T, E>) => Effect<Q, R, F>
|
|
367
|
+
* ) => Effect<O | Q, R, F>}
|
|
286
368
|
*/
|
|
287
|
-
export declare const
|
|
369
|
+
export declare const resultStep: <O extends Operation, T, E, Q extends Operation, R, F>(e: Effect<O, T, E>, f: (r: Result<T, E>) => Effect<Q, R, F>) => Effect<O | Q, R, F>;
|
|
288
370
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
* The eliminator for callers that expect no operations at all — the other side
|
|
294
|
-
* of {@link match}, which is for callers that intend to perform them.
|
|
371
|
+
* Applies a pure function to the `ok` value, passing an `error` through
|
|
372
|
+
* unchanged: the functor `map` of this layer, and a {@link step} whose
|
|
373
|
+
* continuation performs nothing further.
|
|
295
374
|
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* `
|
|
299
|
-
*
|
|
300
|
-
* this exists to rule out. `Option<T>` keeps them apart: `[null]` is a pure
|
|
301
|
-
* `null`, `[]` is a `Do`.
|
|
375
|
+
* A trailing pure projection is where a sequence *ends*, not another link in
|
|
376
|
+
* it, and spelling it as a step misreports how many effects a chain runs
|
|
377
|
+
* (`./todo/map-step-combinator.md`). Without this, every such site would
|
|
378
|
+
* regress to exactly that spelling, now with a `pureOk` inside it.
|
|
302
379
|
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* be rejected. `Do<never, T>` is uninhabited besides, which would make the empty
|
|
307
|
-
* case unreachable without a cast.
|
|
380
|
+
* **The operation set does not widen**: a pure projection issues no commands. Neither does the error channel — `f` cannot
|
|
381
|
+
* fail, so a chain that only projects its value keeps the errors it already
|
|
382
|
+
* had.
|
|
308
383
|
*
|
|
309
|
-
* @type {<O extends Operation, T>(e: Effect<O, T
|
|
384
|
+
* @type {<O extends Operation, T, E, R>(e: Effect<O, T, E>, f: (t: T) => R) => Effect<O, R, E>}
|
|
310
385
|
*/
|
|
311
|
-
export declare const
|
|
386
|
+
export declare const mapStep: <O extends Operation, T, E, R>(e: Effect<O, T, E>, f: (t: T) => R) => Effect<O, R, E>;
|
|
312
387
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* `
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
388
|
+
* Applies a pure function to the whole {@link Result}: the both-branches
|
|
389
|
+
* sibling of {@link mapStep}, and the {@link resultStep} whose continuation
|
|
390
|
+
* performs nothing further.
|
|
391
|
+
*
|
|
392
|
+
* Reach for it where a projection genuinely decides the outcome rather than
|
|
393
|
+
* transforming a value — turning any answer into a fixed one, replacing a
|
|
394
|
+
* channel wholesale, re-tagging a failure. Where only the success is being
|
|
395
|
+
* transformed, {@link mapStep} says so and leaves the channel alone.
|
|
396
|
+
*
|
|
397
|
+
* **Neither channel is preserved**, which is the difference that matters
|
|
398
|
+
* against `mapStep`: `f` returns a `Result<R, F>` of its own, so a caller can
|
|
399
|
+
* discard errors here. That is exactly what makes it the honest spelling for a
|
|
400
|
+
* site that means to — the discarding is written down, in a function that says
|
|
401
|
+
* it takes both branches, instead of being implied by a value-shaped `map` that
|
|
402
|
+
* quietly received a `Result`.
|
|
403
|
+
*
|
|
404
|
+
* Its two output channels are read off `f`'s return type with {@link OkOf} /
|
|
405
|
+
* {@link ErrOf}, for the reason `pure` gives: inference against the `Result`
|
|
406
|
+
* union cannot place a one-sided return, so a projection that always answers
|
|
407
|
+
* `ok` would otherwise acquire an error channel it never produces.
|
|
408
|
+
*
|
|
409
|
+
* @type {<O extends Operation, T, E, R extends Result<unknown, unknown>>(
|
|
410
|
+
* e: Effect<O, T, E>,
|
|
411
|
+
* f: (r: Result<T, E>) => R
|
|
412
|
+
* ) => Effect<O, OkOf<R>, ErrOf<R>>}
|
|
413
|
+
*/
|
|
414
|
+
export declare const resultMapStep: <O extends Operation, T, E, R extends Result<unknown, unknown>>(e: Effect<O, T, E>, f: (r: Result<T, E>) => R) => Effect<O, OkOf<R>, ErrOf<R>>;
|
|
415
|
+
/**
|
|
416
|
+
* Empties the error channel by **panicking** on it: `ok` values continue
|
|
417
|
+
* unchanged, an `error` is thrown as `summary(e)`, and what comes back is an
|
|
418
|
+
* `Effect<O, T, never>` — a `never` that is earned rather than asserted, since
|
|
419
|
+
* the only way past this point is success.
|
|
420
|
+
*
|
|
421
|
+
* This is the program exercising its right to treat a failure as fatal, and it
|
|
422
|
+
* is a policy — not a conversion. It belongs at a site that genuinely has no
|
|
423
|
+
* answer to the failure: a build tool that cannot read its own sources, a
|
|
424
|
+
* proof whose fixture is missing. Where a caller could do something else,
|
|
425
|
+
* {@link catchStep} or {@link resultStep} is the honest spelling, and a chain
|
|
426
|
+
* that merely passes the failure along wants {@link step}.
|
|
427
|
+
*
|
|
428
|
+
* **`summary` is what names the errors being panicked on, and it is required
|
|
429
|
+
* for that reason rather than for the message.** Without it this function was
|
|
430
|
+
* generic in `E` and therefore compiled however far a channel widened: one
|
|
431
|
+
* fallible read added upstream enlarged what every downstream call crashed on,
|
|
432
|
+
* silently. A renderer written for a particular channel cannot accept a wider
|
|
433
|
+
* one — parameters are contravariant — so widening becomes a compile error at
|
|
434
|
+
* the site that chose to panic, which is the site that has to choose again.
|
|
435
|
+
*
|
|
436
|
+
* The `IoChannel` renderer is `errorSummary` (`./node/module.f.mjs`); pass a
|
|
437
|
+
* narrower one where the channel is narrower. An inline `e => String(e)`
|
|
438
|
+
* accepts anything and gives the old behaviour back — that is an escape hatch,
|
|
439
|
+
* and being written out at the call site is the point.
|
|
440
|
+
*
|
|
441
|
+
* This being one greppable name still matters: every occurrence is a site that
|
|
442
|
+
* has chosen to panic, so the choice can be reviewed. What the name alone
|
|
443
|
+
* could not do is tell a reviewer that a site's *scope* had grown since they
|
|
444
|
+
* last looked at it, which is what the argument adds.
|
|
445
|
+
*
|
|
446
|
+
* @type {<O extends Operation, T, E>(e: Effect<O, T, E>, summary: (e: E) => string) => Effect<O, T, never>}
|
|
447
|
+
*/
|
|
448
|
+
export declare const unwrapStep: <O extends Operation, T, E>(e: Effect<O, T, E>, summary: (e: E) => string) => Effect<O, T, never>;
|
|
449
|
+
/**
|
|
450
|
+
* Starts a history from a fallible effect, lifting its `ok` value into a
|
|
451
|
+
* one-element tuple that {@link historyStep} extends — the entry point a chain
|
|
452
|
+
* needs exactly once.
|
|
331
453
|
*
|
|
332
|
-
*
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
*
|
|
337
|
-
*
|
|
454
|
+
* @type {<O extends Operation, T, E>(e: Effect<O, T, E>) => Effect<O, readonly[T], E>}
|
|
455
|
+
*/
|
|
456
|
+
export declare const history: <O extends Operation, T, E>(e: Effect<O, T, E>) => Effect<O, readonly [T], E>;
|
|
457
|
+
/**
|
|
458
|
+
* Like {@link step}, but carries the values forward instead of discarding
|
|
459
|
+
* them: runs `e` for the history `p`, continues with `f(...p)` for `r`, and
|
|
460
|
+
* yields `[r, ...p]`.
|
|
461
|
+
*
|
|
462
|
+
* This is what keeps a **fallible** chain flat. Each `step`'s continuation sees
|
|
463
|
+
* only the value it consumes, so a later link cannot reach an earlier one, and
|
|
464
|
+
* the alternative — nesting so the inner continuation closes over the outer
|
|
465
|
+
* one's parameter — is what `fjs/AGENTS.md` §3.4 rules out. A `Result`-blind
|
|
466
|
+
* `historyStep` could not serve: it carried each link's `Result` into the tuple
|
|
467
|
+
* rather than its value, so every later link had to destructure results it had
|
|
468
|
+
* no intention of handling. That is why this one exists and that one does not.
|
|
469
|
+
*
|
|
470
|
+
* The history holds `ok` values only. An `error` short-circuits the chain, so a
|
|
471
|
+
* failed link contributes nothing to the tuple — which is the point: a later
|
|
472
|
+
* link reads earlier values without asking whether they are there.
|
|
338
473
|
*
|
|
339
474
|
* @template {Operation} O
|
|
475
|
+
* @template {readonly unknown[]} P
|
|
476
|
+
* @template E
|
|
477
|
+
* @template {Operation} Q
|
|
340
478
|
* @template R
|
|
341
|
-
* @
|
|
479
|
+
* @template F
|
|
480
|
+
* @param {Effect<O, P, E>} e
|
|
481
|
+
* @param {(...p: Readonly<P>) => Effect<Q, R, F>} f
|
|
482
|
+
* @returns {Effect<O | Q, readonly[R, ...P], E | F>}
|
|
342
483
|
*/
|
|
343
|
-
export declare const
|
|
484
|
+
export declare const historyStep: <O extends Operation, P extends readonly unknown[], E, Q extends Operation, R, F>(e: Effect<O, P, E>, f: (...p: Readonly<P>) => Effect<Q, R, F>) => Effect<O | Q, readonly [R, ...P], E | F>;
|
|
344
485
|
/**
|
|
345
|
-
*
|
|
486
|
+
* Threads a state through one effect per item, short-circuiting on the first
|
|
487
|
+
* `error`.
|
|
488
|
+
*
|
|
489
|
+
* **`items` is an `Effect` like everything else here.** Its payload was once
|
|
490
|
+
* unwrapped, on the argument that a held list has no error channel and
|
|
491
|
+
* requiring one would mean lifting at every call site. Lifting is one `pureOk`
|
|
492
|
+
* call, and that version made the *fallible* producer pay instead:
|
|
493
|
+
* `fjs/cas/cli` wrapped the whole fold in a `step` whose only job was to unwrap
|
|
494
|
+
* `list()` so `pure` could wrap it again. A producer that can fail now feeds
|
|
495
|
+
* the fold directly, and one that cannot is unaffected when it later can.
|
|
496
|
+
*
|
|
497
|
+
* **The argument order is deliberately not `fold`'s** from `fjs/types/list`, and
|
|
498
|
+
* the difference is what the two combinators are *for*. `fold` is a data
|
|
499
|
+
* pipeline: it is curried `f`-first because the list is the thing being threaded
|
|
500
|
+
* through, and nothing about it happens in time. A step variant is a sequencing
|
|
501
|
+
* construct — this module's `do` notation — and reading one top-to-bottom is
|
|
502
|
+
* reading the order the program executes in. The effect therefore has to come
|
|
503
|
+
* first, because it is what happens first. Currying `f` ahead of `items` would
|
|
504
|
+
* put the *body* of the loop above the thing it loops over, which is exactly the
|
|
505
|
+
* inversion `do` exists to remove.
|
|
506
|
+
*
|
|
507
|
+
* That is also why the whole family — {@link step}, {@link historyStep},
|
|
508
|
+
* `foldStep`, {@link forEachStep} — takes its effect first and breaks one
|
|
509
|
+
* argument per line when it wraps: every such call is a statement list, and each
|
|
510
|
+
* line is one statement in execution order.
|
|
511
|
+
*
|
|
512
|
+
* @template {Operation} O
|
|
346
513
|
* @template T
|
|
347
|
-
* @
|
|
348
|
-
* @
|
|
514
|
+
* @template {Operation} Q
|
|
515
|
+
* @template S
|
|
516
|
+
* @template E
|
|
517
|
+
* @param {Effect<O, List<T>, E>} items
|
|
518
|
+
* @param {S} init
|
|
519
|
+
* @param {(item: T) => (state: S) => Effect<Q, S, E>} f
|
|
520
|
+
* @returns {Effect<O | Q, S, E>}
|
|
521
|
+
*/
|
|
522
|
+
export declare const foldStep: <O extends Operation, T, Q extends Operation, S, E>(items: Effect<O, List<T>, E>, init: S, f: (item: T) => (state: S) => Effect<Q, S, E>) => Effect<O | Q, S, E>;
|
|
523
|
+
/**
|
|
524
|
+
* Runs `f(item)` for each item in order, stopping at the first failure and
|
|
525
|
+
* propagating it. The `void` accumulator sibling of {@link foldStep}.
|
|
526
|
+
*
|
|
527
|
+
* Stopping is the difference against the `Result`-blind `forEachStep` this
|
|
528
|
+
* replaced: that one ran every item whatever each answered, because its `void`
|
|
529
|
+
* accumulator had nothing to carry a failure in — and TypeScript's `void`
|
|
530
|
+
* return position accepts a `Result`-valued effect silently, so the discard
|
|
531
|
+
* does not even show up as a type error.
|
|
532
|
+
*
|
|
533
|
+
* @type {<O extends Operation, T, Q extends Operation, E>(
|
|
534
|
+
* items: Effect<O, List<T>, E>,
|
|
535
|
+
* f: (item: T) => Effect<Q, void, E>
|
|
536
|
+
* ) => Effect<O | Q, void, E>}
|
|
349
537
|
*/
|
|
350
|
-
|
|
538
|
+
export declare const forEachStep: <O extends Operation, T, Q extends Operation, E>(items: Effect<O, List<T>, E>, f: (item: T) => Effect<Q, void, E>) => Effect<O | Q, void, E>;
|