Fork me on GitHub
#clojure-spec
<
2016-08-09
>
gfredericks12:08:12

@xcthulhu: I can't resist a good arithmetic bug

xcthulhu12:08:15

Okay I'm going to have to try to fix one now too. Google Closure doesn't handle UTF-8 properly, so every time I've tried to use it for taking SHA256 of unicode it's been borked.

xcthulhu12:08:37

Also I was curious how to speed up division, the way GMP does it is by divide and conquer reducing the problem to Möller-Granlund division: https://github.com/SaberMod/gnu-gmp/blob/faf7424576910eca222b0ddaea6bbe490e10e70e/mpn/generic/dcpi1_div_qr.c

calvis15:08:17

(s/def ::basically-an-integer
  (s/or :exact integer?
        :inexact #(and (number? %)
                       (zero? (- (int %) %)))))
(s/def ::basically-a-positive-integer
  (s/and ::basically-an-integer pos?))

user> (s/conform ::basically-an-integer 1.0)
;; => [:inexact 1.0]
user> (s/conform ::basically-a-positive-integer 1.0)
;; => ClassCastException   [trace missing]
running into this error, I realize it’s because s/and passes along the conformed value. is there an alternative to s/or or s/and that doesn’t add/pass along conformed information? would rather not have to think about the conformed value of the earlier spec when the spec essentially means “it’s safe to call pos? on it"

eggsyntax15:08:48

@alexmiller: realizing that there hasn't been an alpha release in nearly a month makes me wonder: would you say that spec has pretty much stabilized at this point? Not that I'm requesting any sort of commitment to that, of course; just curious what your sense is.

Alex Miller (Clojure team)16:08:59

Rich has just been busy/ooo

Alex Miller (Clojure team)16:08:12

We have a ton of stuff queued up :)

eggsyntax16:08:23

Makes sense, thanks! Looking forward to checking it out 😄

Alex Miller (Clojure team)16:08:33

@calvis Rich has suggested having both a flowing and non-flowing version of and and I think it’s likely that will eventually happen (probably and-> for flowing and and for non-flowing, although that changes the current meaning of and)

calvis16:08:19

@alexmiller: yeah, that would be helpful. can’t really keep track which of my specs are or’s and which aren't

Alex Miller (Clojure team)16:08:44

one option here is to use s/conformer in ::basically-a-positive-integer to unwrap

Alex Miller (Clojure team)16:08:26

(s/def ::basically-a-positive-integer (s/and ::basically-an-integer (s/conformer val) pos?))