Fork me on GitHub
#beginners
<
2016-11-27
>
lmergen04:11:10

hey guys, i need a bit of feedback on how to best approach a problem i'm trying to solve

lmergen04:11:53

so, basically, i'm writing a library that should accept a value (typically a map) that can have nested functions

lmergen04:11:35

what would be my best approach to handling this ? i'm feeling like eval is not my best option here, since it probably allows way too much logic -- but i'm not sure

lmergen04:11:23

so, e.g., {:foo :bar} would be a perfect value to pass to this library, but so are (fn [] {:foo :bar}) or [:foo {:bar (fn [] :wombat)}] which would return {:foo :bar} and [:foo {:bar :wombat}] respectively

lmergen04:11:09

or should i perhaps be using walk

lmergen04:11:26

well, i ended up doing this:

(postwalk (fn [x] (if (function? x) (x) x)) data)
which is probably the most appropriate solution here

ashnur08:11:35

following the https://github.com/bhauman/lein-figwheel/wiki/Quick-Start results in Figwheel Server: Resource not found

ashnur08:11:45

is this expected?

ashnur10:11:19

anyone uses spacemacs?

ashnur10:11:22

how does it work with clojure? I have to use something in CLI, so either vim or spacemacs. i tried nvim-parinfer and it was unusable, probably someone who is familiar with the situation can resolve it, but I couldn't

ashnur10:11:35

but parinfer is not in spacemacs yet

veggiemonk10:11:43

@ashnur check this out, it’s for Atom but it will get let you start smoothly https://atom.io/packages/proto-repl

ashnur11:11:32

how can i use that in the cli?

ashnur11:11:21

for 2 days i am asking for help, and the first person who responds doesn't even read the question

ashnur11:11:28

the famous clojure community...

roelofw11:11:55

@ashconnor I think most of the developers do not use spacemacs but atom or cursive

ashnur11:11:52

ok, now I think you are just trolling me

roelofw11:11:24

nope, IM telling only what I think and see

ashnur11:11:56

ok, so you are telling me that if i have this limitation i should just give up, because there are no ways ahead

ashnur11:11:00

thanks for helping!

roelofw11:11:41

No, maybe ask in the clojure channel

roelofw11:11:57

I think you never have to give up

rauh11:11:12

@ashnur I don't use emacs anymore but Cursive, can I ask the reason behind "I have to use something in the CLI"?

rauh11:11:30

As to your question: You might get better help in #editors or #emacs

rauh11:11:04

I ask, because you could use more beginner friendly editors, and connect to a remote REPL (if that is the reason you need to use the CLI)

ashnur11:11:38

if you give me another laptop that can run those things, sure

roelofw11:11:19

I think that atom can run on most of the laptops

ashnur11:11:33

it can, but do i want to endure the sluggishness of it?

ashnur11:11:07

emacs through ssh is less slow

roelofw11:11:30

So you work on a server ?

ashnur11:11:30

nah, it's just next room, but where i live now has no place for a table, so i can't use that machine because no place to put the monitor and the keyboard, i mean i tried but my back got hurt from the awkward position

ashnur11:11:57

do i really have to tell you my life story to believe when i say i have to it's not a "i think i might have to but actually i am stupid, please decide for me"

roelofw11:11:25

nope, We just try to help you

roelofw11:11:58

why not run clojure on your laptop then

ashnur11:11:06

i don't really see the help part, i am sorry 🙂

ashnur11:11:28

i see the try to make me be like you part, and i believe that you believe that would be helpful for me

ashnur11:11:53

i am not installing the jvm on this machine

ashnur11:11:02

there is enough shit on it already

ashnur11:11:19

i checked the nodejs version but it had some issues, gave up on it

roelofw11:11:00

oke, then I hope you get help from another person. I agree with rauh that #editors or #emacs you can get help sooner as here

ashnur11:11:56

thanks, i joined those channels too

roelofw12:11:39

@ashnur good luck

curlyfry14:11:50

@ashnur I haven't used it personally, but I hear spacemacs is a great match for Clojure. Check out vim-fireplace as well if you like vim.

gowder14:11:07

@ashnur: I use spacemacs. It has a clojure layer that works pretty fine right from the get-go, hasn't required much setup (though I usually don't use a repl in-editor), and has all the basics down (code highlighting, autocomplete, paredit functionality etc.) All I've done by way of setup is add the clojure, evil-cleverparens, and auto-completion layers and then in my user config:

(spacemacs/toggle-evil-cleverparens-on)
  (add-hook 'clojure-mode-hook #'evil-cleverparens-mode)
  (setq cider-show-error-buffer nil)
  (with-eval-after-load 'clojure-mode
    (dolist (c (string-to-list ":_-?!#*"))
      (modify-syntax-entry c "w" clojure-mode-syntax-table )))

gowder14:11:20

There's also a spacemacs channel here

curlyfry14:11:02

