Fork me on GitHub
#clojure-uk
<
2017-03-16
>
thomas08:03:41

@agile_geek the Welsh flag is missing from the emoji's 😞

agile_geek08:03:52

@thomas it's more disappointing to me that there's no massive Welsh dragon right in the middle of the Union flag...but that's what you get for being a conquered Principality.

thomas08:03:53

true... it always kinda bothered me as well that Wales isn't recognised in the Union Flag.

thomas08:03:18

Maybe once Scotland and NI become a separate country they can have St. Andrew's and St. Patricks cross and England/Wales can have a St. George's cross with a big badass dragon on it.

jasonbell08:03:26

<<NI become a separate country>> as declarations of war goes, that's a pretty good one.

korny09:03:24

I wonder if Scotland (or Wales or whoever) don't have a union jack on their flag - maybe Australia can finally lose theirs?

agile_geek09:03:14

@korny hey, Australia had it's chance to become a Republic...

agile_geek09:03:54

and interesting that NZ didn't ditch the Union flag bit of the flag either

korny09:03:01

yeah. It was a lesson in how to run a referendum while simultaneously undermining it. Why didn't the #brexit planners learn how to do that?

korny09:03:46

If the majority of people want to do X, put up a vote with "do nothing", "do a poor version of X", and "do a different poor version of X" as options. \

korny09:03:02

The sad thing about brexit is, it was precisely the opposite - "do nothing" vs "do a vague idealistic undefined version of X"

jonpither09:03:52

Hi all, if anyone wants to spread some UK Clojure love and good feelings the way of this company, allow me to plug for a RT: https://twitter.com/juxtpro/status/842307041309913088

jasonbell09:03:02

Oh reminds me of my PA/Sporting Life days.

glenjamin09:03:15

that’s an old picture of sheffield 😄

glenjamin09:03:56

oh neat, i’m in that team photo

jonpither09:03:19

hmm, if it's really old I could change it 🙂

glenjamin09:03:38

it’s only noticeably old if you know sheffield pretty well

glenjamin09:03:49

it’s the tram livery that gave it away

glenjamin09:03:03

i had a quick look for a better one, but nothing jumped out

jonpither10:03:23

thanks for setting up @glenjamin

jonpither10:03:20

what happened to the tram?

glenjamin10:03:59

they got repainted

glenjamin10:03:18

without the bands

agile_geek10:03:06

@glenjamin you do look like you're about to be eaten by the revolving door tho!!

thomas12:03:02

I have a rather weird problem.... I am getting a stacktrace in our Immutant app. but not when I call the same function from the repl.

thomas12:03:41

and even weirder.. when I don't remove a key from the map it works as well.

Rachel Westmacott12:03:18

removing keys from records can turn them into ordinary maps?

thomas12:03:37

it is not a record... just an ordinary map

thomas12:03:00

no defrecord in the code

thomas12:03:59

Has anyone here ever use walk or postwalk ?

agile_geek13:03:48

postwalk but only once

dominicm13:03:22

I use postwalk all the time… It's good 😄.

dominicm13:03:34

You'll likely find that the inputs are subtly different when using Immutant. If you're using CIDER I suggest plugging the debugger into the web request itself if you can. If not, it's time to sprinkle in some printlns 🙂.

dominicm13:03:15

Types can subtly change with maps & # of keys. But I would hope the code isn't coded to clojure.lang.TheLargerPersistentMap or something similar to that.

thomas13:03:37

hmmm ok.... I'll try a few things more.

thomas13:03:21

I found a few examples that change particular values in a map.. but I need to do it in nested maps as well... postwalk would be really good for this.

dominicm13:03:20

Yeah, postwalk is designed for that 🙂

dominicm13:03:52

Should just be:

