Fork me on GitHub
#hoplon
<
2016-12-11
>
mynomoto02:12:32

@micha sometimes I miss the ability to have lenses on a loop-tpl/`for-tpl`, do you see a problem allowing it?

micha02:12:15

hm, i think it would be ok

micha02:12:22

does it not work?

mynomoto02:12:47

Don't think there is a way of doing that currently. Am I mistaken?

mynomoto02:12:21

I mean (for-tpl [lens coll] ...)

micha02:12:48

i don't think there is a way to automatically generate a lens

micha02:12:56

how would you do it?

mynomoto02:12:56

It shouldn't always work but if I make sure that coll is a vector of something that implements the (assoc c idx v) it could be a useful thing.

micha02:12:16

maybe for-tpl should accept a 3rd binding form?

micha02:12:19

or something like

mynomoto02:12:55

Yeah, that's what I was thinking. Do you see some problem with performance or other practical impediments?

micha02:12:04

(for-tpl [thing things :fn #(swap! things assoc %1 %2)]
  ...

micha02:12:16

:fn is a bad name obviously

micha02:12:53

i don't think there is any real performance issue, especially if it's optional

micha02:12:26

or maybe we make some interface that things there would implement

mynomoto02:12:27

That could make some code quite elegant...

micha02:12:52

actually if things itself is a lens

micha02:12:08

or if it's an input cell

micha02:12:20

in either of those cases we could presumably make thing a lens then

micha02:12:39

does that sound correct?

mynomoto02:12:47

Yeah, it certainly fails for formula cells.

micha02:12:01

yeah we can check that at runtime

mynomoto02:12:20

I have to go now, but will toy with that later.

micha02:12:27

i'll think about it a bit

grant02:12:55

Is there an easy way to make castra give you more information in an error than #error {:message "Server error.", :data {:castra.core/exception true}}?

micha02:12:01

you should be able to see a stack trace

micha02:12:52

it is (.-serverStack the-exception)

micha02:12:08

you can do like (.log js/console (.-serverStack the-exception))

grant02:12:28

Oh, cool, let me try that.

grant02:12:37

@micha Does the exception come back in the error cell?

micha02:12:14

yes it should

grant03:12:04

@micha Awesome. ๐Ÿ˜„ Works, and bug fixed. Thank you, Micha.

micha03:12:49

dude nice!

micha03:12:12

that's a good idea

flyboarder04:12:03

@micha thanks, trying to give back to this amazing community!

alandipert04:12:19

@flyboarder if you have the cycles and would be interested, http://hoplon.io could use some love

alandipert04:12:02

it's made w/ hoplon, but has some jank CSS goin' on

flyboarder05:12:35

@alandipert whats wrong with the CSS?

alandipert05:12:31

looks crappy on ipads and phones

alandipert05:12:46

the guy who made it originally did a nice job with it, but something was lost when i hoplonified

alandipert05:12:40

oh right - yeah, the examples don't flow properly when the window is made narrow on desktop or mobile

flyboarder05:12:34

@alandipert it would be great if we could get KLIPSE fully working in Hoplon, that way we can use it for the examples

alandipert05:12:10

oh man, yeah

alandipert05:12:16

i thin mynomoto made some progress there

flyboarder05:12:47

@mynomoto what is the status of KLIPSE and Hoplon? Is this something we can try and complete as a Holiday gift to the community?

alandipert05:12:33

i'm totally down to help with that, i'll have a lot of hacking time next week

thedavidmeister08:12:09

aaaah let me know if you get KLIPSE working @alandipert @flyboarder

thedavidmeister08:12:21

very interested in plugging that into my component library

meeli11:12:56

@alandipert i can help fix the css on the hoplon site if you want

thedavidmeister11:12:41

@flyboarder mk! looks cool ๐Ÿ™‚ although i canโ€™t think of anything to use it with off the top of my head

candera14:12:57

Speaking of externs @micha, I had to go back and do the whole foreign lib thing for jQuery.minicolors - I got it working fine using the approach you helped me with the other day. And then I deployed it to my staging site. Which uses advanced compilation. And it broke in confusing ways. So now itโ€™s done properly. ๐Ÿ™‚

mynomoto14:12:05

@candera are you familiar with the fence library? It's a nice option to externs.

micha15:12:21

hi @meeli, welcome!

micha15:12:07

@candera i'm interested to hear more of your thoughts about javelin on the server sometime

mynomoto15:12:01

@flyboarder @alandipert I didn't had time to go back to Klipse on Hoplon other than research the problems. So basically macros needs to be rewritten in cljs itself. The one that looks more troublesome is the string interpolation, other stuff seems more direct.

mynomoto15:12:42

@flyboarder It would be amazing if you get that to work. I just deleted stuff that stopped if from working at all.

flyboarder15:12:47

@mynomoto I'd be willing to give it a go! If my understanding is correct, because we dont have access to clj we need to rewrite all the macro's correct?

mynomoto16:12:08

@flyboarder that's basically it.

micha16:12:23

also it means a much larger js file

micha16:12:52

the compiled js will need to include a lot of runtime that is compiled at build time that will now need to be compiled at runtime

mynomoto16:12:07

@flyboarder some of it is straightforward, but other parts may be trick if we depend on java things.

alandipert16:12:24

@meeli that would be really helpful re: css! if you work on it and have any q's, let me know

mynomoto16:12:35

@micha that is only when using the bootstraped version no?

mynomoto16:12:07

If you use the clojurescript compiler it will use the clj version as usual.

micha16:12:35

@mynomoto yeah, i'm not sure how that works exactly

mynomoto16:12:43

@flyboarder the working version with no macros working is https://mynomoto.github.io/hoplon-klipse/

micha16:12:47

like how to have the two implementations coexist

alandipert16:12:10

i forgot also that i explored driving the hoplon task as a castra endpoint and made a little progress, but i think i trashed the code. was straightforward-ish. micha and i hacked on that a bit before realizing it felt like only a little more work to port the damn thing to cljs

micha16:12:10

maybe they don't coexist and we have two separate jars

mynomoto16:12:38

@micha you use cljc files for macros and the #clj version will be used for the clojurescript compiler and the #cljs version for the bootstraped version.

mynomoto16:12:34

@flyboarder https://github.com/mynomoto/hoplon-klipse/blob/gh-pages/index.html#L21 points to the repositories I'm using. I think the only things I did was deleting stuff until it worked.

micha16:12:27

@mynomoto awesome i was ust going to ask

micha16:12:56

also i was thinking about the -tpl lens issue

micha16:12:10

an interesting problem

micha16:12:38

it means creating a macro that inverts clojure destructuring sort of

alandipert16:12:53

at least we know it should be called restructure

micha16:12:23

deep-restructure2

mynomoto16:12:06

@micha Oh, that sounds crazy, I was thinking that shouldn't be allowed

micha16:12:05

what were you thinking the rules would be?

micha16:12:23

perhaps like

micha16:12:13

hm i dunno

mynomoto16:12:39

Or cells destructuring should lens all the way down...

mynomoto16:12:52

What I was thinkimg is only [lens vector] is allowed.

mynomoto16:12:13

For the lens version

mynomoto16:12:41

I forgot that destructuring was allowed there.

micha16:12:26

there are also very useful cases like this that wouldn't work:

micha16:12:51

(for-tpl [[i thing] (cell= (map-indexed list things))]
  ...

mynomoto17:12:50

Yeah, don't think there is a way to avoid that. Unless everything is a lens which is overkill.

micha17:12:08

yeah i don't think it's even possible in lisp

micha17:12:14

to find the inverse function in all cases

micha17:12:39

like (cell= (+ (rand-int 100) x))

mynomoto17:12:40

Yeah, finding the inverse in that case is probably not useful.

mynomoto17:12:43

I'm looking at your form machinery now. You don't validate fields one at a time right?

micha17:12:37

they are validated individually, in that you get separate validation error messages

micha17:12:49

but the entire form is submitted to the backend for validation as a whole

micha17:12:20

so the backend could fail validation for eg password confirmation doesn't match or things like that

micha17:12:30

and you can display the errors in the right places

micha17:12:42

i haven't needed any clientside validation so far

micha17:12:02

the backend is plenty fast enough to handle all of the validation in real time with no perceptible delay or lagging

micha17:12:03

for the above to work smoothly you would want to have the backend rpc functions or whatever accept a map of arguments instead of positional ones

micha17:12:18

so it can easily associate errors with specific fields

mynomoto17:12:31

We already do have client side validation on work that happens on blur of the field, I'm looking for an abstraction for that. I have one, but I'm looking around for a better one. Not related, I like that map of cells but that makes harder to create formula cells using those right?

micha17:12:45

it's a tradeoff yeah

micha17:12:34

you can end up with ugly things like (cell= (doit ~(:password (:errors machine)))) or something

micha17:12:10

but there were issues with having one cell containing a map, too

micha17:12:31

because you'd end up with more cell= stuff

micha17:12:42

i'm not sure i made the right choice with it though

micha17:12:54

so if you try it the other way and it works better i'd be interested to see

mynomoto17:12:34

I used a result cell with {:success {:server-data ...} :error {:server-error ...} :form {:form-data}} don't remember having much trouble with it.

mynomoto17:12:03

It could use better names thought :thinking_face:

micha17:12:20

interesting

micha17:12:48

so the machine has a "state" cell that contains all of its internal state?

mynomoto17:12:14

Yes, and things should always be in the same path except for the first one that is the type of data.

micha17:12:40

whenever you have a chance i'd be interested to see what you did

flyboarder17:12:57

@mynomoto sorry was in a video call, I will look into the klipse stuff thanks!

mynomoto17:12:26

@flyboarder np, it will be awesome if you make progress on that!

mynomoto17:12:21

@micha I will try to put something together. I'm currently working on a datascript version where the db is the only cell that is not a formula and seeing how that works. If the baby helps I may put something on github later today.

mynomoto17:12:07

@micha What is the use case of a constant formula cell?

micha18:12:07

some formula cells are constant, like this:

micha18:12:27

(defelem foop [{:keys [barp]} _]
  (div :id (cell= (str "thing-" barp)) "hello world"))

micha18:12:54

in that case barp might be a cell or it might not

micha18:12:13

the idea is that some efficiency can be gained by knowing that the formula is a constant

micha18:12:20

you can avoid adding watches in some cases, etc

flyboarder18:12:20

@mynomoto: if you have a generic cell feel free to submit it to the brew repo!

micha18:12:16

in the above example if barp is a constant then you can just set the div's id, you don't need to add the watch

micha18:12:29

hoplon could presumably do this automatically

micha18:12:27

that undeclared var thing, so annoying

alandipert18:12:11

So if none of the arguments to formula are cells... Why would formula return a cell with a constant attr instead of just not returning a cell?

micha18:12:24

because deref

alandipert18:12:26

I guess it needs to maintain the contract

micha18:12:47

you should still be able to add a watch to it

micha18:12:50

and whatnot

alandipert18:12:07

I guess an atom would work

alandipert18:12:14

But still, backward compatibility

mynomoto18:12:19

Ok, I think I follow. No need to check if barp is a cell and special case it right?

micha18:12:24

oh i found another thing from the beforetimes that i think we can remove

micha18:12:02

i think that was there because we did add-watch on the intput cell before

micha18:12:07

to trigger the propagation

micha18:12:22

then we changed it to be part of the iswap implementation

micha18:12:50

i mean IReset

micha18:12:06

returning an atom though

micha18:12:17

that is an interesting possibility

micha18:12:26

do you think we should do it?

alandipert18:12:07

I don't think the advantage of not needing a new field outweighs importance of returning the same type if we can help it

alandipert18:12:30

Change is very small anyway

micha18:12:50

yeah i guess there isn't much to be gained there

alandipert18:12:18

Also the memory implications are probably the same

alandipert18:12:33

Ie I don't think returning an atom would make it more efficient on any way

flyboarder18:12:49

@micha: what's your thought on splitting the cljs stuff out of boot-hoplon, I realized the ability to create a DSL like the .hl files and what we are putting on top of it with hoplon could be factored apart

micha18:12:58

boot-hoplon is no more, right?

flyboarder18:12:14

I think it could be beneficial to the cljs boot community to be able to make our own DSLs like that

flyboarder18:12:21

Well it's in hoplon now

flyboarder18:12:56

It feels like the boot task is doing 2 things that could be used separate

grant20:12:51

Is there a function that will show, in a repl, the html that will be generated by an element? Or is it better to just throw it up in the browser and inspect it?

flyboarder21:12:10

@grant html is not generated there is no way to do that

flyboarder22:12:58

Elements are created and attached to the DOM at runtime

micha22:12:25

in chrome for instance you can do like this:

micha22:12:11

(.log js/console "%o" (div :id "foop" "hi there"))