@ashnur Did you resolve your figwheel issue? I'm not at my computer so I'm afraid I can't give any better help than "it worked for me"... There is a #lein-figwheel channel as well that the author of figwheel checks from time to time.

gowder14:11:45

I think some people add parinfer to their spacemacs config too as a separate package. (I don't much like parinfer myself, so I've not tried. Spacemacs has baked in parens matching, rainbow parens, and lisp editing mode with slurp and such, plus the clojure mode indenting is awesome; those are quite enough for me)

az16:11:27

Hi all. Trying to get protorepl working with a reframe project. Would like to enable the auto eval file option, when I do I get a bunch of warnings though. Showing errors on things like enable console print. Any tips?

ashnur17:11:45

thanks for all the responses, will check the mentioned tools

az17:11:32

@dorianc.b Thank you. Are you able to auto eval cljs files? I was able to run clojure without errors, but I get these errors with the cljs

ashnur17:11:23

@curlyfry nope, i still get resource not found

roelofw18:11:13

Any Linux clojure developers here ?

dorianc.b18:11:36

@limix oh my apologies I misread I didn’t realize you meant cljs. I also get the same error. When I start proto-repl it does state that it is unsupported. You can ask the developer of proto-repl in the proto-repl channel

az18:11:22

@dorianc.b I think it is limited, but what I have been trying to figure out is how can I connect to a remote repl

az18:11:33

proto-repl has the option to connect to a remote repl

az18:11:00

trouble is I don’t understand how to start a remote repl that will eval the forms and load the ns etc

az18:11:10

I have just been using lein figwheel and that runs fine

az18:11:44

I can interact via the command line, but I don’t see a repl address and port to connect to via proto-repl

az18:11:07

Do I need to use figwheel + sidecar + nrepl + piggieback?

roelofw18:11:19

Is this about atom ?

az18:11:34

yes, the repl addon for atom

az18:11:40

proto-repl

roelofw18:11:23

oke, I was thinking of using it locally on Linux but maybe I have to look for another one

haywood20:11:59

proto-repl doesn't work with clojurescript

haywood20:11:11

if you want to connect to figwheel over nrepl you have to use repl-lite in atom

haywood20:11:20

it's pretty bad, and I've been meaning to improve it, but it works

haywood21:11:13

@limix piggieback etc is all complicated (to me:P), to get up and running with atom, create a new chestnut project because it's going to give you all the things you need to connect to figwheel over nrepl. lein new chestnut my-project cd my-project lein repl that's gonna kick you into the user namespace which is the stuff in dev/user there are functions in there you use, but before that grab the nrepl port number that was outputted from lein repl At this point you want to switch to atom and connect to the nrepl instance using repl-lite, do that with the shortcut ctrl+r (let go) r input the nrepl port into the text box (this text box is absolute shit for some reason) and hit return. this should kick you into the user namespace now type (run) and with your cursor on the closing paren, hit ctrl+r (let go) i this is the shortcut to eval a sexp, this will start figwheel once that's done, boot the browser repl with (browser-repl)

haywood21:11:30

if you want to evaluate a block or a variable, you highlight the thing and do ctrl+r (let go) j

az21:11:04

@haywood thank you this is great, will try it out

haywood21:11:16

dude, I struggle so hard with tooling

haywood21:11:30

haha hopefully this helps

haywood21:11:13

also if you're not using parinfer, you need to be

haywood21:11:16

atom parinfer is ace

az21:11:50

Hopefully, I’m still just in the early stages, so even just running figwheel is already on par with all my other tools, but the auto eval in proto-repl is just so amazing and of course eval a block.

az21:11:10

yes I have parinfer installed it’s really great

haywood21:11:23

yea, proto-repl only works with clojure though right?

haywood21:11:32

because it wraps calls in eval or something

az21:11:12

I was able follow a figwheel config that enabled nrepl to start

haywood21:11:48

running figwheel from the repl via lein repl is def the way to go as far as nrepl and figwheel are concerned

az21:11:50

it has sidecar and piggie, and I was able to remote connect to nrepl from proto-repl

haywood21:11:05

cool beans

az21:11:05

then I can run lein figwheel, and I see nrepl start

az21:11:21

I was able to auto eval some re-frame components

az21:11:27

seems like it works

haywood21:11:34

I'll have to re-visit

az21:11:10

:figwheel {
  ;; Start an nREPL server into the running figwheel process
  :nrepl-port 7888

  ;; Load CIDER, refactor-nrepl and piggieback middleware
  :nrepl-middleware ["cider.nrepl/cider-middleware"
                     "refactor-nrepl.middleware/wrap-refactor"
                     "cemerick.piggieback/wrap-cljs-repl"]
}

az21:11:19

that’s the snippet from figwheel wiki

haywood21:11:49

👍:skin-tone-2:

az21:11:08

but I still can’t do (enable-console-print!) in an auto eval file

az21:11:43

I’m sure I’m just not there yet with understanding what namespaces are auto loaded