Fork me on GitHub
#clojure-uk
<
2016-12-07
>
agile_geek06:12:04

@bigkahuna and given Clojure is hosted don't underestimate the value of knowing this!

agile_geek06:12:33

I think I've asked this before but those of u using Spec, have u bumped your Clojure version to 1.9alpha or are u using a back port to an earlier version?

agile_geek06:12:36

I ask cos I'm validating an api atm and I'm using schema as I don't want to introduce 1.9alpha

agile_geek06:12:38

However a back port may introduce it's own risk depending on how well it's used/tested. Currently thinking stay with schems

paulspencerwilliams07:12:28

I get to play with Clojure this afternoon.

jasonbell07:12:07

Swap the word “Christmas” for “Clojure” in as many Christmas songs that you can think of...... 🙂

agile_geek07:12:17

@paulspencerwilliams sorry we didn't get time to catch up more at ClojureX. I still owe u a beer or 3 for the lift to West Midlands JUG

agile_geek07:12:16

@jasonbell "Clojure Spec is coming to town"?

paulspencerwilliams08:12:29

"I'm dreaming of a diverse Clojure community"

agile_geek08:12:57

@paulspencerwilliams that one is so close to the truth I'm not sure whether to laugh or cry?

paulspencerwilliams08:12:38

@agile_geek yeah. I did start to write "I'm dreaming of a white..." and then I thought about it and nah!!!

paulspencerwilliams08:12:09

@agile_geek ClojureX was pretty diverse which is great. It's wonderful to hear so many accents, languages etc.

paulspencerwilliams08:12:59

@bigkahuna

<dependency>
		  <groupId>org.ocpsoft.prettytime</groupId>
		  <artifactId>prettytime-nlp</artifactId>
		  <version>4.0.0-Final</version>
	  </dependency>
still fails for me...
[ERROR] Failed to execute goal on project wat: Could not resolve dependencies for project wat:wat:jar:1.0-SNAPSHOT: Could not find artifact org.ocpsoft.prettytime:prettytime-nlp:jar:4.0.0-Final in central () -> [Help 1]

agile_geek08:12:31

I was a little disappointed with our diversity count amongst the speaker... but it wasn't for want to trying. I'm open to suggestions about how we improve next year

agile_geek08:12:44

@jasonbell are u using spec? If so, have you gone to 1.9.alpha?

petem08:12:29

Morning, @bigkahuna I think that needs to be 4.0.0.Final 🙂

paulspencerwilliams08:12:37

@petem @bigkahuna yeah, their 4.0.1.Final pom points to a 4.0.1-SNAPSHOT #DOH

jasonbell08:12:51

@agile_geek personally no, but it’s worth chatting to @otfrom and @tcoupland who have.

tcoupland08:12:46

we are pretty spectastic it's true

tcoupland08:12:44

cld ramble on about it for ages 🙂

peterwestmacott09:12:22

don’t let us stop you

peterwestmacott09:12:09

I’ve only done a little spec, but I’d gladly hear more from someone who has

tcoupland09:12:22

well, it would take me a while to type it all out, if only there was some sort of long form of Slack, but keeping the gushing over how it's allows data first development, the generative testing is so much better than it has been before (you can get some good pay off for your efforts, at last), test time enabling of data checks

tcoupland09:12:24

there is a wart

tcoupland09:12:35

and it's the conformers side of things

tcoupland09:12:05

after quite a bit of heart arch i'm going to steer clear of them for a while

tcoupland09:12:39

especially clear of any use of them as a 'coercer' ala plumatic schema

tcoupland09:12:18

this comes down to the fact that you can't round trip things through them, i.e. something that matches the spec, that is conformed, will no longer match the spec

tcoupland09:12:27

they just aren't for using like coercers, it appears they really are just for helping with variadic fn args

tcoupland09:12:36

something i also don't do

peterwestmacott09:12:04

