Fork me on GitHub
#parinfer
<
2016-02-26
>
cfleming00:02:02

@sekao: I just pushed 0.3.0, which has the cursorX fix.

cfleming00:02:50

It’s not published anywhere right now, you’ll have to pull it and build it.

chrisoakman00:02:44

thank you for keeping up with parinfer-jvm @cfleming simple_smile

chrisoakman00:02:56

a lot of that was Parinfer related simple_smile

cfleming01:02:39

Haha, nice simple_smile

sekao01:02:03

@chrisoakman yep I got the stickers! I'm only gonna give them to my students who like clojure

chrisoakman01:02:41

rationing, eh?

sekao01:02:45

@cfleming thanks very much I'll check it out

sekao01:02:30

It's the carrot. Haven't figured out the stick yet

chrisoakman01:02:32

I don't remember where I heard this from, but you're teaching at The Iron Yard these days?

sekao01:02:23

Yep, I'm their first java instructor and I teach some clojure as well

chrisoakman01:02:57

I considered teaching at their Houston chapter here, but I couldn't bring myself to teach non-clojure

cfleming01:02:40

@sekao: Do you teach Clojure to non-programmers, or to people with other dev experience?

sekao01:02:52

Most have no experience other than the java I teach them beforehand

sekao01:02:31

I get into clojure weeks 8 and 9 which is the functional programming part

cfleming01:02:55

How do they find it?

cfleming01:02:02

Is it difficult for them after Java?

sekao01:02:34

Yeah they actually found it pretty hard. One problem was that they had a really hard time editing it. They couldn't remember paredit commands, and without it their parens were constantly unbalanced. Hence why I'm here :)

cfleming01:02:46

Nice, I’d be interested to hear how it works out for them.

chrisoakman01:02:55

yeah, that's huge

cfleming01:02:57

I have a couple of people interested in using Cursive for education

chrisoakman01:02:09

I need to write about this, but I think Parinfer is a game-changer for Lisp

cfleming01:02:36

I’m very interested to see how newbies find it.

chrisoakman01:02:38

it totally removes the "balance parens" or "learn an extreme editing mode" part of the equation

chrisoakman01:02:54

(I think the learning curve of paredit is too steep)

chrisoakman01:02:31

I'm trying to promote the idea that Parinfer turns Lisp into an off-side rule language like Python or CoffeeScript

cfleming01:02:41

Right, it pretty much does that.

cfleming01:02:09

I should actually take PyCharm for a spin, I don’t know what editor functionality they provide around indentation.

sekao01:02:26

yeah i’ll definitely let y’all know how it goes. my current class is on week 4 so i have some time before we get into clojure

chrisoakman01:02:05

sounds good; let us know if you run into anything

chrisoakman01:02:26

FYI - I'm a fan of The Iron Yard. I have spoken to every cohort here in Houston

chrisoakman01:02:52

in general I'm bullish on the idea of these coding bootcamps; hired some people out of one at my last job and taught them CLJS

chrisoakman01:02:00

they were some of my best team members

sekao01:02:10

yeah it’s been a great gig. i dunno if any others are teaching clojure or other functional langs. they’ve given me a lot of leeway

chrisoakman01:02:39

I've been toying with the idea of giving a weekend clojure workshop here in Houston with Shaun

chrisoakman01:02:48

we have enough people who are interested I think

chrisoakman01:02:12

I feel like people need to dedicate some time to it; I don't think it's the sort of thing you can really learn in a few hours

snoe01:02:18

That's really cool @sekao, grats on the gig

snoe01:02:48

- (Case from outpace)

cfleming01:02:02

Yeah, I helped out at a ClojureBridge - even with a whole day, a lot of the code they wrote was filling in the blanks in code they’d been given.

sekao01:02:36

@snoe: hey good to hear from you. did you see that bryce (a.k.a. remington) is speaking at clojure/west?

sekao01:02:01

he was my team lead at outpace FYI to others

sekao01:02:11

never met him in the flesh hah

snoe01:02:17

Yup, didn't see the topic, is it about his game?

sekao01:02:26

ya, the game he made with my library 😃

sekao01:02:51

well, a heavily edited fork of my library

sekao02:02:07

@cfleming: been playing with the new release. in a repl, i did (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) (int 0)). the result has a text of "(defn hi []\n )”, which is right (if indenting by one space is the intent), but it seems the cursorX is 0. shouldn’t it be 1 so it is next to the end paren?

sekao02:02:06

i’m not sure what cursor-dx is BTW, i just passed 0

cfleming02:02:35

Yeah, cursor-dx is if you’re in paren mode and you know how much the current edit moved the cursor by.

cfleming02:02:47

I don’t think any of the integrations handle it right now.

sekao02:02:22

oh should i set it to something else?

cfleming02:02:42

I think null is probably the best thing to pass right now.

sekao02:02:14

ok. but as for the cursorX, am i right that it should be 1?

cfleming02:02:58

So I think the issue might be that the lines are 0-based in parinfer.

