Fork me on GitHub
#clojure-uk
<
2019-02-12
>
yogidevbear09:02:14

For anyone that happens to find themselves near Horsham on the 2nd Wednesday of the month (starting in March), we'll be hosting a FP coding dojo primarily focused on using Clojure https://www.meetup.com/Horsham-Functional-Programming/events/xklqrqyzfbrb/

👍 25
3Jane10:02:45

Coercion gives me such mixed feelings

3Jane10:02:50

On one hand, immensely convenient

3Jane10:02:36

On the other hand, it’s rare to be able to make use of the convenience because data sources are untrustworthy. Even when you’re moving data internally, you can hit on things like upper bounds of ints being different between contexts 😕

mccraigmccraig11:02:23

almost all my coercion is done from JSON submitted to #yada HTTP APIs - coercion and schema-checking happen at the same time, so it's well defined what happens in the case of any failure (generally a 400 response) - it's a big win for this use-case

3Jane11:02:07

yeah… I’m doing it the other way round, sending out JSON from a GraphQL API

3Jane11:02:30

turns out GraphQL standard has a smaller upper bound for what constitutes ints than PHP (or JS)

guy10:02:18

Morning!

guy10:02:10

Minor question for today: (some true? [false true false]) or (some identity [false true false]) Or don’t care?

practicalli-johnny11:02:49

This expression defines the intent to determine if a collection contains a Boolean true value. (some true? [false true false]) The other expression seems quite vauge as to its intent, therefore I would avoid.

👍 10
guy11:02:09

Yeah I think the reason why I would use, Identity as ive seen it used before for things like filter identity keep identity and things like that. I like the intent idea :thumbsup:

Rachel Westmacott14:02:46

I prefer to (remove nil? ...) or (remove false? ...) then to (filter identity ...)

5
practicalli-johnny16:02:31

partition-by identity is a nice one I picked up from http://4Clojure.com exercises

bronsa10:02:30

depends whether you're know you have a vector of bools or not

bronsa10:02:36

if you do, don't care

bronsa10:02:43

if you don't, they're semantically different

bronsa10:02:07

testing for truth vs truthiness

👍 5
3Jane10:02:51

so, BBC vs the Sun 🔥

😂 20
thomas11:02:11

but what about the Daily Mail?

😱 5
3Jane11:02:32

@U052852ES …and we’re back to coercion… :]

💥 25
15
maleghast12:02:47

Morning everyone

thomas13:02:48

just found the problem after staring it for hours....`=` instead of === in JS. if only we had immutable data structures... maybe one day someone will come up with some decent immutable data structures that are simple to use, have good performance etc.

😬 5
alexlynham13:02:13

I tend to use identity pervasively I think because when dealing with potentially bad data (i.e. er, all data) truthy is as confident as I'm usually likely to be

guy13:02:04

What are peoples thoughts on spec2 vs spec? 😅

mccraigmccraig14:02:30

what does spec2 do differently @guy ?

mccraigmccraig14:02:15

those seem like sane changes

👍 5
otfrom14:02:53

or indeed, coherent ones. 😉

👍 5
rickmoynihan15:02:08

@guy: Not used it — but have been following it with interest… my feeling is don’t use it for anything real just yet. The fact it doesn’t integrate with clojure yet etc will likely cause problems; and I suspect it’ll be a faster moving target than spec.alpha 1

👍 5
rickmoynihan15:02:54

The main reason to use it is if you need to generate specs programatically — though I’d personally avoid it for that just now too, at least until the dust settles a bit

Wes Hall17:02:23

Anybody ever read documentation pages like the one linked above and think, "Yup, Rich definitely wrote this!"

seancorfield17:02:47

We have a branch at work with all our code running on spec2.

seancorfield17:02:27

A few changes have been a bit inconvenient but overall it's been relatively smooth. The changes definitely "make sense" once you get your head around them.

Wes Hall17:02:29

I don't fully understand the changes, probably need to read that doc page a few more times... but I have learned the word "explicate".

seancorfield17:02:46

Spec1 had a very blurred line between "spec" and "predicate" and spec2 makes that line crystal clear (which highlights all the places where you accidentally used a predicate instead of a spec! 🙂). There's also a very clear line between "symbolic specs" and "spec objects" now.

seancorfield17:02:54

(and, nicely, there are two entry points for programmatically defining specs now)