Fork me on GitHub
#beginners
<
2021-08-07
>
Edward Ciafardini12:08:58

I'm trying to update this so that it works with the current ns form rules: https://github.com/uplift-inc/twilio lein test keeps failing and giving messages like: Syntax error macroexpanding clojure.core/ns at (twilio/core.clj:1:1). import - failed: #{:refer-clojure} at: [:ns-clauses :refer-clojure :clause] spec: :clojure.core.specs.alpha/ns-refer-clojure

Edward Ciafardini12:08:09

I replaced the (import [http://java.net URLEncoder]) with ring.util.codec and that seemed to resolve the issue.

dgb2314:08:50

is there a (core) predicate that answers whether something is a scalar? Like #{int? string? ...}

Alex Miller (Clojure team)16:08:27

No, as that is an open ended set

Alex Miller (Clojure team)16:08:41

complement coll? is probably closest, but colls are also an open ended set

👍 3
dgb2317:08:40

I often stub my toes against exactly that notion. In some talk about spec it was said “There can always be more stuff”. I don’t need to enumerate all the things nor do I need to find some abstraction over that. Just specify what is needed where it is needed. Ty

dgb2314:08:30

“not a composite value”

dgb2314:08:55

well string is a composite value, but you know what I mean

sova-soars-the-sora15:08:07

I'm not sure what you mean by composite ... What would be some qualifying inputs? 7 ? 3.14159 ? radical 2 ?

Ed15:08:59

@denis.baudinot Maybe (complement sequential?)? ... Sorry on my phone so I can't actually check it

Jon Boone15:08:18

something other than number?

sova-soars-the-sora16:08:37

There's number? ... so one could do (complement number?) perhaps

seancorfield16:08:22

@denis.baudinot (complement coll?) perhaps?

dgb2316:08:14

Maybe it should be an explicit set

seancorfield16:08:35

(`sequential?` is not true of several collection types so (complement sequential?) won't be accurate)

Alex Miller (Clojure team)16:08:16

Clojure is open to new scalars and new coll types

seancorfield16:08:02

Perhaps if you explain the problem you're trying to solve, we can offer a more specific solution?

☝️ 3
dgb2316:08:13

I’m thinking im terms of “a thing that is inherently atomic” in database terms

dgb2316:08:45

I cannot really say that can I?

dgb2316:08:20

“Sean, Alex, Jon, L0st, Sova”

dgb2316:08:58

I guess a best effort would be (complement coll?)

seancorfield16:08:23

I'm not even sure what "inherently atomic" in database terms means -- that depends on the database technology, doesn't it?

dgb2316:08:58

Yeah that’s the problem: I don’t use a specific database, just that’s where the idea comes from I guess

dgb2316:08:03

first normal form

seancorfield16:08:27

In some databases, that would be a whole document (definitely a "collection" of data), in others it would be a row, in others just a tuple...

dgb2316:08:33

“not complex and not a function”

lassemaatta16:08:42

Atomic = a single bit? :)

2
seancorfield16:08:51

But, again, what problem are you trying to solve?

dgb2316:08:57

Right I guess In terms of SQL or Datalog databases

quoll21:08:09

I recently added vectors as an atomic type for the Asami database, though I did (arbitrarily) restrict them to not allowing collection types as members. So it’s definitely vague!

👍 2
seancorfield16:08:48

I'm not hearing a problem statement here, just academic curiosity about terminology 🙂

dgb2316:08:12

ok sorry 🙂 I have to think about it more before I can ask the right question! ty

seancorfield16:08:57

I consider operations as something that can be atomic, not values.

seancorfield16:08:38

dev=> (doc compare-and-set!)
-------------------------
clojure.core/compare-and-set!
([atom oldval newval])
  Atomically sets the value of atom to newval if and only if the
  current value of the atom is identical to oldval. Returns true if
  set happened, else false
Atomic operation.

seancorfield16:08:56

dev=> (doc swap!)
-------------------------
clojure.core/swap!
([atom f] [atom f x] [atom f x y] [atom f x y & args])
  Atomically swaps the value of atom to be:
  (apply f current-value-of-atom args). Note that f may be called
  multiple times, and thus should be free of side effects.  Returns
  the value that was swapped in.
Atomic operation.

dgb2316:08:37

I guess it is easier to think of it in scheme, where it wouldn’t have a car/cdr

seancorfield16:08:33

(and that's true of databases too: ACID - Atomic, etc - refers to operations)

quoll21:08:50

I’m led to think of mathematical logic, and in particular Prolog, where base terms are called atoms

dgb2317:08:50

Ty for your answers and hints. I resolved the issue, for reference: I realised that this part of the program doesn’t know or shouldn’t care if that makes sense. I tried to write a spec for something that this module can’t possibly validate without leaking the implementation of another module.

dgb2317:08:22

So my question was wrong in the first place 😄

sova-soars-the-sora19:08:38

😄 those are some of the best questions. At least you are interrogating / questioning what is possible while preserving simplicity. It sounds like you want to know the type of the data and just be wary of turning any generic screw drivers into fruit-brand context-specific screw drivers that cost extra. it's the right-to-repair movement for your source code 😛

😄 2
Parvesh Monu19:08:43

Hi everyone, I hope you all are doing great. I am very new to Clojure World. I am working on a ClojureScript, shadow-cljs project. I am trying to use an npm package in the project. I installed it using "yarn add react-native-swipe-list-view".  But I don't know if something is wrong with the package or this is not the right way to add a dependency. Because that added module is showing Syntax Error: "Cannot use Import Statement outside a module". It will be a big help if someone can point me to a resource to fix this issue. I posted other Info's like screenshots on this URL: https://github.com/status-im/status-react/pull/12432#issuecomment-894633595

Drew Verlee21:08:42

@U02AB40BP0W you want want to ask in #shadow-cljs "yarn add" is the right way to add a js dep. What is make test running?

Drew Verlee21:08:25

I feel like that might just a bug in that library. it seem rather self contained.

Parvesh Monu22:08:44

Hi @https://app.slack.com/team/U0DJ4T5U1 , Thank you very much for your reply. According to my research shadow-cljs implements a custom JS bundler and bundles node_modules into something that can be used with clojurescript. And that npm package uses ES6 Syntax and shadow-cljs having trouble bundling that. I think I need to use babel to convert that into browser-friendly code first. I just need to figure out how to use babel to do that. You are right I should ask question in #shadow-cljs Thanks

didibus22:08:18

Are you just doing: (:require ["module-name" :refer (export)])

Parvesh Monu22:08:19

@U0K064KQV Thank you very much for your reply. Yes, it mentions adding the dependency. Also, what will be the similar syntax to ES6 to use for coding in clojurescript. But problem is, npm package that I added is using ES6 syntax.

didibus22:08:45

Ya, that's fine, shadow works with ES6 imports as well

Parvesh Monu22:08:42

I don't know but here it is breaking, just because package has ES6 syntax

didibus22:08:56

I think you're not using the package correctly

Parvesh Monu22:08:14

As you can see in error message in link, error is only in node_modules directory. That I not even modified. Problem is happening while shadow-cljs converting that code for clojurescript

didibus22:08:51

I think you might want: (:require ["react-native-swipe-list-view" :refer (SwipeRow)]) maybe? I'm not too sure, but I know that shadow should be able to handle ES6

didibus23:08:27

Ya, I think you are just not using the right syntax for importing in ClojureScript.

didibus23:08:58

Or you might need to do: swipe-list-view/SwipeRow maybe?

Parvesh Monu23:08:01

This is my swiper search for keyword react-native-swipe-list-view. You can see there is only one manually added place, others are automated files like yarn.lock. And you can see my import there.

didibus23:08:46

SwipeRow is supposed to be a Class?

Parvesh Monu23:08:03

Oh sorry I forget to mention, I am quite sure about syntax. Because I am able to run code and app is running on phone with this imported class. Means this code is right.

didibus23:08:26

oh, its just the bundling that's struggling? Ya, you'd probably need theller to help you with that

Parvesh Monu23:08:10

bundling is the issue

didibus23:08:18

It could be you're not specifying something as a module that should be

Parvesh Monu23:08:18

Ya that's good advice, I am messaging him. Thanks!

didibus23:08:29

Ya, he'll be better help, I'm also a beginner with JS and ClojureScript 😛

😄 2
Parvesh Monu23:08:46

Still, Thank you very much for your time. 🙂