(postwalk (fn [x] (if (map? x) (update-map x) x)) input

agile_geek13:03:47

@thomas of course you could also look at traversy and spectre for that.

dominicm13:03:13

I think that postwalk should be more than sufficient for this kind of task.

dominicm13:03:03

Specter is targetted at mostly known deep paths into a structure (Update every odd element, nested 5 levels deep inside this structure)

thomas13:03:40

and it is with postwalk that we get the stacktrace 😞

thomas13:03:46

a java.lang.AbstractMethodError of all things... doesn't even make sense (at the moment at least)

thomas13:03:23

and that looks very similar to our code @dominicm

thomas13:03:10

And we can't really switch to Spectre either... running an older version of clj at the moment.

agile_geek13:03:40

Your getting some strange things here....could this be some odd AOT side effect?

thomas13:03:24

could be.... but how would I determine that is the case?

dominicm13:03:57

@thomas Are you able to run the uberjar locally?

dominicm13:03:38

@thomas Are they definitely maps? And not, e.g. datomic entities?

thomas13:03:00

I can run it locally... but then I don't see it... I am running a newer version of Java though. and yes Datomic is involved.

thomas13:03:28

:page {:db/id 17592186050855} is the key that is offending.

dominicm13:03:29

Yeah, this sounds like that then

dominicm13:03:36

Yeah, datomic entities are not maps

thomas13:03:53

what to do then?

dominicm13:03:03

Do this: (into {} my-entity) as part of the postwalk?

thomas13:03:29

at the moment we do this (clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m))) where f is our function

thomas13:03:10

so what about doing a into {} when we get back the data from Datomic?

dominicm13:03:25

Could do, as long as you don't need to use it as an entity later.

dominicm13:03:47

Are datomic entities passing map? I wonder :thinking_face:

dominicm13:03:02

I mean, tbh, you probably want to do a d/pull to turn them into a map

thomas13:03:52

ok let me have a look at the code (I didn't write it of course)

dominicm13:03:29

A datomic entity does not pass the map? predicate

thomas13:03:32

it looks like we do this:

thomas13:03:40

(defn export-entity
  [entity]
  (into {} entity))

dominicm13:03:59

If you perform (d/pull db '[*] eid) it will get all the attributes off the member and put them into a map (which passes map?)

dominicm13:03:44

^^ That also works if you have a whole entity

dominicm13:03:14

I wonder if that's sufficiently recursive…

agile_geek13:03:37

or you can do what we do a style and specify only the attributes required in the pattern

agile_geek13:03:57

and you can use pull syntax in the query too

dominicm13:03:00

We've moved away from that. It limits consumers of the querying functions.

dominicm13:03:10

And you get ~50 attributes randonly added.

agile_geek13:03:11

Not if they pass the pattern

dominicm13:03:22

That's the other option, but at that point, you may as well just use entities.

agile_geek13:03:36

not if they're remote

dominicm13:03:12

You'd have to be more explicit about what remote means. But I suppose yes. Though I'd still make that an endpoint feature rather than db.

dominicm14:03:36

@thomas So yeah, the answer is to either add an extra (into {}) into your postwalk, or explicitly update that key before passing it in (with (update :page #(into {} %)). Which you do depends on the appropriate level of abstraction for yourr use-case.

thomas14:03:32

ok let me try that. thank you

agile_geek14:03:48

@dominicm I agree it's definitely an end point feature to allow fine control over what a client can 'pull' rather than just exposing the datalog syntax to a client but having pull syntax type semantics across the client-server boundaries can be useful

agile_geek14:03:50

You need control at the end point if only for validation and security (which also involves validation btw to ensure you can't do the equivalent of SQL injection)

dominicm14:03:26

@agile_geek The database functions should probably be agnostic of whether they're being exposed to the world or just used internally in the same JVM. The Endpoint can do the (d/pull) equivalent on the entity it receives if it chooses.

agile_geek14:03:43

Hmm, what's the overhead in terms of memory or performance if you have to map the pull over a large collection of entities rather than asking datomic to resolve it in one query? (I don't know Datomic's internals well enough to judge)

dominicm14:03:50

It's approximately the same if you just use (d/pull-many) 🙂

dominicm14:03:41

Though you'd need a large number of entities coming back from queries to even notice in the first place.