|
4 | 4 | ... https://en.wikipedia.org/wiki/Variadic_function
|
5 | 5 | (.using
|
6 | 6 | [library
|
7 |
| - [lux (.except the) |
| 7 | + [lux (.except argument ->) |
8 | 8 | [abstract
|
9 | 9 | ["?" projection]
|
10 |
| - ["[0]" monad]] |
11 |
| - [error |
12 |
| - ["[0]" exception (.only Exception)]] |
| 10 | + [functor |
| 11 | + ["/" effect]]] |
13 | 12 | [data
|
14 |
| - ["[0]" text (.only) |
15 |
| - ["%" \\injection]] |
16 | 13 | [collection
|
17 | 14 | ["[0]" list (.use "[1]#[0]" monad)
|
18 |
| - ["?[1]" \\projection]] |
19 |
| - ["[0]" set]]] |
20 |
| - [math |
21 |
| - [number |
22 |
| - [/64 |
23 |
| - ["n" natural]]]] |
24 |
| - [macro (.only with_names) |
25 |
| - ["[0]" syntax (.only) |
26 |
| - ["[0]" export]]] |
27 |
| - ["[0]" meta (.only) |
28 |
| - ["[0]" module] |
29 |
| - ["[0]" name] |
30 |
| - ["[0]" code (.only) |
31 |
| - ["?[1]" \\projection]]]]]) |
32 |
| - |
33 |
| -(exception.the .public (duplicate_parameters [definition parameters]) |
34 |
| - (Exception [Name (List Text)]) |
35 |
| - (exception.report |
36 |
| - (list ["Definition" (name.as_text definition)] |
37 |
| - ["Parameters" (list.as_text %.text parameters)]))) |
38 |
| - |
39 |
| -(exception.the .public (must_have_rest_parameter [definition]) |
40 |
| - (Exception Name) |
41 |
| - (exception.report |
42 |
| - (list ["Definition" (name.as_text definition)]))) |
43 |
| - |
44 |
| -(syntax.the .public (the [[exported? [name parameters] type body] |
45 |
| - (export.with (all ?.and |
46 |
| - (?code.form (?.and ?code.local (?.some ?code.local))) |
47 |
| - ?list.any |
48 |
| - ?list.any))]) |
49 |
| - (monad.let meta.monad |
50 |
| - [[here _] module.current] |
51 |
| - (if (n.= (list.size parameters) |
52 |
| - (set.size (set.of_list text.hash parameters))) |
53 |
| - (with_names ['function] |
54 |
| - (when (list.split 1 (list.in_reverse parameters)) |
55 |
| - [(list &rest) mandatory] |
56 |
| - (let [mandatory (list#each code.local (list.in_reverse mandatory)) |
57 |
| - &rest (code.local &rest)] |
58 |
| - (pure (list (` (.the (, exported?) ((, 'function) (,* mandatory) (, &rest)) |
59 |
| - (, type) |
60 |
| - (, body))) |
61 |
| - (` (syntax.the (, exported?) ((, (code.local name)) [(,* (|> mandatory |
62 |
| - (list#each (function (_ parameter) |
63 |
| - (list parameter (` ?list.any)))) |
64 |
| - list#conjoint)) |
65 |
| - (, &rest) (?.some ?list.any)]) |
66 |
| - (by meta.monad (,' pure) |
67 |
| - (list (` ((, 'function) |
68 |
| - (,* (list#each (|>> , ((,' .,)) `) mandatory)) |
69 |
| - (list ((,' .,*) (, &rest)))))))))))) |
70 |
| - |
71 |
| - _ |
72 |
| - (meta.failure (exception.error ..must_have_rest_parameter [[here name]])))) |
73 |
| - (meta.failure (exception.error ..duplicate_parameters [[here name] parameters]))))) |
| 15 | + ["?[1]" \\projection]]]] |
| 16 | + [macro |
| 17 | + ["[0]" syntax] |
| 18 | + ["[0]" expansion]]]] |
| 19 | + ["[0]" // (.only) |
| 20 | + [poly |
| 21 | + ["[0]" type]]]) |
| 22 | + |
| 23 | +(every (Return return) |
| 24 | + (/.Effect [] return)) |
| 25 | + |
| 26 | +(every (Call' Argument |
| 27 | + argument return) |
| 28 | + (all /.Or |
| 29 | + (Return return) |
| 30 | + (Argument argument return) |
| 31 | + )) |
| 32 | + |
| 33 | +(every (->' Call' Argument |
| 34 | + argument return |
| 35 | + it) |
| 36 | + (.-> (Call' Argument argument return it) |
| 37 | + it)) |
| 38 | + |
| 39 | +(every (Argument argument return) |
| 40 | + (/.Effect argument (->' Call' Argument argument return))) |
| 41 | + |
| 42 | +(every Call |
| 43 | + (Call' ..Argument)) |
| 44 | + |
| 45 | +(every .public -> |
| 46 | + (->' ..Call' ..Argument)) |
| 47 | + |
| 48 | +(the (application function argument) |
| 49 | + (for_any (_ argument return it) |
| 50 | + (.-> (-> argument return it) |
| 51 | + (Call argument return it) |
| 52 | + it)) |
| 53 | + (function argument)) |
| 54 | + |
| 55 | +(expansion.let [#Return (these 0 0b) |
| 56 | + #Argument (these 0 1b)] |
| 57 | + (these (the return |
| 58 | + (for_any (_ argument return) |
| 59 | + (Call argument return |
| 60 | + return)) |
| 61 | + {#Return [[] //.identity]}) |
| 62 | + |
| 63 | + (the (argument it) |
| 64 | + (for_any (_ argument return) |
| 65 | + (.-> argument |
| 66 | + (Call argument return |
| 67 | + (-> argument |
| 68 | + return)))) |
| 69 | + {#Argument [[it] //.identity]}) |
| 70 | + |
| 71 | + (the .public (new' return argument) |
| 72 | + (for_any (_ argument return return') |
| 73 | + (.-> (.-> return' return) |
| 74 | + (.-> argument (Change return')) |
| 75 | + return' |
| 76 | + (-> argument |
| 77 | + return))) |
| 78 | + (function (new total it) |
| 79 | + (when it |
| 80 | + {#Argument [it of]} |
| 81 | + (of (new (argument it total))) |
| 82 | + |
| 83 | + {#Return [_ of]} |
| 84 | + (of (return total))))) |
| 85 | + |
| 86 | + (the .public new |
| 87 | + (for_any (_ argument return) |
| 88 | + (.-> (.-> argument (Change return)) |
| 89 | + return |
| 90 | + (-> argument |
| 91 | + return))) |
| 92 | + (..new' //.identity)) |
| 93 | + )) |
| 94 | + |
| 95 | +(the (partial' argument function) |
| 96 | + (for_any (_ argument return) |
| 97 | + (.-> argument |
| 98 | + (Change (-> argument |
| 99 | + return)))) |
| 100 | + (per ..application |
| 101 | + function |
| 102 | + (..argument argument))) |
| 103 | + |
| 104 | +(syntax.the .public (partial ['function ?list.any |
| 105 | + '*argument (?.some ?list.any)]) |
| 106 | + (pure (list (` (|> (, 'function) |
| 107 | + (,* (list#each (function (_ 'argument) |
| 108 | + (` (..partial' (, 'argument)))) |
| 109 | + '*argument))))))) |
| 110 | + |
| 111 | +(syntax.the .public (of ['function ?list.any |
| 112 | + '*argument (?.some ?list.any)]) |
| 113 | + (pure (list (` (per ..application |
| 114 | + (, 'function) |
| 115 | + (,* (list#each (function (_ 'argument) |
| 116 | + (` (..argument (, 'argument)))) |
| 117 | + '*argument)) |
| 118 | + ..return))))) |
0 commit comments