Fork me on GitHub
#clojure-uk
<
2018-06-21
>
manas_marthi06:06:14

Good morning all

thomas07:06:16

mogge 😼

maleghast08:06:55

Morning All :-)

hyankov08:06:31

Morning everyone

danielneal08:06:59

HELLO EVERYONE! 📣

📣 8
Rachel Westmacott09:06:57

good morning everyone and HELLO DANIELNEAL!

jasonbell09:06:47

It was good while it lasted

otfrom09:06:50

I should be banned from the interwebs

3Jane09:06:00

do not ever stop being yourself

3Jane09:06:11

I am a connoisseur of bad puns

😍 4
otfrom09:06:40

I'm not though. I have no taste in puns whatsoever and I have a degree in English Lit.

3Jane09:06:44

also had like 3h of sleep so it’s all good bar 3rd world war

😱 4
otfrom09:06:56

ah, don't read the news then

3Jane09:06:49

do not think of the pink elephant…

3Jane09:06:23

given I have a mental auto-ignore on Trump and Brexit news, today’s big story is… summer solstice?

3Jane09:06:34

happy summer solstice everyone 😄

🎉 8
☀️ 4
otfrom09:06:04

hooray! after today every day gets darker until 21st December!

😱 8
otfrom09:06:24

there will be many goths gently glowering in anticipation

😆 4
3Jane09:06:29

no more sunburn, amirite?

3Jane09:06:08

read that as goths gently glowing and it took a moment to parse

3Jane09:06:12

on second thought I need more coffee

jasonbell09:06:12

Limavady sunset time isn't until 2211, so it won't be dark until 11pm.

danielneal09:06:11

WITH CAPS IS FINE!

danm09:06:43

Er, with less caps

otfrom09:06:12

@jasonbell yeah, but your dawn is later you southwesterner you

jasonbell09:06:17

I tend not to notice that bit.

thomas09:06:04

so... my SAD starts today?

Rachel Westmacott09:06:22

have you tried one of those lamps?

thomas09:06:47

I have in the past... didn't do that much for me TBH

jamescroft10:06:40

@seancorfield thanks for your comments on the uberjar stuff the other day, it was exactly what I needed :thumbsup:

maleghast10:06:17

Hello All… I’ve put some feelers out in #react-native already, but do any of you lot have any experience with ReactNative under Clojurescript? We are starting to talk about device-based apps and I am tempted to push hard on ReactNative as a way of keeping our tech-stack Clojure-based and uncluttered…

korny10:06:45

I shouldn’t be surprised, but - the git graph for linux is crazy. My parser doesn’t like 3-way merges - which are pretty rare elsewhere - but not in the linux kernel:

18-06-21 10:43:41 Crobuzon.local WARN [git-cd-log.core:132] - Can't diff commit with more than 2 parents:  790844941ae2d0ccde5892140cc499982800dd46  -  Merge branches 'for-4.16/hid-quirks-cleanup/asus', 'for-4.16/hid-quirks-cleanup/elecom', 'for-4.16/hid-quirks-cleanup/ish', 'for-4.16/hid-quirks-cleanup/multitouch', 'for-4.16/hid-quirks-cleanup/pixart', 'for-4.16/hid-quirks-cleanup/rmi', 'for-4.16/hid-quirks-cleanup/sony' and 'for-4.16/hid-quirks-cleanup/toshiba' into for-linus

korny12:06:38

That is awesome! Also I love how much hackery they can do with the command-line git tools, and how much easier it is than my code using jgit 🙂

mccraigmccraig11:06:08

@danieleneal has been doing cljs rn stuff iirc @maleghast

otfrom11:06:49

yeah, but he's very shouty. 😉

danielneal11:06:25

yeah @maleghast I've been doing a fair amount of react native stuff

mccraigmccraig11:06:52

oops i meant @danieleneal HAS BEEN DOING CLJS RN STUFF IIRC @maleghast

😂 4
otfrom11:06:57

is that why you are so angry @danieleneal?

danielneal11:06:37

my process is (cycle [:react-native-red-screen-of-death :problem-with-npm :argh-android])

