Skip to content

Commit

Permalink
amb, input, watch docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
leonoel committed Jan 26, 2024
1 parent d49f979 commit 90d729e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/hyperfiddle/electric_de.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,39 @@
#?(:cljs (:require-macros hyperfiddle.electric-de)))

(defmacro join [flow] `(::lang/join ~flow))
(defmacro input [& flows] `(join (r/fixed-signals ~@flows)))
(defmacro watch [ref] `(input (m/watch ~ref)))
(defmacro ctor [expr] `(::lang/ctor ~expr))
(defmacro call [ctor] `(::lang/call ~ctor))
(defmacro pure [v] `(::lang/pure ~v))
(defmacro amb [& exprs] `(call (join (r/pure ~@(mapv #(list `ctor %) exprs)))))

(defmacro fn [bs & body]
`(ctor
(let [~@(interleave bs (eduction (map #(list ::lang/lookup %)) (range)))]
~@body)))

(defmacro amb "
Syntax :
```clojure
(amb table1 table2 ,,, tableN)
```
Returns the concatenation of `table1 table2 ,,, tableN`.
" [& exprs] `(call (join (r/pure ~@(mapv #(list `ctor %) exprs)))))

(defmacro input "
Syntax :
```clojure
(input cf)
```
Returns the current state of current continuous flow `cf`.
" [& flows] `(join (r/fixed-signals ~@flows)))

(defmacro watch "
Syntax :
```clojure
(watch !ref)
```
Returns the current state of current reference `!ref`.
" [ref] `(input (m/watch ~ref)))

(defmacro diff-by "
Syntax :
```clojure
Expand Down

0 comments on commit 90d729e

Please sign in to comment.