cfleming02:02:07

One sec, firing up a REPL

cfleming02:02:27

Damn, I am currently REPL-less

cfleming02:02:17

Ok, so that actually looks right. Since the lines are 0-based, your caret should be at the start of the second line.

sekao02:02:35

shouldn’t it move the cursor to be next to the end paren? i tried the same thing in parinfer.js: parinfer.parenMode("(defn hi []\n)", {cursorX: 0, cursorLine: 1}) and the result’s cursorX is 1.

cfleming02:02:11

I’m getting the result cursorX as one too.

cfleming02:02:24

The only difference is that I’m passing null as the cursorDx

sekao02:02:02

weird…i tried (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil) and the cursorX is still 0 for me.

sekao02:02:01

unless you’re talking about the js version

cfleming02:02:19

No, I’m definitely getting a cursorX of 1.

cfleming02:02:53

Connecting to local nREPL server...
Clojure 1.8.0
nREPL server started on port 58111 on host 127.0.0.1 - 
(import com.oakmac.parinfer.Parinfer)
=> com.oakmac.parinfer.Parinfer
(.-cursorX (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil))
=> 1

cfleming02:02:25

How did you build the version you’re using?

sekao02:02:10

i did ./gradlew build and copied the jar from build/libs

cfleming02:02:12

./gradlew clean install, and then reference com.oakmac/parinfer “0.3.0"

cfleming02:02:29

I think that should do the same thing.

cfleming02:02:56

I’m actually pretty new to gradle, but I can’t imagine that does anything too different.

cfleming02:02:21

I did the install, and then in a lein project pulled in [com.oakmac/parinfer "0.3.0”] as a dep.

sekao02:02:48

wait, (.-cursorX (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil)) actually does return 1 for me. i was doing (def res (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil)) and then (.-cursorX res), which returns 0.

cfleming02:02:54

I get that too.

cfleming02:02:59

How is that possible?

sekao02:02:24

no idea 😃

cfleming02:02:05

I assume the tests pass for you?

sekao02:02:36

yeah i didn’t get any test failures when i built it

cfleming02:02:06

So that is officially extremely weird.

sekao02:02:14

is there something about kotlin’s classes that make them behave differently?

cfleming02:02:17

I have no idea what is going on there.

cfleming02:02:24

I don’t think so.

cfleming02:02:38

That result should just be a normal Java class with normal fields.

cfleming02:02:39

The only thing I can think of is that in the first case, type inference will give the correct type, whereas in the second it will not.

sekao03:02:51

(.-cursorX (deref (def res (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil)))) also returns 1. i have no idea what that means

cfleming03:02:36

~/d/parinfer-test> javap -classpath ~/.m2/repository/com/oakmac/parinfer/0.3.0/parinfer-0.3.0.jar com.oakmac.parinfer.ParinferResult
Compiled from "parinfer.kt"
public final class com.oakmac.parinfer.ParinferResult {
  public java.lang.String text;
  public boolean success;
  public java.lang.Integer cursorX;
  public com.oakmac.parinfer.ParinferException error;
  public java.util.ArrayList<com.oakmac.parinfer.LineDelta> changedLines;
  public com.oakmac.parinfer.ParinferResult(com.oakmac.parinfer.MutableResult);
}

cfleming03:02:20

The equivalent Java class also prints 1

cfleming03:02:27

Interestingly, I get (defn hi []\n) for the text

cfleming03:02:36

i.e., no extra space added

sekao03:02:38

really? (.-text res) has the space for me

sekao03:02:12

same when not defing a var

chrisoakman03:02:43

what is the status of success for these calls?

chrisoakman03:02:55

I also have a completely unrelated question

sekao03:02:15

true in both cases

chrisoakman03:02:20

I pulled the latest parinfer-jvm and ./gradlew install is taking bloody forever

chrisoakman03:02:36

I've been on that screen for like 10 minutes

chrisoakman03:02:54

oh wow - it's moving now

chrisoakman03:02:59

haha, right as I uploaded that

chrisoakman03:02:11

now I suppose there is a different problem

chrisoakman03:02:45

I just ran it again and got the same thing

chrisoakman03:02:52

what is clojuresque ?

chrisoakman03:02:43

ok, I got things working by typing ./gradlew clean

cfleming03:02:10

clojuresque is the Clojure plugin for Gradle

cfleming03:02:25

It’s what allows the tests to be run by Gradle, in this case.

chrisoakman03:02:53

I'm just updating the README

chrisoakman03:02:57

making sure the setup instructions work

cfleming03:02:12

Ok cool, I’m surprised that that requires a clean

chrisoakman03:02:31

I just know it worked after I tried the ./gradlew clean clojureTest command

chrisoakman03:02:50

I haven't updated my system in a while; could be something left over from whatever I was doing previously with Kotlin

chrisoakman03:02:05

I just want to make sure the README is bulletproof

chrisoakman03:02:22

it's painful when projects don't have clear setup instructions

cfleming03:02:36

Yeah, no doubt.

cfleming03:02:01

I actually have to head off. I have no idea what might be causing that problem, sorry - I’ll try to look at it over the weekend.

cfleming03:02:06

It’s really bizarre.

chrisoakman03:02:20

pretty sure this crew are the only people using Parinfer at the moment anyhow 😉

cfleming03:02:58

Hehe, true enough - it seems to be working pretty well for me, although I have a bunch of niceties to add around the edges.

cfleming03:02:14

But undo/redo and caret/selection movement all seems to be working well.

chrisoakman03:02:12

I'm sure people will be glad to hear that and play around with it

sekao04:02:49

found a workaround...wrapping the calls in functions that return the results in a map seems to avoid the weird behavior

sekao04:02:00

still don’t know why though

chrisoakman04:02:55

wonder if it has anything to do with Kotlin

cfleming07:02:34

I’m going to investigate that further, it’s really strange.

cfleming07:02:05

I thought it was something to do with the fact that the field was primitive, but in fact it’s not, it’s an Integer object.

cfleming09:02:47

I added a toString() to the result object, just to confirm that the actual result itself is different - it is:

Connecting to local nREPL server...
Clojure 1.6.0
nREPL server started on port 60022 on host 127.0.0.1 - 
(import com.oakmac.parinfer.Parinfer)
=> com.oakmac.parinfer.Parinfer
(def res (Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil))
=> #'user/res
res
=> #<ParinferResult ParinferResult(text='(defn hi []
 )', cursorX=0, success=true)>
