Fork me on GitHub
#clojure-spec
<
2017-10-26
>
bbrinck00:10:52

@b.j.vanderes FWIW, my understanding is that conformers are not intended to be used to change the shape of the data, so you may run into problems here. Perhaps it’d be easiest to just conform as normal, then write a transformation function that uses the conformed values and converts them

Brendan van der Es01:10:58

@bbrinck @hiredman Yea, this is all probably too counter to intention to be usable (performance might also be an issue). But just for fun this is what I came up with as far as defining functions that process the conformed arguments:

Brendan van der Es02:10:55

Can combine with above to mitigate an outer layer of branching in the function.

tap08:10:00

I get OutOfMemoryError when calling instrumented function with wrong number of arguments where one of the argument is a huge collection. I know it’s considered user mistake but it’s a kind of mistake that is quite hard to figure out the cause. Should clojure prevent that, or break circuit or something?

alexmiller12:10:33

Would help to know more about the spec and understand why its generating huge collections

alexmiller12:10:49

There are some known issues in this area

tap02:10:25

Sure. I’ll try to come up with a sample project replicating the issue I found this weekend

danielneal11:10:07

What is the best way of getting the specs of arguments to an fdef'd function?

danielneal11:10:11

I've got an approach here

danielneal11:10:37

but it uses eval and is probably all wrong 🙃

alexmiller12:10:18

Yeah, don’t do that :)

alexmiller12:10:55

Just (-> sym s/get-spec :args)

alexmiller12:10:47

Or do you want the spec of each argument separately?

alexmiller12:10:01

In the most general sense (considering multi arity and variadic), I think that is difficult

danielneal12:10:15

yeah - the spec of each argument separately

danielneal12:10:11

thanks for the get-spec tip 🙂

danielneal12:10:45

just doing a very rough and ready thing to see if I can go from a value to the (specced) functions that you can invoke that take that value as an arg

danielneal12:10:51

like intellisense, but stupid

danielneal12:10:57

stupidisense, if you will

alexmiller14:10:30

this is kind of what’s happening inside of spec regex validation checking, but it’s really happening left to right and every possibility is being evaluated and narrowed based on the prior matches (of which there may be multiple)

alexmiller14:10:11

so a priori before starting the parse there is not necessarily a single spec but really a set of specs that may apply at each point

alexmiller14:10:58

that said, there is the very common case that the args spec is a single non-variadic arity and each arg matches up 1-for-1 with an s/cat args spec

alexmiller14:10:22

in which case, you can just pull the s/cat spec apart to match it up

danielneal14:10:05

mm yes I follow you. Technically the args spec for fns could be any regex (or anything) but in practice there will be a common case like you described

danielneal14:10:42

this is what I've got so far - https://gist.github.com/danielneal/d82c142c9eab9f8caec0fa93b87ff7f3 - I'd like to see if I can get it completing in emacs to see if it 'feels' useful. Dumb but proof of concept, like when IDEO demonstrated the talking kitchen with people hidden behind the fridge saying stuff and responding to voice commands.

zclj19:10:43

Sometimes I get errors such as: `java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.test.check.generators/choose, compiling:(generators.cljc:499:3) Exception in thread "main" java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.test.check.generators/choose, compiling:(generators.cljc:499:3)` It happens with different test.check unbound fns, it is not the same every time and a rebuild usually resolves the error. The file that is beeing compiled is a quite basic cljc file with some specs in it. Does anyone have any advice to point me in the right direction?

alexmiller21:10:55

Any chance this is happening during check?

alexmiller21:10:20

There is a dynamic load race that can happen with loading the test check generator namespace that we have a ticket on. I don’t remember [email protected] presents, but it was weird looking

zclj12:10:35

@U064X3EF3 Sorry for the late reply. The stack trace only show line 1 for my files i.e. in the ns loading. The file do include a stest/check test but from the stack trace I do not seem to hit that. It blow up on the first line. I'll try and find the ticket you mentioned and see if that holds any clues

bill19:10:57

in an s/fdef :fn spec for a tree function of mine, it seems like I need to get access to the un-conformed argument (a tree) to the function so I can pass it to some other tree functions to build up my validation. is there a way to gain access to the un-conformed args or perhaps to un-conform the conformed args?

bill19:10:31

is the right word for “un-conform” “unform”?

gfredericks19:10:20

deconformificate