glad I asked, that sounds worth knowing

mccraigmccraig09:12:43

@tcoupland with schema you would normally take something that may not match the schema and coerce it into something which does match the schema... and if it already matches it would be unchanged - how does spec/conforming differ ?

tcoupland09:12:02

the clearest example is if you have a s/cat in your spec, a vector of values will match, but if you conform it, it will be turned into a map !

tcoupland09:12:18

(s/def ::ingredient (s/cat :quantity number? :unit keyword?))
(s/conform ::ingredient [2 :teaspoon])
;;=> {:quantity 2, :unit :teaspoon}

tcoupland09:12:00

it should'nt be a surprise, it's right there in the docs and everything, but, i for one, kinda of heard 'conform' and though 'coerce' and it takes a little while to get over that assumption.

agile_geek09:12:09

Yeah me too. I think the choice of conform as the fn name was very deliberate as it suggests to me bending something to fit a rule or specification.

agile_geek09:12:29

and there's a difference between a specification and the data

agile_geek09:12:44

that matches that spec

peterwestmacott09:12:58

it seems almost like a “higher-order” data structure that describes the actual data structure

agile_geek09:12:34

Yep. It's very meta. As I think of it, it's meta data wrapped around the data

dominicm09:12:03

@agile_geek, @seancorfield is using 1.9 alpha in prod, and to the best of my knowledge is very happy with it.

tcoupland09:12:53

the other problem is just were to put these things, I've not had so much trouble with cyclic dependencies for years!

mccraigmccraig09:12:41

@tcoupland if you were to (s/conform ::ingredient {:quantity 2, :unit :teaspoon}) it would presumably remain unchanged ? so it's like maps are the archetypal structures ?

agile_geek09:12:21

@dominicm cheers really useful to know. I think I may stick with Schema as I can't unilaterally enforce a version change on 25 other developers...especially when I'm just a contractor brought in to ship code.

agile_geek09:12:03

@mccraigmccraig that's my understanding

tcoupland09:12:48

(s/conform ::ingredient {:quantity 2, :unit :teaspoon})
:clojure.spec/invalid

tcoupland09:12:01

s/cat is for lists, it won't match maps

tcoupland09:12:49

(s/valid? ::ingredient {:quantity 2, :unit :teaspoon})
false

mccraigmccraig09:12:17

oh, i see - so conform is really a way of extracting the named fields from the given structure in map form

tcoupland09:12:54

i'm going to say 'yes', but you can make it do a lot more that that, with custom conformers

tcoupland09:12:29

you can get very close to it working like coerce, but your playing with fire by doing it, as that is not really it's motivation

agile_geek09:12:39

I guess the intent is to provide a canonical representation for the data that conforms to a spec?

mccraigmccraig09:12:30

yeah, i can see the utility

dominicm09:12:41

My (limited) experience is that spec is excellent in it's domain (function arguments, macros), but isn't suited outside that domain. E.g. Form validation, anything that touches the db,

agile_geek09:12:19

@dominicm interesting. What makes you say that?

mccraigmccraig09:12:24

i guess i'm not going to be ditching schema anytime soon though - i use it quite heavily for coercing JSON off of the network

tcoupland09:12:40

@dominicm i'm using it for exactly that 🙂

tcoupland09:12:53

so really interested to hear to hear more!

dominicm09:12:56

@agile_geek my interest in data specifications comes from user facing mostly. My litmus test is a registration form. With spec you can't pass in lookup information, like A database connection, and use s/keys, to validate that the email is unique. The other case it can't handle is fields where checking must be done across multiple keys (password, password-confirmation) but the error must be attached to password-confirmation - so you can no longer use a generic parse for errors.

agile_geek09:12:28

Cool. Makes sense

dominicm09:12:46

Worth noting that schema can't handle the latter either.

agile_geek09:12:56

Just what I was thinking

dominicm09:12:08

Libraries such as vlad can though.

