Fork me on GitHub
#clojure-spec
<
2017-07-01
>
bbloom03:07:03

saw some javascript/flowtype code today that has this type:

bbloom03:07:12

declare type Callback<T> = (error: ?Error, result: ?T) => void;

bbloom03:07:45

and the code calling it had the common pattern: if (err) { log(…); return; } process(data)

bbloom03:07:55

but to appease the type checker, had to add if (data) { ...

bbloom03:07:15

meanwhile, spec: (s/alt :failure (s/cat :err ::error) :success (s/cat :err nil? :data ::whatever))

bbloom03:07:33

sure, it isn’t checked statically - but at least it represents the actual right thing!

arohner17:07:50

well, not soon, but I’m actively working on it