Skip to content

Commit

Permalink
Don't use use polimorphic coersion on macro return values
Browse files Browse the repository at this point in the history
  • Loading branch information
niwinz committed Aug 19, 2024
1 parent a546283 commit abae3d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/promesa/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
expression."
[& exprs]
`(pt/-mcat
(pt/-promise nil)
(impl/resolved nil)
(fn [_#]
(promesa.core/do* ~@exprs))))

Expand All @@ -580,7 +580,7 @@
(assert (even? (count bindings)) (str "Uneven binding vector: " bindings))
(c/->> (reverse (partition 2 bindings))
(reduce (fn [acc [l r]]
`(pt/-mcat (pt/-promise ~r) (fn [~l] ~acc)))
`(pt/-mcat (impl/coerce ~r) (fn [~l] ~acc)))
`(do* ~@body))))

(defmacro let
Expand All @@ -589,7 +589,7 @@
[bindings & body]
(if (seq bindings)
`(pt/-mcat
(pt/-promise nil)
(impl/resolved nil)
(fn [_#] (promesa.core/let* ~bindings ~@body)))
`(promesa.core/do ~@body)))

Expand All @@ -599,7 +599,7 @@
[bindings & body]
(assert (even? (count bindings)) (str "Uneven binding vector: " bindings))
`(pt/-mcat
(pt/-promise nil)
(impl/resolved nil)
(fn [_#]
~(c/let [bindings (partition 2 bindings)]
`(c/-> (all ~(mapv second bindings))
Expand Down
10 changes: 5 additions & 5 deletions src/promesa/impl.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
(.completeExceptionally ^CompletableFuture p v)
p)))

#?(:cljs
(defn coerce
"Coerce a thenable to built-in promise impl type."
[v]
(impl/coerce v)))
(defn coerce
[v]
(if (promise? v)
v
(resolved v)))

(defn all
[promises]
Expand Down

0 comments on commit abae3d6

Please sign in to comment.