(Parinfer/parenMode "(defn hi []\n)" (int 0) (int 1) nil)
=> #<ParinferResult ParinferResult(text='(defn hi []
 )', cursorX=1, success=true)>

cfleming09:02:15

I have literally zero idea why the context in which the function is invoked should affect the result.

cfleming09:02:29

But at least it seems reproducible and I can debug it.

denik14:02:15

I’m curious: does any editor compute the cursor position based on edit deltas?

dominicm15:02:55

@cfleming: Have you tried setting up parinfer as nrepl middleware? That would really enable parinfer for emacs users quite well (and anything that can connect to the nrepl really..)

cfleming18:02:40

@denik: The IntelliJ integration I’m working on now does.

cfleming18:02:26

@dominicm: No, I haven’t. Paredit is really a client-side thing since it works on the source code, not during evaluation.

dominicm19:02:37

@cfleming I agree that really it's client side. But I'm trying to come up with a way to have one parinfer implementation to rule them all

dominicm19:02:54

Javascript is almost perfect. But the emacs guys are lacking

dominicm19:02:19

I mean, even java could run it on nashorn

denik20:02:45

@cfleming: is there a public repo for it? what does it use for inputs?

shaunlebron22:02:28

@dominicm: oh man, was it an oversight to port parinfer to kotlin instead of using nashorn?

snoe22:02:20

nashorn startup time is pretty egregious, you really need pooling

shaunlebron22:02:33

@snoe idk what you mean by pooling. is that jvm specific?

snoe22:02:41

so in order to run nashorn you need to create an engine, but the engine takes 2-5s to start IME. so you'd usually start a bunch put them in a pool, and take them out and refill as needed

snoe22:02:37

like a connection or thread pool

shaunlebron23:02:30

ha okay. thanks

shaunlebron23:02:53

wonder if syncing features across ports is easier than pooling then

dominicm23:02:01

@shaunlebron: I mean.. maybe? 😛 Might have saved you some time, and I think consistency across implementations is important.

dominicm23:02:36

ah, looks like snoe is the boss on this stuff 😛

sekao23:02:22

looks like i’ve mostly got parinfer into nightcode. am i correct that one-space indentation is the intended behavior? it’s not how i’ve normally indented in the past but that seems to be the behavior in both parinfer.js and parinfer-jvm

snoe23:02:53

parinfer only moves stuff to boundaries, indentation is officially editor's problem

sekao23:02:33

@snoe: i mean paren mode. the output string of ”(defn hi []\n)” is ”(defn hi []\n )”. should i adjust it after the fact to insert two spaces instead of one?

snoe23:02:55

I believe so, yeah. Although I honestly don't use paren mode very much

sekao23:02:51

i just use paren mode to pre-process my files and indent after hitting enter

sekao23:02:21

i could look into adjusting its output but i thought the point of paren mode was to figure out indentation for me so indent mode can be used afterwards

sekao23:02:41

doing that adjustment afterwards will be pretty complicated

snoe23:02:12

so I think indent mode handles the pressing enter issue, my plugin doesn't need to indent there

sekao23:02:17

hmm really? i don’t get auto-indent unless i run paren mode when i hit enter. for example, parinfer.indentMode("(defn hi []\n)", {cursorX:0, cursorLine:1}) returns a result with a text of "(defn hi [])\n” which would not be correct behavior for auto-indenting

snoe23:02:17

eh sorry, I'm past the depth of my understanding of the details then