Code examples in the documentation don't return what's expected
- Dominant language
- Clojure
- Stars
- 970
- Forks
- 68
- PR merge metrics
- No merged PRs in 30d
Description
Versions used:
- `[org.clojure/clojure "1.10.1"]`
- `[funcool/cats "2.3.6"]`
- `[funcool/promesa "5.1.0"]`
ns form:
``` clojure
(ns user
(:require
[cats.builtin]
[cats.core :refer [bind return alet mlet fmap fapply]]
[cats.monad.maybe :refer [just]]
[cats.labs.promise]
[promesa.core :as p]))
```
When evaluating the examples provided in https://funcool.github.io/cats/latest/#alet, some results don't match what is shown in the doc:
``` clojure
(macroexpand '(alet [a (just 1)
b (just 41)]
(+ a b)))
;; =>
(fapply
(fmap
(fn [a]
(fn [b]
(do (+ a b))))
(just 1))
(just 41))
;; the documentation suggests it returns:
(fapply (fn [a]
(fn [b]
(do
(+ a b))))
(just 1)
(just 41))
```
The asynchronous code raises an exception:
``` clojure
(defn sleep-promise
"A simple function that emulates an
asynchronous operation."
[wait]
(p/promise (fn [resolve reject]
(future
(Thread/sleep wait)
(resolve wait)))))
(time
@(mlet [x (sleep-promise 42)
y (sleep-promise 41)]
(return (+ x y))))
;; Execution error (ClassCastException) at user/eval34213$fn$fn (user.clj:4).
;; class user$sleep_promise$fn__34206 cannot be cast to class java.lang.Number (user$sleep_promise$fn__34206 is in unnamed module of loader clojure.lang.DynamicClassLoader @571ca823; java.lang.Number is in module java.base of loader 'bootstrap')
```
Anyway thanks for the work already done on this library!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.