beginners

Getting started with Clojure/ClojureScript? Welcome! Also try: https://ask.clojure.org. Check out resources at https://gist.github.com/yogthos/be323be0361c589570a6da4ccc85f58f.
blak3mill3r 2021-03-23T00:35:14.280400Z

I am pretty sure that clojure.core/cat is the only one "named after an animal" (although it really is not)

blak3mill3r 2021-03-23T00:37:32.280600Z

but there are these vaguely zoologically named clojure.core fns '[ descendants ancestors aclone ]

blak3mill3r 2021-03-23T00:38:13.280800Z

oh yeah, and lazy-cat

pinealan 2021-03-23T01:22:54.281Z

@sova I need actual websocket for connecting to third-party steamed data

pinealan 2021-03-23T01:23:15.281200Z

@chepprey thanks, haslett looks like a good option

sova-soars-the-sora 2021-03-23T01:34:43.282100Z

is there a way to query the duration of a sound file such as an mp3 that has metadata and know the time-duration of the mp3 ? java interop probably?

zendevil 2021-03-23T01:49:18.283400Z

I have the following namespace declaration that I’m trying to evaluate:

(ns foo.events
  (:require
   [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]]
   [cljs.core.async :refer [<!]]
   [goog.style :as gs]
   [reagent.core :as r]
   [re-frame.core :refer [subscribe dispatch]]
   [ajax.edn :as edn]
   [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax]
   [humboi.db :refer [app-db]]
   [day8.re-frame.http-fx]
   [cljs.core.async :refer [go]]
   [cljs.core.async.interop :refer-macros [<p!]]
   ["@react-native-async-storage/async-storage" :default AsyncStorage]
   ["@react-native-community/cameraroll" :as CameraRoll]
   ["expo-media-library" :as MediaLibrary] ;; register error ;; doesn't work on simulator
   ["react-native-image-picker" :refer [launchImageLibrary]]
   ["@react-navigation/native" :refer [useNavigation]]
   [cognitect.transit :as t]
   ["@segment/analytics-react-native" :default analytics]
   ["@segment/analytics-react-native-mixpanel" :default mixpanel]
   ["@segment/analytics-react-native-google-analytics" :default google-analytics]
   [react-native-background-actions :default BackgroundService]
   [react-native-background-upload :default Upload]

   ))
However, upon evaluating it, I’m getting the following error:
2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling src/humboi/events.cljs at (1:1)
   #:clojure.error{:phase :macro-syntax-check,
                   :line 1,
                   :column 1,
                   :source
                   "/Users/prikshetsharma/Desktop/Humboi/src/humboi/events.cljs",
                   :symbol clojure.core/ns}
             Compiler.java: 6971  clojure.lang.Compiler/checkSpecs
             Compiler.java: 6987  clojure.lang.Compiler/macroexpand1
             Compiler.java: 7074  clojure.lang.Compiler/macroexpand
             Compiler.java: 7160  clojure.lang.Compiler/eval
             Compiler.java: 7131  clojure.lang.Compiler/eval
                  core.clj: 3214  clojure.core/eval
                  core.clj: 3210  clojure.core/eval
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn/fn
                  AFn.java:  152  clojure.lang.AFn/applyToHelper
                  AFn.java:  144  clojure.lang.AFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj: 1973  clojure.core/with-bindings*
                  core.clj: 1973  clojure.core/with-bindings*
               RestFn.java:  425  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   87  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  414  clojure.main/repl/read-eval-print/fn
                  main.clj:  414  clojure.main/repl/read-eval-print
                  main.clj:  435  clojure.main/repl/fn
                  main.clj:  435  clojure.main/repl
                  main.clj:  345  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  152  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  202  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  201  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  748  java.lang.Thread/run

