Fork me on GitHub
#clojure-europe
<
2020-10-06
>
otfrom07:10:45

I'm loving cgrand's xforms

orestis08:10:49

I’m loving data-driven UIs. I need to spec my UI-driving data more though!

otfrom09:10:35

@orestis what are you using?

orestis09:10:24

@otfrom I’m using hx for the view layer, and my own reseda library for the state. https://github.com/lilactown/hx https://github.com/orestis/reseda

dharrigan10:10:24

If anyone is interested, for those following the major.minor.commits approach to tagging repos, I've put together a very simple script to help do that. I use it on my clojure stuff all the time (with a slight variation, I prefix my versions with a rel/)....

👍 9
ordnungswidrig15:10:19

I do like monoids.

ordnungswidrig15:10:29

But I’ve also studied math.

slipset15:10:07

Monoids are cool.

slipset15:10:00

@borkdude one could argue that maps form a monoid under merge with nil as the identity since

user> (merge nil)
;; => nil
user> (merge)
;; => nil
user> (merge {})
;; => {}
user> (merge {} nil)
;; => {}
user> (merge nil {})
;; => {}
user> 

slipset15:10:10

It seems like merge has two identity values, nil and {}

borkdude15:10:18

Monoids are just a very simple thing with a fancy name which makes people think they're smart when using it :)

slipset15:10:57

conj is also monoidic I believe

borkdude15:10:37

monoids are a datastructure + an operation + an identity element, not one or the other without any given context

🙂 3
slipset16:10:35

Event though (conj) => [], so it somewhat presents an identity value, it doesn't seem to form a monoid with [] as an identity value.

slipset16:10:55

And, it's not really a binary operator of the same type

slipset16:10:37

into on the other hand, with [] as the identity seem to form a monoid.

slipset16:10:22

(which makes sense since (reduce into [] colls) )

slipset16:10:10

Another (not really) interesting thing:

user> (clojure.repl/doc merge)
-------------------------
clojure.core/merge
([& maps])
  Returns a map that consists of the rest of the maps conj-ed onto
  the first.  If a key occurs in more than one map, the mapping from
  the latter (left-to-right) will be the mapping in the result.
;; => nil
user> (merge nil)
;; => nil
user> (map? nil)
;; => false
user> 

slipset16:10:48

So nil is a map, but still it's not.

borkdude16:10:55

Things are monoids in clojure, except when Rich chose not to in an instanceof check

slipset16:10:16

Now, that's a tweet 🙂

borkdude16:10:39

Feel free to tweet ;)

slipset16:10:01

I'm not sure I grok the true meaning of it yet.

borkdude16:10:02

What I'm getting at is that some things are pretty ad hoc in Clojure based on their class. Take contains? for example. Did you know that thing worked on String?

slipset16:10:31

What I find interesting with the typed fp folks is that they have their types and their "laws"

slipset16:10:03

The "laws" are the things that the type-system can't help them with. It's where they have to retort to unit-tests

borkdude16:10:08

user=> (contains? "foo" 1)
true

slipset16:10:33

Right, because strings are sequential? or some such

borkdude16:10:39

nope, it's just hardcoded

slipset16:10:01

Kind'a makes sense since Clojure is written pre-protocols and you can't extend interfaces to existing java-classes.

borkdude16:10:26

I think in hindsight they would not do the string seq / indexed thing again

borkdude16:10:40

could be wrong, but it feels like a mistake

slipset16:10:46

I kind'a like it.

slipset16:10:02

means you can use all the sequential fns on strings like interpose, interleave etc?

borkdude16:10:37

I've been told by Alex: please don't use seq on a string, but str/foobar (e.g. str/blank?). It's just not an good idea to marshall a thing into some other object and then call some function on that which looks up if it's a string again, etc. All that waste of time

borkdude16:10:01

not really no, interpose doesn't return a string

slipset16:10:39

No, it doesn't return a string, but you kan get it back by (I've forgotten how)

otfrom16:10:07

apply str?

borkdude16:10:12

yes, with horrible apply str + concat

otfrom16:10:42

(apply str (interpose \| "foo"))
"f|o|o"

slipset16:10:44

Probably not something you'd do if you favour performance over golfing 🙂

borkdude16:10:36

user=> (clojure.string/join "|" "foo")
"f|o|o"
(this calls seq on the string still)

slipset16:10:57

user> (apply str (interleave "aaa" "bbb"))
;; => "ababab"
user> 

borkdude16:10:33

that's nice for 4clojure, but not something you typically do with strings

slipset16:10:48

exactly. Neat but not useful

slipset16:10:03

How did we get to here from monoids?

borkdude16:10:28

the thing with strings being seqables is that it leads to awkward core specs. like many functions take seqables, except strings

borkdude16:10:44

so then you need a different spec than ::seqable which is annoying

borkdude16:10:35

I'm just ranting, don't mind me ;)

slipset16:10:53

But then maybe the problem is that the fns that take seqables should have accepted strings?

slipset16:10:10

(apply str (remove #{\a} "blabla")) is kinda nice

slipset16:10:09

I mean, a string is just a sequence of characters so why bother implementing specific fns for it?

slipset16:10:13

but then, maybe (into "" (remove #{\a} "blabla")) should have been a thing.

borkdude16:10:06

oh maybe it was the nil that was annoying

slipset16:10:07

Which would make sense in a way, since map/filter/etc aren't type-preserving anyway.

slipset16:10:35

You're getting old. You can't remember why, just that you're annoyed 🙂

slipset16:10:08

The annoying thing is that clojure.string fns blow up on nil 😕

slipset16:10:22

I understand and accept why, but I'm still annoyed.

borkdude16:10:45

so nil is seqable? but can also be many other things. this annoyed me when creating the type system in clj-kondo, since it checks if something could have been of a certain type, so if something is nilable, it could have been a seqable....

borkdude16:10:09

btw @slipset, the type system in clj-kondo heavily borrowed from our core spec project :)

simple_smile 3
slipset20:10:40

That’s a lot of work…

borkdude16:10:15

have a nice dinner

dominicm17:10:40

😩 discovered today that queries are really slow if you have java util logging in with postgres. Was costing us 4x. I love the profiler we have in clojure, it's awesome.

orestis18:10:39

How do you mean? We’re you logging each query/result?

dominicm19:10:42

Postgres has built in logging

borkdude20:10:50

what does that have to do with java util logging though?

dominicm21:10:12

That's what postgresql uses

borkdude21:10:52

huh.... b-b-but postgres is not written in java is it

dominicm21:10:18

Sorry, I mean the postgresql java driver!

dominicm21:10:44

I see now that I ignored that key term 😂 long day as you can imagine

borkdude21:10:11

I usually enable the logging in postgres itself to see the queries

dominicm21:10:21

Yeah, I'm not sure what postgres is doing tbh

orestis06:10:19

So you somehow enabled something in Java.util.logging? And that triggered slowdowns?