danielneal11:06:56

@maleghast I'm using expo - which is imo a decent trade off. It's a lot easier to get started and integrate CI but you can't drop down into native

danielneal11:06:11

I'm actually starting to get the hang of it now but the learning curve was pretty steep

otfrom11:06:47

ah, regular clojure is much easier (constantly :classpath-problem)

danielneal11:06:48

I think @olivergeorge recently put a guide together getting up and running, covering lots of the questions that come up as you begin development

maleghast11:06:31

@danieleneal - Thanks for the feedback, I did rather have the fear that it might be a lot to take in…

maleghast11:06:08

Initial investigations had led me to re-natal..?

maleghast11:06:25

Not spotted expo yet, but I will have a rummage on the internet…

maleghast11:06:50

Going to have a look at that link you posted as well…

guy11:06:22

Morning all! 👋

danielneal11:06:53

expo is like a curated react native experience that bundles some common native libraries and means you only ever write js (or cljs) code, not native code.

maleghast12:06:46

Sounds very appealing!

maleghast12:06:49

Does that mean there is a “water’s edge” of can do / can’t do though? For example can you access the device camera and / or mapping capabilities and GPS, for example?

maleghast12:06:53

(Sorry was away from Slack for lunch)

danielneal13:06:14

Yes there is definitely a "water's edge" of can do/ can't do but the can do functionality is quite broad. You can access device camera and mapping I think. I think their aim is to provide sensible js apis around the native features that aren't necessarily part of core react native

maleghast13:06:41

That sounds very encouraging... Sorry I am "in and out" today...

danielneal13:06:29

that's ok . I'm in and out all the time

thomas13:06:21

I am out all of the time...

💥 12
thomas13:06:31

of my mind that is.

🧠 8
danm13:06:58

If I have passed a class into a function as a var (e.g. (defn foo [klass] ...), how can I instantiate an instance of that class?

danm14:06:22

Where I would expect to call it like (foo Exception)

danm14:06:43

(new klass) is of course looking for a class called 'klass'

maleghast14:06:05

Is there a way to return the "middle" items in a vector without them being wrapped in a lazy-sequence? I mean drop-last returns a lazy-seq, but if I had a vector that looked like this:

[:order :order-id "order-1" "Order"]
and I wanted to pass :order-id and "order-1" into a function call as parameters...?

danm14:06:14

(klass ...) also doesn't work, because Java interop expects the dot and it's also looking for a class called klass

maleghast14:06:02

(in the above I would do (drop-last (rest coll)) to get the "middle" items as a lazy-seq))

guy14:06:53

@maleghast so you want the middle item, or the middle items?

maleghast14:06:04

both the middle items

guy14:06:04

I’m a little unsure what you want

guy14:06:23

(some-fn [:order :order-id "order-1" "Order"]) => [:order-id "order-1"]

Rachel Westmacott20:06:02

There’s already a function called some-fn!

guy07:06:43

Ur correct 😂

guy14:06:28

like that?

maleghast14:06:48

but NOT inside a collection

guy14:06:04

:thinking_face:

guy14:06:26

how do you get back multiple things if its not in a collection

firthh14:06:29

@carr0t I looked for the java implementation of what you’re talking about - https://stackoverflow.com/questions/4872978/how-do-i-pass-a-class-as-a-parameter-in-java Does (.newInstance klass) work?

maleghast14:06:45

Basically I am (for...)-ing over a vector of vectors. I want to use the contents of the vector as parameters to a bidi call:

(bd/path-for routes (first coll) (drop-last (rest coll)))

maleghast14:06:47

but the above ^ will eval to this:

(bd/path-for [[vec of routes]] :order `(:order-id "order-1"))

bronsa14:06:09

@carr0t I’ve replied to your question about new in #clojure

maleghast14:06:18

and that won't work as the bidi/path-for (bd/path-for) expects the params for the URL / route definition to be parameters, like this:

(bd/path-for [[vec of routes]] :order :order-id "order-1")

maleghast14:06:47

(long story short, I am trying to create a re-usable Reagent component for our breadcrumb trail and some links can only be "built" by Bidi if I pass in the extra params)

guy14:06:25

dumb idea but could you desctructure ur coll

guy14:06:35

i assume u get it passed in

guy14:06:38

so its something like

guy14:06:02

(defn x [[a b c d]] ... (bd/path-for routes a b c))

bronsa14:06:42

@maleghast that’s what apply is for

bronsa14:06:54

(apply bd/path-for routes (first coll) (drop-last (rest coll)))

maleghast14:06:00

That's not a dumb idea, but for URLs that don't have extra params that would not work too well and some have more params and some less

maleghast14:06:54

so apply will turn any collections into their constituent parts and then eval the function call..?

bronsa14:06:23

(apply f a b .. '(x y ..)) = (f a b .. x y ..)

maleghast14:06:08

Wow! That's so cool - I'd never really had to think about this ever before so I've been wondering what apply is for, if I am honest...

danm14:06:00

@bronsa Ace, ta 🙂

maleghast14:06:35

@bronsa - I am assuming that if the result of (drop-last (rest coll)) was nil / an empty sequence that would still be ok?

sundarj14:06:47

(apply f nil) would just call (f)

bronsa14:06:47

[] or nil just splice into nothingness

danielneal16:06:20

my next album

bronsa16:06:59

I’ll buy it

guy14:06:01

So would you do something like this then? (apply bd/path-for routes (butlast coll)) @maleghast

maleghast17:06:46

Yeah, that's what I am doing, and it's working! 🙂

maleghast17:06:05

Thanks so much guys - your assistance has allowed me to turn another part of the app (reagent spa) into a reusable component and reduce the line count on the app by another 320 lines.

maleghast17:06:35

I am in refactor MODE - have dropped the overall line count by nearly 1300 lines since I started.

maleghast17:06:59

(though some of that drop is not a true drop, just moving functions that didn’t need to be in the main app namespace into another namespace / file and requiring them in) Still the main Clojurescript file is now a LOT smaller and easier to navigate around as a result. I reckon I can make it even smaller over the next couple of days too.

mccraigmccraig17:06:33

i ❤️ deleting code

💯 12
maleghast18:06:22

Have I mentioned how much I <3 the Heathrow Express..?

bronsa18:06:04

pop quiz for the evening

bronsa18:06:22

explain why this works

Clojure 1.10.0-master-SNAPSHOT
user=> (deftype T [x])
user.T
user=> (defn f [^T t] (.-x t))
#'user/f
user=> (deftype T [x])
user.T
user=> (f (T. 1))
1

bronsa18:06:26

but this throws a ClassCastException

Clojure 1.10.0-master-SNAPSHOT
user=> (deftype T2 [x])
user.T2
user=> (defn f2 [^T2 t] (.-x t))
#'user/f2
user=> (f2 nil)
NullPointerException   user/f2 (NO_SOURCE_FILE:6)
user=> (deftype T2 [x])
user.T2
user=> (f2 (T2. 1))
ClassCastException user.T2 cannot be cast to user.T2  user/f2 (NO_SOURCE_FILE:6)

mccraigmccraig18:06:46

so if the function is called before the type is re-defined the type-hint borks when called with an instance of the re-defined type, but if the function isn't called before the type is re-defined there is no borkage ?

mccraigmccraig18:06:53

well i don't have time to dig into it properly, but i'll guess that the type hint targets are resolved lazily via the var ?

bronsa18:06:22

not quite but you're on the right track

bronsa18:06:35

the first example didn't use to work either before 1.8.0

mccraigmccraig18:06:21

i get the feeling you just gave me a massive hint and i'm not seeing the elephant in front of me 😬

bronsa19:06:56

linkage happens at class load time, since 1.8.0 clojure doesn't force loading of a class upon import, but just on first use

bronsa19:06:15

so in the first example f is linked to the second T

bronsa19:06:53

in the second f2 is linked to the first T2 and so a ClassCastException

4
mccraigmccraig20:06:21

ah, i didn't know clj had changed class-load-time in 1.8.0 neat!

Rachel Westmacott20:06:49

Does anyone know when on Friday the Clojure eXchange deadline for submissions is?