1. Caused by clojure.lang.ExceptionInfo
   Call to clojure.core/ns did not conform to spec.
   #:clojure.spec.alpha{:problems
                        [{:path [],
                          :reason "Extra input",
                          :pred
                          (clojure.spec.alpha/cat
     ...

zendevil 2021-03-23T01:49:26.283600Z

Why is this?

seancorfield 2021-03-23T02:03:55.284600Z

You’ve omitted the piece of the error that actually tells you why it was rejected by the compiler. What does the rest of this Spec failure say:

#:clojure.spec.alpha{:problems
                        [{:path [],
                          :reason "Extra input",
                          :pred
                          (clojure.spec.alpha/cat

2021-03-23T02:05:11.285700Z

Is :default a thing?

seancorfield 2021-03-23T02:05:14.285800Z

Also, why change (ns humboi.events to (ns foo.events in your code paste when your error messages still show the full filename?

😅 2
seancorfield 2021-03-23T02:05:23.286100Z

It’s ClojureScript so I dunno.

dpsutton 2021-03-23T02:05:42.286600Z

in cljs yeah.

2021-03-23T02:05:50.287Z

:/

dpsutton 2021-03-23T02:06:06.287700Z

or at least in shadow. i'm not sure if that's an extension to work with npm deps

seancorfield 2021-03-23T02:06:07.287800Z

But looking at the failure, I think it’s getting evaluated as Clojure and it’s illegal in Clojure?

dpsutton 2021-03-23T02:08:57.288500Z

this didn't pass validation for me on a bare cljs repl. are you using shadow cljs?

dpsutton 2021-03-23T02:09:29.288800Z

Unexpected error (ExceptionInfo) compiling at (<cljs repl>:1:1).
Only :as, :refer and :rename options supported in :require / :require-macros; offending spec: ["@react-native-async-storage/async-storage" :default AsyncStorage] at line 1 <cljs repl>
in cljs.main

zendevil 2021-03-23T02:22:11.289Z

yes I’m using shadow cljs

blak3mill3r 2021-03-23T02:24:08.289700Z

I'd suggest shelling out to an ffmpeg process with clojure.java.shell https://stackoverflow.com/questions/10437750/how-to-get-the-real-actual-duration-of-an-mp3-file-vbr-or-cbr-server-side

blak3mill3r 2021-03-23T02:24:38.290300Z

or this https://github.com/Raynes/conch instead of clojure.java.shell

zendevil 2021-03-23T02:24:59.291200Z

but the repl I’m running is shadow-cljs so why does it complain about :default? This is the error I get when I evaluate in cider

zendevil 2021-03-23T02:25:26.291500Z

Show: Project-Only All Hide: Clojure Java REPL Tooling Duplicates (15 frames hidden) 2. Unhandled clojure.lang.Compiler$CompilerException Error compiling src/humboi/events.cljs at (1:1) #:clojure.error{:phase :macro-syntax-check, :line 1, :column 1, :source “/Users/prikshetsharma/Desktop/Humboi/src/humboi/events.cljs”, :symbol clojure.core/ns} Compiler.java: 6971 clojure.lang.Compiler/checkSpecs Compiler.java: 6987 clojure.lang.Compiler/macroexpand1 Compiler.java: 7074 clojure.lang.Compiler/macroexpand Compiler.java: 7160 clojure.lang.Compiler/eval Compiler.java: 7131 clojure.lang.Compiler/eval core.clj: 3214 clojure.core/eval core.clj: 3210 clojure.core/eval interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn AFn.java: 152 clojure.lang.AFn/applyToHelper AFn.java: 144 clojure.lang.AFn/applyTo core.clj: 665 clojure.core/apply core.clj: 1973 clojure.core/with-bindings* core.clj: 1973 clojure.core/with-bindings* RestFn.java: 425 clojure.lang.RestFn/invoke interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn main.clj: 414 clojure.main/repl/read-eval-print/fn main.clj: 414 clojure.main/repl/read-eval-print main.clj: 435 clojure.main/repl/fn main.clj: 435 clojure.main/repl main.clj: 345 clojure.main/repl RestFn.java: 1523 clojure.lang.RestFn/invoke interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 152 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn AFn.java: 22 clojure.lang.AFn/run session.clj: 202 nrepl.middleware.session/session-exec/main-loop/fn session.clj: 201 nrepl.middleware.session/session-exec/main-loop AFn.java: 22 clojure.lang.AFn/run Thread.java: 748 java.lang.Thread/run 1. Caused by clojure.lang.ExceptionInfo Call to clojure.core/ns did not conform to spec. #:clojure.spec.alpha{:problems [{:path [], :reason “Extra input”, :pred (clojure.spec.alpha/cat :docstring (clojure.spec.alpha/? clojure.core/string?) :attr-map (clojure.spec.alpha/? clojure.core/map?) :ns-clauses :clojure.core.specs.alpha/ns-clauses), :val ((:require [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]] [cljs.core.async :refer [<!]] [goog.style :as gs] [reagent.core :as r] [re-frame.core :refer [subscribe dispatch]] [ajax.edn :as edn] [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax] [humboi.db :refer [app-db]] [day8.re-frame.http-fx] [cljs.core.async :refer [go]] [cljs.core.async.interop :refer-macros [<p!]] [“@react-native-async-storage/async-storage” :default AsyncStorage] [“@react-native-community/cameraroll” :as CameraRoll] [“expo-media-library” :as MediaLibrary] [“react-native-image-picker” :refer [launchImageLibrary]] [“@react-navigation/native” :refer [useNavigation]] [cognitect.transit :as t] [“@segment/analytics-react-native” :default analytics] [“@segment/analytics-react-native-mixpanel” :default mixpanel] [“@segment/analytics-react-native-google-analytics” :default google-analytics] [react-native-background-actions :default BackgroundService] [react-native-background-upload :default Upload])), :via [:clojure.core.specs.alpha/ns-form], :in [1]}], :spec #object[clojure.spec.alpha$regex_spec_impl$reify__2509 0x21a7b90c “clojure.spec.alpha$regex_spec_impl$reify__2509@21a7b90c”], :value (humboi.events (:require [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]] [cljs.core.async :refer [<!]] [goog.style :as gs] [reagent.core :as r] [re-frame.core :refer [subscribe dispatch]] [ajax.edn :as edn] [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax] [humboi.db :refer [app-db]] [day8.re-frame.http-fx] [cljs.core.async :refer [go]] [cljs.core.async.interop :refer-macros [<p!]] [“@react-native-async-storage/async-storage” :default AsyncStorage] [“@react-native-community/cameraroll” :as CameraRoll] [“expo-media-library” :as MediaLibrary] [“react-native-image-picker” :refer [launchImageLibrary]] [“@react-navigation/native” :refer [useNavigation]] [cognitect.transit :as t] [“@segment/analytics-react-native” :default analytics] [“@segment/analytics-react-native-mixpanel” :default mixpanel] [“@segment/analytics-react-native-google-analytics” :default google-analytics] [react-native-background-actions :default BackgroundService] [react-native-background-upload :default Upload])), :args (humboi.events (:require [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]] [cljs.core.async :refer [<!]] [goog.style :as gs] [reagent.core :as r] [re-frame.core :refer [subscribe dispatch]] [ajax.edn :as edn] [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax]

zendevil 2021-03-23T02:25:27.291700Z

[humboi.db :refer [app-db]] [day8.re-frame.http-fx] [cljs.core.async :refer [go]] [cljs.core.async.interop :refer-macros [<p!]] [“@react-native-async-storage/async-storage” :default AsyncStorage] [“@react-native-community/cameraroll” :as CameraRoll] [“expo-media-library” :as MediaLibrary] [“react-native-image-picker” :refer [launchImageLibrary]] [“@react-navigation/native” :refer [useNavigation]] [cognitect.transit :as t] [“@segment/analytics-react-native” :default analytics] [“@segment/analytics-react-native-mixpanel” :default mixpanel] [“@segment/analytics-react-native-google-analytics” :default google-analytics] [react-native-background-actions :default BackgroundService] [react-native-background-upload :default Upload]))} alpha.clj: 705 clojure.spec.alpha/macroexpand-check alpha.clj: 697 clojure.spec.alpha/macroexpand-check AFn.java: 156 clojure.lang.AFn/applyToHelper AFn.java: 144 clojure.lang.AFn/applyTo Var.java: 705 clojure.lang.Var/applyTo Compiler.java: 6969 clojure.lang.Compiler/checkSpecs Compiler.java: 6987 clojure.lang.Compiler/macroexpand1 Compiler.java: 7074 clojure.lang.Compiler/macroexpand Compiler.java: 7160 clojure.lang.Compiler/eval Compiler.java: 7131 clojure.lang.Compiler/eval core.clj: 3214 clojure.core/eval core.clj: 3210 clojure.core/eval interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn/fn AFn.java: 152 clojure.lang.AFn/applyToHelper AFn.java: 144 clojure.lang.AFn/applyTo core.clj: 665 clojure.core/apply core.clj: 1973 clojure.core/with-bindings* core.clj: 1973 clojure.core/with-bindings* RestFn.java: 425 clojure.lang.RestFn/invoke interruptible_eval.clj: 87 nrepl.middleware.interruptible-eval/evaluate/fn main.clj: 414 clojure.main/repl/read-eval-print/fn main.clj: 414 clojure.main/repl/read-eval-print main.clj: 435 clojure.main/repl/fn main.clj: 435 clojure.main/repl main.clj: 345 clojure.main/repl RestFn.java: 1523 clojure.lang.RestFn/invoke interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate interruptible_eval.clj: 152 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn AFn.java: 22 clojure.lang.AFn/run session.clj: 202 nrepl.middleware.session/session-exec/main-loop/fn session.clj: 201 nrepl.middleware.session/session-exec/main-loop AFn.java: 22 clojure.lang.AFn/run Thread.java: 748 java.lang.Thread/run

blak3mill3r 2021-03-23T02:31:04.293500Z

@ps what is :default ? Is this something specific to shadow-cljs? I couldn't find any documentation for it, and I've never seen it in a require form before, and as dpsutton pointed out it does not pass the validation with plain cljs

blak3mill3r 2021-03-23T02:31:53.294100Z

also slack snippets are great for long blocks of code or stacktraces

blak3mill3r 2021-03-23T02:32:04.294500Z

v-- that lightning bolt lets you make snippets

seancorfield 2021-03-23T02:34:31.296800Z

Looking at that stack trace, I’m fairly certain this is getting evaluated as either regular Clojure or regular ClojureScript rather than actually evaluating into Shadow-cljs’s REPL. I was hoping for more of a clue in the full Spec failure but I don’t see anything that nails it down further.

zendevil 2021-03-23T02:36:17.297400Z

so this is a problem with cider?

blak3mill3r 2021-03-23T02:36:25.297500Z

:default seems like the obvious culprit, it is specific to shadow-cljs

blak3mill3r 2021-03-23T02:36:45.298Z

@ps can you try it from shadow-cljs's repl in the terminal?

zendevil 2021-03-23T02:37:00.298200Z

yeah, it’s still giving the error

blak3mill3r 2021-03-23T02:38:12.299600Z

odd... since the error message unfortunately doesn't have much to narrow it down, I would try commenting out or removing parts of the namespace form, and pasting it into the shadow-cljs repl until you identify the part that breaks it

zendevil 2021-03-23T02:38:26.300100Z

wait, it won’t be exactly the same right?

blak3mill3r 2021-03-23T02:38:36.300300Z

what if you remove all these :default requires?

blak3mill3r 2021-03-23T02:39:21.301100Z

well it might help identify the problem (not fix it)

blak3mill3r 2021-03-23T02:39:38.301500Z

the problem you have now is that the clojurescript compiler doesn't consider your ns form valid

zendevil 2021-03-23T02:39:44.301800Z

(ns humboi.events
  (:require
   [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]]
   [cljs.core.async :refer [&lt;!]]
   [goog.style :as gs]
   [reagent.core :as r]
   [re-frame.core :refer [subscribe dispatch]]
   [ajax.edn :as edn]
   [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax]
   [humboi.db :refer [app-db]]
   [day8.re-frame.http-fx]
   [cljs.core.async :refer [go]]
   [cljs.core.async.interop :refer-macros [&lt;p!]]
   ;;["@react-native-async-storage/async-storage" :default AsyncStorage]
   ["@react-native-community/cameraroll" :as CameraRoll]
   ["expo-media-library" :as MediaLibrary] ;; register error ;; doesn't work on simulator
   ["react-native-image-picker" :refer [launchImageLibrary]]
   ["@react-navigation/native" :refer [useNavigation]]
   ;;["@segment/analytics-react-native" :default analytics]
   ;;["@segment/analytics-react-native-mixpanel" :default mixpanel]
   ;;["@segment/analytics-react-native-google-analytics" :default google-analytics]
   ;;[react-native-background-actions :default BackgroundService]
   ;;[react-native-background-upload :default Upload]

   ))
still doesn’t work. Same error

blak3mill3r 2021-03-23T02:42:15.302400Z

I don't see the problem. I'll try it in a shadow-cljs repl.

zendevil 2021-03-23T02:45:00.302700Z

yes shadow-cljs repl too gives the same error

dpsutton 2021-03-23T02:47:10.303200Z

Is this a web app

dpsutton 2021-03-23T02:47:17.303600Z

Or node?

zendevil 2021-03-23T02:47:28.303800Z

In fact just doing this:

(ns humboi.events
  (:require
   [re-frame.core :as rf :refer [reg-event-fx reg-event-db after reg-sub reg-cofx inject-cofx reg-fx]] 
   [reagent.core :as r]
   [re-frame.core :refer [subscribe dispatch]]
   [ajax.edn :as edn]
   [ajax.core :refer [json-response-format raw-response-format json-request-format] :as ajax]
   [day8.re-frame.http-fx]
   [cljs.core.async :refer [go]]
   ))
gives:
1. Unhandled java.io.FileNotFoundException
   Could not locate day8/re_frame/http_fx__init.class, day8/re_frame/http_fx.clj
   or day8/re_frame/http_fx.cljc on classpath. Please check that namespaces with
   dashes use underscores in the Clojure file name.

dpsutton 2021-03-23T02:47:48.304400Z

Yeah. You’re in a clojure repl

zendevil 2021-03-23T02:47:53.304600Z

this is web I think since it’s react native

blak3mill3r 2021-03-23T02:48:03.304900Z

it would be trying to locate a .cljs file

blak3mill3r 2021-03-23T02:48:05.305100Z

if it were cljs

blak3mill3r 2021-03-23T02:48:19.305600Z

instead it is looking for a .clj file which definitely indicates it is a jvm clojure repl

dpsutton 2021-03-23T02:48:32.306100Z

You need to read the documentation for shadow about how to get your repl going

blak3mill3r 2021-03-23T02:50:16.307400Z

can you share any more of this project? the shadow-cljs.edn file and package.json list all these library dependencies, right?

blak3mill3r 2021-03-23T02:50:50.308Z

I generated a new shadow-cljs project using npx create-cljs-project xyz

blak3mill3r 2021-03-23T02:51:01.308300Z

and I can get a clojurescript Node.js repl like this

blak3mill3r 2021-03-23T02:51:14.308700Z

from that xyz directory: shadow-cljs node-repl

blak3mill3r 2021-03-23T02:51:57.309200Z

and the prompt looks like this: cljs.user=&gt;

zendevil 2021-03-23T02:53:11.309500Z

{:deps true
  :builds
 {:test
  {:target    :npm-module
   :output-dir "test-out"
   :entries [humboi.core-test]}
  :dev
  {:target     :react-native
   :init-fn    humboi.core/init
   :output-dir "app"
   :compiler-options {:closure-defines
                      {"re_frame.trace.trace_enabled_QMARK_" true}}
   ;;:devtools {:preloads [devtools.preload]}
   }}}

2021-03-23T17:48:26.329300Z

@ps Please put longer messages like this inside of a "reply thread" on Slack, to avoid having large blocks of text at the top level that some people might not want to see. Another technique is to publish such text on Github, perhaps as a "Gist", and paste only a link to it in Slack.

zendevil 2021-03-23T02:53:34.309800Z

{
  "name": "Humboi",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.13.2",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/cameraroll": "^4.0.1",
    "@react-native-community/cli": "^4.13.1",
    "@react-native-community/datetimepicker": "^3.0.9",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/google-signin": "^5.0.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/bottom-tabs": "^5.11.3",
    "@react-navigation/material-top-tabs": "^5.3.13",
    "@react-navigation/native": "^5.9.0",
    "@react-navigation/stack": "^5.14.2",
    "@segment/analytics-react-native": "^1.4.3",
    "@segment/analytics-react-native-google-analytics": "^1.4.3",
    "@segment/analytics-react-native-mixpanel": "^1.4.3",
    "@unimodules/core": "^7.0.0",
    "@unimodules/react-native-adapter": "^6.1.0",
    "create-react-class": "^15.7.0",
    "expo-camera": "^9.1.1",
    "expo-media-library": "^10.0.0",
    "lottie-ios": "^3.1.8",
    "lottie-react-native": "^3.5.0",
    "metro-react-native-babel-transformer": "^0.64.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.0",
    "react-native": "0.63.4",
    "react-native-background-actions": "^2.6.0",
    "react-native-background-upload": "^6.2.0",
    "react-native-beautiful-video-recorder": "^2.0.1",
    "react-native-camera": "^3.42.0",
    "react-native-camera-roll-picker": "^2.0.0",
    "react-native-elements": "^3.1.0",
    "react-native-fade-in-image": "^1.5.0",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-google-place-picker": "^1.2.1",
    "react-native-google-places-autocomplete": "^2.1.3",
    "react-native-google-signin": "^2.1.1",
    "react-native-image-picker": "^3.1.4",
    "react-native-image-resizer": "^1.4.2",
    "react-native-image-to-blob": "0.0.6",
    "react-native-modal": "^11.7.0",
    "react-native-modal-datetime-picker": "^9.2.0",
    "react-native-paper": "^4.7.2",
    "react-native-progress": "^4.1.2",
    "react-native-really-awesome-button": "^1.6.0",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.16.1",
    "react-native-splash-screen": "^3.2.0",
    "react-native-tab-view": "^2.15.2",
    "react-native-unimodules": "^0.12.0",
    "react-native-vector-icons": "^8.1.0",
    "react-native-video": "^4.3.0",
    "unimodules-permissions-interface": "^5.4.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.4",
    "@babel/runtime": "^7.8.4",
    "@react-native-community/eslint-config": "^1.1.0",
    "@testing-library/react-native": "^7.1.0",
    "babel-jest": "^25.1.0",
    "eslint": "^6.5.1",
    "jest": "^25.5.4",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native",
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/.shadow-cljs/"
    ],
    "testMatch": [
      "**/test-out/**/*_test.js"
    ],
    "snapshotResolver": "&lt;rootDir&gt;/customSnapshotResolver.js"
  }
}

zendevil 2021-03-23T02:54:20.310500Z

Btw, the project shadow/watch is running smoothly, i.e., the project is compiling smoothly but just the repl and the evaluation isn’t working

zendevil 2021-03-23T02:55:46.311200Z

It probably has something to do with how cider works

dpsutton 2021-03-23T02:55:53.311500Z

if you type (help) in that repl you'll probably get some helpful popup

dpsutton 2021-03-23T02:56:09.311700Z

(shadow/repl :foo) - Switches the current REPL to that of :foo in particular this

zendevil 2021-03-23T02:56:11.311900Z

Unable to resolve symbol: help in this context

dpsutton 2021-03-23T02:57:17.312300Z

try (shadow/watch :dev) and then (shadow/repl :dev)

zendevil 2021-03-23T02:58:05.313Z

I don’t know why but the repl is in humboi.events namespace and not in the shadow namespace

zendevil 2021-03-23T02:58:13.313200Z

it was in the shadow namespace before

zendevil 2021-03-23T02:58:30.313700Z

so cannot run shadow/watch

zendevil 2021-03-23T02:59:01.314Z

i don’t know how to go back

zendevil 2021-03-23T03:00:33.314600Z

oh yeah because I had done this: (ns humboi.events (:require [reagent.core :as r]))

zendevil 2021-03-23T03:00:41.314900Z

which had worked and changed the namespace

zendevil 2021-03-23T03:02:19.315300Z

yes I went back to (ns shadow.user) and (help) works

dpsutton 2021-03-23T03:02:43.315500Z

(doto 'shadow.cljs.devtools.api require in-ns)

zendevil 2021-03-23T03:03:23.315700Z

The strange thing is that I’m getting a java error in the shadow repl

sova-soars-the-sora 2021-03-23T03:08:40.316Z

Oh my ... ask the shell... this opens up a whole new world

2021-03-23T10:37:08.320100Z

Hi fellow clojurians Im deploying clojure deps.edn app to heroku. and it deployed successful. But heroku dyno restart (happens once every day automatically ) fails with

Error R10 (Boot timeout) -&gt; Web process failed to bind to $PORT within 150 seconds of launch
Here my Procfile command
web: java -cp ps.jar clojure.main -m reviews.system
and here is my main system file, Locally it takes around 30 seconds to start up server
(ns reviews.system
  (:require [integrant.core :as ig]
            [ring.adapter.jetty :as jetty]
            [reviews.server :as server]
            [migratus.core :as migratus]
            [migrations :as migrations]
            [reviews.db :as db]))

(def system-config
  {:shop/jetty {:handler (ig/ref :shop/handler)
           :port (Integer. (or (System/getenv "PORT") "3000"))}
   :shop/handler {:db (ig/ref :shop/postgres)}
   :shop/migrations {:db (ig/ref :shop/postgres)}
   :shop/postgres nil})

(defmethod ig/init-key :shop/jetty [_ {:keys [handler port] }]
  (println "server running on port 3000")
  (jetty/run-jetty handler {:port port :join? false}))


(defmethod ig/init-key :shop/migrations [_ {:keys [db] }]
  (let [config {:db {:datasource {:datasource db}}}]
    (migratus/migrate migrations/config)))

(defmethod ig/init-key :shop/handler [_ {:keys [db] }]
  (server/create-app db))

(defmethod ig/init-key :shop/postgres [_ _]
  db/spec)

(defmethod ig/halt-key! :shop/jetty [_  jetty]
  (.stop jetty))


(defn -main []
  (println "Running main!")
  (println "PORT: " (Integer. (or (System/getenv "PORT") "3000")))
  (ig/init system-config))

(comment 
  (def system (ig/init system-config))
  (ig/halt! system))

javahippie 2021-03-23T11:00:30.320400Z

Can you see the “PORT:” message from your main function? What does it say?

2021-03-23T11:07:36.320600Z

in case of successful run message is

2021-03-22T22:45:57.094366+00:00 app[web.1]: PORT:  38440
on restart timeout error, this message is not printed

pez 2021-03-23T11:57:07.324200Z

If I evaluate something like (range) then the sequence is realized, right? Is that because the REPL wants to print it, or why is it happening? When I do it through Calva (nrepl) I get no printing, but the CPU is exercised. Doing it from a clojure prompt it starts to print the sequence.

jkxyz 2021-03-23T12:11:08.324300Z

Yes, it’s realized in order to print it out at the REPL. Calva probably doesn’t print anything because it’s waiting until the sequence has been realized so it can show the result. If you eval (def foo (range)) , because def just returns the var #'foo , it will return immediately and not realize the sequence

pez 2021-03-23T12:48:45.327400Z

Thanks! Good with the tips about defining it. I'm going to demo Clojure to some people and want to mention the lazyness, but struggled with a good example since the cpu was telling a non-lazy story. 😀

jkxyz 2021-03-23T13:06:29.327600Z

I had a good case for a lazy infinite sequence recently: I had some fn that went from a number n to a string (in this case it was a table column heading: A, B, C, … AA, AB etc.) I used that fn to create an infinite sequence, as (def column-labels (map column-label (iterate inc 0)) such that (nth column-labels n) returns the right label. My view does something like (for [label (take max-columns column-labels)] [:th label]) . Because I def’d column-labels, it will only ever call column-label once per n and the sequence will realize for as many values as I need. (Of course this comes at the cost of memory as with any memoization, but I thought it was neat that I could do this 🙂). Then again 5 minutes later I also spent an hour debugging why I was getting unexpected values and it was because a lazy sequence wasn’t being realized at the right time.

pez 2021-03-23T14:20:11.328Z

Awesome case. Also no free lunches for anyone. 😃

2021-03-23T17:48:45.329500Z

@umardaraz4747 Please put longer messages like this inside of a "reply thread" on Slack, to avoid having large blocks of text at the top level that some people might not want to see. Another technique is to publish such text on Github, perhaps as a "Gist", and paste only a link to it in Slack.

☝️ 2
Franco Gasperino 2021-03-23T17:51:11.331300Z

hello all. Curious as to the difference here: => (int? 0) true => (filter #((% 0)) [int?]) class java.lang.Boolean cannot be cast to class clojure.lang.IFn (java.lang.Boolean is in module java.base.loader 'bootstrap'; clojure.lang.IFn is in unnamed module of loader 'app')

grazfather 2021-03-23T17:56:05.332900Z

you hade extra parens in your # func

wevrem 2021-03-23T17:56:10.333Z

Your anonymous function is being expanded into (fn [x] ((x 0))) and when you then pass int? into that function, you have ((int? 0)) which becomes (true) which results in trying to call true as a function and produces the error you received

Franco Gasperino 2021-03-23T17:59:18.335300Z

that makes sense. howevere, i would like the result of (int? 0) to be returned. a single parens set returns the function, not the eval of the expression

wevrem 2021-03-23T18:01:52.337600Z

Your filter is returning everything in the original sequence, everything in [int?], that passes the filter. int? passes the filter, so that is what is being returned.

Franco Gasperino 2021-03-23T18:02:09.337900Z

got it. thanks

Franco Gasperino 2021-03-23T18:02:34.338300Z

the recommended route is to map -> filter, then?

wevrem 2021-03-23T18:02:53.338600Z

Try this alternate to get a feel for what is happening: (filter (fn [x] (x 0)) [int? zero?])

Franco Gasperino 2021-03-23T18:02:59.338800Z

that's correct

wevrem 2021-03-23T18:04:19.340100Z

Is your goal to start with a sequence of functions and filter them in some way, so that you end up with a possibly smaller seq of functions?

Franco Gasperino 2021-03-23T18:07:41.342200Z

somewhat. let me provide the test here i've gotten working, and then will be happy to get a more idiomatic suggestion

wevrem 2021-03-23T18:10:15.343900Z

You might want to look at the keep function. You pass it a function f and a sequence, and unlike filter, it doesn’t return elements of the original seq, it returns the result of calling f on the elements of the seq, as long as the results are ‘truthy’.

(keep #(% 0) [int?])
=&gt; (true)

Franco Gasperino 2021-03-23T18:10:55.344400Z

great. that reduces the preceeding map call i would need to make

Franco Gasperino 2021-03-23T18:11:00.344600Z

thanks

wevrem 2021-03-23T18:11:35.345200Z

One more example with keep:

(keep #(% 0) [int? zero? pos?])
=&gt; (true true false)

wevrem 2021-03-23T18:12:05.345300Z

Correct. Keep is often a replacement for a combination of map and filter.

wevrem 2021-03-23T18:13:06.345500Z

I’d still be happy to see your test case and offer suggestions if you think it might be made more idiomatic. It is sort of odd looking what you are doing, but then again, I’m seeing it completely out of context.

Franco Gasperino 2021-03-23T18:14:19.346300Z

(let [tests [int? pos?] value-under-test 5] (= (count tests) (count (keep #(% value-under-test) tests)))) => true

Franco Gasperino 2021-03-23T18:14:27.346600Z

thats exactly what i was looking for. thanks again

Franco Gasperino 2021-03-23T18:19:12.346900Z

well almost, slight omission above, but the flow is correct 😃

wevrem 2021-03-23T18:19:40.347100Z

You could maybe use juxt and every? as an alternative:

(let [tests (juxt int? pos?)
      v-u-t 5]
  (every? true? (tests v-u-t)))

wevrem 2021-03-23T18:20:17.347300Z

It feels like juxt is the more appropriate function for what it looks like you are doing.

seancorfield 2021-03-23T18:25:08.347600Z

Using three backticks around your code will make it easier to read:

(let [tests [int? pos?]
        value-under-test 5]
  (= (count tests) (count (keep #(% value-under-test) tests))))
=&gt; true
or
(let [tests (juxt int? pos?)
      v-u-t 5]
  (every? true? (tests v-u-t)))
(you may need to change a Slack setting to not submit the message on ENTER when you’re inside the backticks — or just use shift-enter for newlines)

Franco Gasperino 2021-03-23T18:25:44.347800Z

👍

wevrem 2021-03-23T18:25:49.348Z

Thanks. That does look much better.

Franco Gasperino 2021-03-23T18:28:36.348300Z

had never known juxt was available

Endre Bakken Stovner 2021-03-23T18:30:09.349600Z

I cannot for the life of me remember the name of the function that let you pair up elements of a seq:

(aaaaargh [1 2 3 4] 2) ; ([1 2] [3 4])

Endre Bakken Stovner 2021-03-23T18:30:23.349900Z

Please help XD

wevrem 2021-03-23T18:30:28.350Z

partition

Endre Bakken Stovner 2021-03-23T18:30:31.350200Z

Thanks!

Endre Bakken Stovner 2021-03-23T18:30:46.350600Z

Should have tried that Hoogle for Clojure

wevrem 2021-03-23T18:31:18.350700Z

I feel like I’m always discovering a new function in the core library that does exactly what I needed. Fun discoveries!

Franco Gasperino 2021-03-23T18:32:16.350900Z

i was about to say it's similar to finding old gnu tools on your installations that had been around for decades

wevrem 2021-03-23T18:32:22.351100Z

I like to use http://clojuredocs.org. I seem to always have that open in a tab somewhere.

🙏 1
Franco Gasperino 2021-03-23T18:33:49.351400Z

i ended up with:

(defn value-passes-checks? [schema value]
  (let [{checks :checks :or {checks []}} schema]
    (every? true? (keep #(% value) checks))))

Franco Gasperino 2021-03-23T18:34:15.351600Z

(value-passes-checks? {:checks [int? pos?]} 5)
true

Franco Gasperino 2021-03-23T18:34:47.351800Z

(value-passes-checks? {:checks [int? pos?]} 0) false

Endre Bakken Stovner 2021-03-23T18:34:52.352Z

Thanks! This one is also great: https://borkdude.github.io/re-find.web/?args=2%20%5B1%202%203%204%5D

seancorfield 2021-03-23T18:35:04.352200Z

every? on [] and every? on nil should be the same so you could just use (:checks schema) directly, without the destructuring.

wevrem 2021-03-23T18:35:15.352400Z

That looks good. I wondered if you needed to parameterize your tests (which it looks like you did). I was going to recommend using (apply juxt checks) if that were the case.

Franco Gasperino 2021-03-23T18:35:58.352600Z

i have a case where an in-flight event (map) needs some basic parameter checking, defined by edn (or json). So leveraging spec in this case is a bit heavy as it's user-driven

Franco Gasperino 2021-03-23T18:36:48.352800Z

thanks, @seancorfield ill check that too

Franco Gasperino 2021-03-23T18:37:07.353Z

im working largely off the (somewhat dated) clojure 4 the brave

seancorfield 2021-03-23T18:37:43.353700Z

Ah, I suspect it errs on the side of very explicit code rather than more concise, more idiomatic code.

Franco Gasperino 2021-03-23T18:38:21.354200Z

yea, its a good entry point for transitioning

Franco Gasperino 2021-03-23T18:38:44.354600Z

and i'ts appreciated as i'm moving from python + pycharm -> clojure + emacs. so ill refactor some of this later

Franco Gasperino 2021-03-23T18:39:44.355600Z

tested some cljs + reagent + re-frame and..wow, impressed. now working on some backend jvm stuff

Endre Bakken Stovner 2021-03-23T18:39:57.356Z

This function is so simple I almost want to create a lambda:

(def add-dep [graph [node dep]] (dep/depend graph node dep))
However, it needs to be used like this:
(reduce add-dep (dep/graph) (partition 2 (range 10)))
Therefore I would need to destructure the pair in the reducing function. Is that possible?

dpsutton 2021-03-23T18:41:55.356300Z

look at apply

👍 1
Endre Bakken Stovner 2021-03-23T18:43:50.357500Z

Neat:

(reduce #(apply dep/depend %1 %2)  (dep/graph) (partition 2 (range 10)))

seancorfield 2021-03-23T18:53:01.357600Z

Learning Emacs at the same time as learning Clojure is a big hill to climb. What editor is pycharm based on?

seancorfield 2021-03-23T18:54:48.357800Z

Looks maybe IntelliJ? If you’re finding Emacs frustrating, you could try Cursive for IntelliJ and it might be more familiar…

seancorfield 2021-03-23T18:55:41.358Z

After 20+ years of using Emacs on and off, I eventually switched to Atom and last year to VS Code. A lot of folks like VS Code with Calva.

wevrem 2021-03-23T18:56:52.358200Z

Not to gang up here, but I echo Sean’s comments. I’ve been using VS Code since before I learned Clojure, and it works great.

NoahTheDuke 2021-03-23T20:14:35.359300Z

is it possible for a given file to be "loaded" when i use in-ns to switch to the file's namespace? or do I have to use (load "path/to/file.clj") each time?

dpsutton 2021-03-23T20:15:46.360Z

Sets *ns* to the namespace named by the symbol, creating it if needed. A common thing to do is (doto 'the-ns require in-ns)

dpsutton 2021-03-23T20:16:21.360400Z

your editor should have keybinding to require a ns and then load it

NoahTheDuke 2021-03-23T20:17:53.361300Z

cool, thank you

seancorfield 2021-03-23T20:21:25.362100Z

And you should pretty much never use load or load-filerequire is the way to go.

seancorfield 2021-03-23T20:21:39.362500Z

I’m curious as to why you feel the need to use in-ns?

seancorfield 2021-03-24T16:21:20.462200Z

If you want nice visualization of data structures while working in the REPL and/or debugging, I recommend Reveal. It makes a great client for tap&gt;.

seancorfield 2021-03-23T20:22:07.363Z

(I pretty much never use it but I see a lot of beginners trying to use it so I’m curious where that is coming from)

2021-03-23T20:32:50.363900Z

I don't do a lot of Clojure dev these days, and have not optimized my IDE setup by any means, but when I do, I sometimes use in-ns to switch the REPL to a different namespace, before re'defn'ing a function.

2021-03-23T20:33:01.364200Z

I believe a lot of IDE setups will automatically do the in-ns for you?

dpsutton 2021-03-23T20:37:31.365100Z

i'm kinda curious about this one. in nrepl based tooling there's no reason to sweat this as the ns is sent and handled for you. in socket based repls manual management of ns seems far more important

2021-03-23T20:39:33.365200Z

I have a very bare-bones setup with Emacs, no Cider, socket REPLs to JVM processes started at terminal outside of Emacs, inf-clojure for connecting to that socket REPL, and one hot key for "send previous form to REPL". The hot-key I use doesn't currently try to auto-detect the namespace of the buffer my cursor is in, so manual in-ns is useful there.

2021-03-23T20:40:10.365400Z

If I were doing Clojure for hours per day, I'd invest more time to find something less manual.

dpsutton 2021-03-23T20:42:05.365600Z

yes i've switched over to this exactly. (and landed a couple patches to inf-clojure to make this better)

2021-03-23T20:43:20.365800Z

Cool on the patches you've landed. You probably replicated one or two that I did locally but didn't bother to try to publish elsewhere.

dpsutton 2021-03-23T20:43:31.366Z

and i'm surprised i need to watch the ns so much. i'm pretty curious what @seancorfield does. He's been in socket land much longer than i have. I remember him evaluating ns forms each time in a new file which sets the ns. But i don't remember how he easily bounced between files and evaluated in different namespaces

seancorfield 2021-03-23T20:46:02.366200Z

@dpsutton Clover automatically wraps expressions in code to select the ns when you eval anything, which I think is what CIDER does too.

seancorfield 2021-03-23T20:46:17.366400Z

Chlorine/Clover (Atom/VS Code).

Franco Gasperino 2021-03-23T20:46:27.366600Z

ill take a look at atom. right now, im on ubuntu desktop and my projects largely use docker

2021-03-23T20:46:56.366800Z

That makes a lot of sense. It probably wouldn't be terribly difficult to enhance inf-clojure to do that, too, by parsing the first ns form in the current buffer

dpsutton 2021-03-23T20:47:03.367Z

the ns to evaluate in is a first class concept in nrepl.

seancorfield 2021-03-23T20:49:12.367200Z

@franco.gasperino The only issue with Atom is that ProtoREPL is no longer supported/maintained and Chlorine (which is very well supported and maintained) primarily uses a Socket REPL, not nREPL. It can connect to nREPL but that is not its primarily function. I would recommend VS Code over Atom because of that: and use Calva for nREPL (although I use Clover for Socket REPL because I prefer that setup — Clover is Chlorine, ported to VS Code).

seancorfield 2021-03-23T20:49:48.367400Z

I have Calva installed on VS Code and just have its nREPL UI disabled so I can use Clover for my (socket) REPL connections but Calva (and LSP) for everything else.

Franco Gasperino 2021-03-23T20:49:51.367600Z

does VScode require a windows environment?

dpsutton 2021-03-23T20:50:17.367800Z

i can see the convenience but i very much like that there's no real munging of things sent to the repl

seancorfield 2021-03-23T20:51:00.368Z

No, VS Code runs on Mac, Linux, and Windows.

seancorfield 2021-03-23T20:52:03.368200Z

I do all my Clojure development on macOS for work and Ubuntu outside of work — the latter on WSL2 on Windows 10, so I run VS Code on Windows there: it has a really nice “Remote-WSL2” feature that lets you run the editor on Windows but access all of the files and run all of the extensions on Linux via WSL2.

Franco Gasperino 2021-03-23T20:52:35.368400Z

ok im checking it out. thanks for the tip

seancorfield 2021-03-23T20:54:55.368600Z

There’s a really helpful #calva channel if you need help with it.

2021-03-23T22:00:08.368800Z

@andy.fingerhut for that workflow, you might also appreciate monroe