Fork me on GitHub
#clojure
<
2021-10-19
>
Joshua Suskalo02:10:22

Was it ever considered to use #[] for e.g. persistent queues?

seancorfield02:10:40

Some sort of persistent queue literal has been discussed on and off since 2012: https://ask.clojure.org/index.php/3365/implement-reader-literal-support-persistentqueue-structure

seancorfield02:10:51

(that links to a few JIRA tickets too @suskeyhose)

seancorfield02:10:02

Yeah, I think that's what the Jiras behind the Ask above ended up going with but I haven't checked the patches.

đź‘Ť 1
Alex Miller (Clojure team)02:10:13

Having thought about it for many years, my current thought is that queues are not common enough to warrant syntax

Alex Miller (Clojure team)02:10:52

Just my personal opinion

seancorfield02:10:24

In our 120K line code base, we have just three PersistentQueue/EMPTY instances. One of those is in a test. One is in some production code but intended purely as a debugging aid. Only one is in mainline production code. Definitely not worth having a literal for us.

Alex Miller (Clojure team)02:10:45

I do think a constructor function would be useful

đź‘Ť 1
1
seancorfield03:10:41

Like this:

user=> (defn queue [& args] (into clojure.lang.PersistentQueue/EMPTY args))
#'user/queue

đź‘Ť 1
1
Joshua Suskalo03:10:19

that would be good, yeah

đź’Ż 2
the2bears04:10:29

Hi Everyone, I'm looking for a library in Clojure (or Java for that matter) that can take a JSON document, or the schema of the document, and generate sample JSON that conforms to the schema. So far my Google-fu has let me down.

lsenjov04:10:11

A single json document, or multiple json documents of the same form?

lsenjov04:10:17

Mainly because otoh I’m thinking of using something like https://github.com/stathissideris/spec-provider to infer specs, then you can use generators to spit them out

the2bears04:10:39

Multiple json documents that conform. Hmmm... was wondering if there was something using spec. Will check this out, thank-you very much.

qqq05:10:59

Crazy idea: I read somewhere the way to think about the Clojure REPL is: (1) you have some blob of live state, and (2) you submit code against it. This sounds a lot like a database, except the live state is not in relational form. I was wondering: are there any database oriented libraries, or database oriented languages in the following sense: In most current situations, code is 'first class' (IDE for it, github to save history, etc ...) while 'data' is often 2nd class. Is there any language setup where code & data are equally valued ?

Ben Sless06:10:16

Maybe smalltalk

respatialized16:10:37

http://composition.al/CMPS290S-2018-09/2018/12/13/state-is-progressive-or-hey-what-happens-if-we-make-literally-everything-append-only.html In the context of stateful distributed systems the need to have something like this becomes pretty evident, so you may be interested in these notes from a distributed systems course:

respatialized16:10:45

A smalltalk system where the image is stored in a CRDT so you can diff the state of two running systems would be super neat

respatialized16:10:38

Bloom is a research language based on a temporal variant of Datalog, which allows it to apply consistency models to data at the language level http://bloom-lang.net/faq/

respatialized16:10:59

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.66.7169&amp;rep=rep1&amp;type=pdf This paper purports to summarize the state of things as of 2005 so may be good for historical context

respatialized15:10:03

two clojure libraries relevant here spotted on #find-my-lib đź‘€ : https://github.com/wotbrew/relic https://github.com/yanatan16/fyra

GGfpc10:10:19

How is everyone handling errors in their Clojure programs? I don't think exceptions work very nicely in Clojure so I was wondering what alternatives there are

vlaaad10:10:28

Exceptions are idiomatic in Clojure though...

lsenjov11:10:57

Better question, why don’t you think they work nicely? Then we can give alternatives to help

âž• 1
mpenet12:10:11

+1 for exceptions, they just work

mpenet12:10:25

and given the host, it's easier to just embrace that style

Linus Ericsson12:10:12

In pedestal, there is quite an interesting exception handling mechanism in the interceptor chains. http://pedestal.io/reference/error-handling

Colin P. Hill12:10:28

There are some general-purpose alternatives like returning errors as values, but users of your code will be surprised by this because, as others said, it’s not idiomatic in Clojure

Søren Sjørup12:10:30

When error’s aren’t exceptional I think it makes sense to return errors as values rather than use exceptions. Also you might for instance, when doing validation, want to return several error messages rather than throw just one exception.

Colin P. Hill13:10:16

True, I overgeneralized by saying it’s not idiomatic – better to say it’s not idiomatic for everything we might call an error

Joshua Suskalo13:10:38

If you happen to like Common Lisp, you'll probably feel at home with it.

Joshua Suskalo13:10:22

The premise is that when an error occurs you check the callstack for any function that has a desired way to handle that error, you call that handler, which may decide to unwind. Basically it decouples unwinding from error handling.

Joshua Suskalo13:10:55

This works great for IO based stuff and other process-level concerns, but for data-level errors, I like flow https://github.com/fmnoise/flow

Joshua Suskalo13:10:08

It's great for creating data pipelines that have considerations for errors inside them.

mpenet14:10:34

we use https://github.com/exoscale/ex at work, basically use ex-info everywhere and that remains compatible with other libs we have to interact with (from the java world)

mpenet14:10:06

it basically allows to express exceptions hierarchies in a way that's not horrible in clojure

mpenet15:10:25

It's similar but slingshot doesn't bring the hierarchy support via keywords

Joshua Suskalo15:10:33

oh I thought slingshot used isa? for comparisons. Maybe not.

mpenet17:10:15

Maybe it does, haven't checked

mpenet17:10:11

We scope it to our own hierarchy in ex case

Eddie14:10:26

Does the phrase “tyranny of the container” to describe typed languages originate from one of Rich's talks? I forget where I initially heard it but I use it all the time. At work (Scala shop) and my colleagues are getting pretty sick of hearing me mutter it under my breadth.

flowthing14:10:33

Not sure whether it actually originates from there, of course.

borkdude15:10:51

On Java 11 I'm calling this method *newFileSystem*(*Path* path, *ClassLoader* loader) as (FileSystem/newFileSystem (.toPath ...) nil) which is fine and doesn't need any reflection. But on Java 17, there are more overloads where the second argument can be a different type, so I'm getting an error since the compile doesn't know which one to choose:

static FileSystem
newFileSystem(Path path, ClassLoader loader)
Constructs a new FileSystem to access the contents of a file as a file system.
static FileSystem
newFileSystem(Path path, Map<String,?> env)
Constructs a new FileSystem to access the contents of a file as a file system.
static FileSystem
newFileSystem(Path path, Map<String,?> env, ClassLoader loader)
Constructs a new FileSystem to access the contents of a file as a file system.
How do I make this call compatible with both Java 11 and Java 17? You cannot type hint nil right?

hiredman15:10:54

You use let, bind nil to a name, type hint the name

1
đź‘Ť 3
borkdude15:10:02

ah gotcha! thanks

borkdude15:10:48

worked like a charm, thank you @hiredman