emacs-promise icon indicating copy to clipboard operation
emacs-promise copied to clipboard

[Feature Request] anamorphic version of the functions in the spirit of dash

Open yyoncho opened this issue 4 years ago • 3 comments

Here it is how it will look like:

(promise-chain (do-something-async 1 33)
  (thena (message "first result: %s" result)
         (do-something-async 1 (* result 2)))
  (thena (message "second result: %s" result)
         (do-something-async 1 (* result 2)))
  (thena (message "third result: %s" result)))

yyoncho avatar Jul 25 '20 16:07 yyoncho

Unfortunately, I can't find a better way to writethenas suggested, since it takes two functions as arguments, as shown below.

(promise-chain (do-something-async 1 33)
  (then (lambda (value)
          (message "value -> %s" value))
        (lambda (reason)
          (message "error: reason -> %s" reason))))

chuntaro avatar Jul 27 '20 07:07 chuntaro

Hh, can we use thena only for the positive case and let catcha handle the error? Does this make any sense?

(promise-chain (do-something-async 1 33)
  (thena (message "result -> %s" result))
  (catcha (message "error: reason -> %s" error)))

yyoncho avatar Jul 27 '20 07:07 yyoncho

I've added an anaphoric version!

chuntaro avatar Jul 27 '20 09:07 chuntaro