agile_geek09:12:16

I think we would be 'complecting' multiple concerns if they did

agile_geek09:12:57

I don't think spec or schema's motivation is cross field validation for example. They are more active documentation and runtime type checking in my mind but happy to be proved wrong as my experience with both is very limited.

tcoupland09:12:01

ah, i'm not quite using it for that.

agile_geek09:12:21

Anyway, this conversation is too fascinating and distracting me from work so back to the grindstone...but keep posting and I'll catch up with thread later

tcoupland09:12:52

it does feel like real work time doesn't it

dominicm09:12:50

My train is delayed. I've got ages to distract you all :)

dominicm09:12:53

To me, I want a single format to describe my data. That's how you create a series of filters where the first layer doesn't create something which conforms to the second layer, but you can't convey errors from the second layer back to your user. I have one concept of a registration form in my application. I don't think checking it with vlad and then spec provides any value. I want to be able to describe it ONCE, and then use it as I need (form validation, generation, function arguments, etc)

dominicm09:12:40

I'm not saying that my data validation library should know how to generate html necessarily, but it should be simple to write that extension.

tcoupland10:12:38

@dominicm that sounds like a lot of concerns in one thing to me, but my use cases are a bit different

glenjamin10:12:46

but attaching errors onto password-confirmation isn’t part of your data

glenjamin10:12:44

representing a data model and accepting+coercing user input into said data model are (imo) slightly different but related goals

mccraigmccraig10:12:18

sure - but it doesn't sound unreasonable to want to use the same representation of model for both purposes

glenjamin10:12:42

i think it’s a decent goal, but the edge cases don’t overlap

dominicm10:12:56

The tool that provides my model doesn't even need to know about all uses, if sufficiently easy to parse it should be possible to interact with my model in an infinite number of ways.

mccraigmccraig10:12:17

@glenjamin dyu mean that the edge cases in these few implementations don't overlap, or that there is some fundamental reason why the required edge cases can never be satisfied by a single implementation ?

glenjamin10:12:41

i’m not sure, it’s just that it always seems to pan out this way

glenjamin10:12:53

every all-in-one model+form system i’ve used has been awful

glenjamin10:12:26

for instance, with a data modelling hat on, “this field must be equal to this other field” is a bit silly - you’d just normalise and remove the second field

glenjamin10:12:37

eugh, i’m trying to stop using the word “just” 😞

mccraigmccraig10:12:30

i'm not thinking that all the form-validation requirements should be satisfied by a data-modelling lib - but that a form-validation lib should be able to build upon the provisions of a data-modelling lib without requiring me to re-specify a bunch of stuff which is already adequately specified seems reasonable

glenjamin10:12:51

yeah, i don’t disagree there

glenjamin10:12:37

I would imagine you’d use spec to model your internal “user” data structure, and the registration form would use something slightly more validation focused, and then once registration validation is passed you’d assemble the user

mccraigmccraig10:12:05

that seems sane. i'm a bit disappointed that you can't use spec to coerce the user back to it's true form after passing it through a type-hostile network format like JSON though

glenjamin10:12:16

mm, although i’d suspect the spec itself is introspectable enough to do that?

glenjamin10:12:35

or would the arbitrary-predicate stuff get in the way?

mccraigmccraig10:12:24

could be. i am a spec n00b though, so i don't really know -just going by what was said above

dominicm10:12:42

Swagger parsing exists, but it requires that all your specs look like: (s/and str? my-custom-pred) So you have to pollute your specs with a subset of predicates that can be understood.

dominicm10:12:00

This is also required for test.check, so maybe it's only me who's bothered by this. test.check works by generating random strings, and seeing if they match the second predicate. Spec has built in mechanisms for specifying a custom generator. It's not generic though, so doesn't apply to other use cases outside generators.

tcoupland12:12:17

going to change tack here a little, i've got an annoying problem, maybe someone can help

tcoupland12:12:06

