~nasser/8fl

47a58ddabe07652a8e1fdbb044bac7d340463d88 — Ramsey Nasser 2 months ago dc9c952
Add <&> and <?> sequence macros
1 files changed, 15 insertions(+), 1 deletions(-)

M api-macros.fnl
M api-macros.fnl => api-macros.fnl +15 -1
@@ 5,6 5,20 @@
        (tset _CYCLES ,name# (cycle [,...])))
      ((. _CYCLES ,name#)))))

(fn <&> [...]
  (let [name# (tostring (gensym :cycle))]
    `(do
      (when (not (. _CYCLES ,name#))
        (tset _CYCLES ,name# (cycle (& ,...))))
      ((. _CYCLES ,name#)))))

(fn <?> [...]
  (let [name# (tostring (gensym :cycle))]
    `(do
      (when (not (. _CYCLES ,name#))
        (tset _CYCLES ,name# (choice-of [,...])))
      ((. _CYCLES ,name#)))))

(fn $> [...]
    (match (# [...])
        0 nil


@@ 18,4 32,4 @@
                    ;; accomplishes this
                    (balance-and-render! 1 args#))))))

{ : <> : $> }
\ No newline at end of file
{ : <> : <&> : <?> : $> }
\ No newline at end of file