uploading files to a webserver, there are some required headers, when they aren't present I want to return a 400. Simple you say

tcoupland12:12:09

however, what seems to be happening, is the clients are just reacting to the socket closure and not seeing that they have a response to read

tcoupland12:12:37

as the server is, quite rightly in my view, closing the socket once it has responded with the 400 and not bothering to read the rest of the upload

tcoupland12:12:50

now, curl handles this very nicely:

tcoupland12:12:26

HTTP/1.1 400 Bad Request
< Content-Length: 478
< Content-Type: application/json
< Server: Aleph/0.4.1
< Connection: Keep-Alive
< Date: Wed, 07 Dec 2016 12:20:08 GMT
* HTTP error before end of send, stop sending
< 
{"status":400, etc, etc]

tcoupland12:12:06

but, http-client just throws a SocketException and http-kit just seems to hang until the request gets timed out.

tcoupland12:12:04

i'm wondering if anyone else has had this trouble...

tcoupland12:12:02

this is a multipart request, btw

tcoupland12:12:55

i'm just about to try and quick hack of http-kit's client to see if it does have the response on timeout, might be able to fashion a real solution from there, but i'd rather not have to do that 🙂

mccraigmccraig12:12:19

i haven't had that trouble - server behaviour is entirely reasonable though, and presumably since the server couldn't close the socket until after it had written its 400 response, the 400 response should be buffered and readily available for the client to return if it wasn't throwing its toys out of the pram because the socket was closed

mccraigmccraig12:12:44

have you tried aleph's http client ? i've been using it plenty and the experience has been good - though i haven't deliberately exercised it in this particular way

tcoupland12:12:54

it doesn support multi-part 😞

tcoupland12:12:03

i have just hacked http-kit to read the response on timeout

tcoupland12:12:05

and it worked!

tcoupland12:12:24

so the response is really there

tcoupland12:12:36

yeah, i'm not sure i wanted it to work 🙂

tcoupland12:12:33

well, now it means i'm going to have to probably install a java ide for the first time 4 years, to do a real fix

tcoupland12:12:10

and fix http-client as well i guess

mccraigmccraig12:12:46

haha, good luck

otfrom13:12:08

tcoupland some nice java modes for emacs

otfrom13:12:17

(and easy to use if your change is reasonably small)

otfrom13:12:05

though I just used built in java-mode last time

otfrom13:12:19

I used to use JDEE, which seems to have come back to life

peterwestmacott13:12:49

intelliJ has a free edition which is v. powerful (esp. for Java)

peterwestmacott13:12:32

I’m surprised aleph doesn’t do multi-part - I thought yada did, and I thought yada ran on aleph

mccraigmccraig13:12:17

yada does do multipart server handling @peterwestmacott , but it's all yada not aleph

tcoupland13:12:32

yada does multi-part as a server, but aleph client... what he said 🙂

peterwestmacott13:12:47

gotcha, thanks for clearing that up

mccraigmccraig13:12:50

i imagine aleph client would be fine if you did your own multipart encoding and POSTed that, but it's certainly nicer to have your http client look after such details

agile_geek13:12:57

@otfrom I must try meghanada-emacs sometime. Tried jdee about 18 months ago and found it lacking..Moot point in my last client as even IntelliJ was 'illegal'!

mccraigmccraig13:12:38

dare i ask what was 'legal' @agile_geek ?

agile_geek13:12:15

I'll give you a clue: It blocks out the Sun

agile_geek13:12:14

Actually, it wasn't even that IDE...it was a 'hacked' version that had stuff to allow you to test without Websphere as IBM charge $1M per user license*

agile_geek13:12:25

* OK slight exageration

mccraigmccraig13:12:06

huh, crazy hippies wanting to test without websphere

jasonbell16:12:42

IntelliJ Idea for Java, Emacs for Clojure. I tried IntelliJ for Clojure and got annoyed really quickly.

jonpither16:12:12

gonna buy a clojurex ticket for next year me thinks

jasonbell16:12:00

When’s the CFP @agile_geek ?

peterwestmacott16:12:04

@jasonbell, really? with Cursive I find IntelliJ great for Clojure - of course it stops being free then...

jasonbell16:12:24

@peterwestmacott well there's the bruce element to take into account 😉 then the CIDER element and I used to be an Eclipse user in years gone by. Emacs works for me now, just took a bit of time to get there.

tcoupland16:12:23

i did try cursive, a while ago, it gave me night terrors, reminded me of eclipse to much

tcoupland16:12:02

i found the lack of consistent key bindings across all the different panes the real killer

dominicm16:12:26

Vim for Clojure vim 😎

agile_geek16:12:43

@jasonbell dont know yet. Probably not until June/July

seancorfield17:12:38

IDEs are very subjective. I’ve tried IntelliJ multiple times, across many different versions, and there’s just something about it I can’t grow to like. I used Eclipse/CCW for a while when I was first working with Clojure (I was used to Eclipse for other language stuff prior) but I made the jump to Emacs (well, back to Emacs after a 20 year gap!) and have been very happy since. That said, I’m trying Proto REPL (Atom) right now b/c of Jason Gilman’s talk at Conj.

dominicm17:12:02

The graphing stuff in ProtoREPL was very impressive last time I looked (really want to steal it & integrate into nyaovim or something). Has it gone further (I have no internet to watch a talk :()

petem17:12:49

IDEs are really necessary for ent java. I'm also trying out proto-repl at the moment. Its working well except I just cant get used to Parinfer. Just got to remember to switch to Paren mode!!

agile_geek17:12:53

@jasonbell yeah bl**dy tyranical CTO's eh?

dominicm17:12:58

I think calling them "necessary" is very dangerous. They are necessary because no better plugins have been written yet.

jasonbell17:12:13

@agile_geek I could not possibly comment

jasonbell17:12:46

I may have written a library by June, who knows

agile_geek17:12:26

IMO the killer features for Java are refactoring support and a debugger you can hook into a socket (with the later you don't need plugins to simulate your runtime container just enable debug listening on a port and hook in....assuming the app server you're running on is not a massively expensive proprietary beast....bl**dy WAS...grumble)

agile_geek17:12:11

@jasonbell I aspire to being a tyrant. If you talked to Fi at ClojureX you'll know that I was the CTO that just acquiesced to everything she said!

otfrom18:12:36

bruce is a tyrant

thomas19:12:36

I used Eclipse for many many years.... for obvious reasons.. At last years EuroClojure @cdpjenkins and I explained to Colin Fleming why we weren't using IntelliJ and he thought that was the best reason he had heard so far.

thomas19:12:25

and I have been using Atom as well for quite some time.. I really like parinfer and after having watched the Conj talk I need to look more into it.

glenjamin19:12:43

what was your reason @thomas ?

thomas19:12:30

working for IBM meant that all our tooling was Eclipsed based....

thomas19:12:26

And things like RTC integrate fairly well with Eclipse and I don't think there is a plug in for IntelliJ (but could be wrong)

glenjamin19:12:39

A friend of mine is on the Eclipse team

glenjamin19:12:54

there are some rather fun stories

glenjamin19:12:09

like how they’re moving to Maven, from Eclipse

glenjamin19:12:23

and they moved to Eclipse (as a build tool) from ant

glenjamin19:12:37

so to compile from scratch you need to bootstrap an older version

thomas20:12:20

One of the projects I was one we used both ant and the eclipse tool... two things to maintain was quite a pain.

agile_geek20:12:44

I had to use either Eclipse or IntelliJ at last client (once IntelliJ was sanctioned...yes I wish that was in the sense the CIA mean!) @tcoupland Found that you can switch to Emacs key bindings for both, but it completely freaked out anyone I paired with!