Fork me on GitHub
#hoplon
<
2017-09-08
>
wistb00:09:06

hi. Just started with hoplon getting started

wistb00:09:18

seeing this when I ran boot dev

wistb00:09:19

tarting file watcher (CTRL-C to quit)... Retrieving clojure-1.3.0-alpha6.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-alpha7.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-alpha8.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-beta2.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-beta3.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.3.0-RC0.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha1.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha2.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha3.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha4.pom from https://repo1.maven.org/maven2/ (5k) Retrieving clojure-1.4.0-alpha5.pom from https://repo1.maven.org/maven2/ (5

wistb00:09:55

is this normal ?

bocaj01:09:20

What does your dependency list look like?

alandipert02:09:24

wistb that's a little unusual but doesn't necessarily indicate a problem, notice how it's downloading just .poms.

dm313:09:45

is there a nice solution to having a cell act as a reference in one forumla and as a cell in another?

dm313:09:10

For example, let’s say I have

(defc indicator 1)
(defc= bad? (> indicator 5))

(defc= alert (when bad? (println "BAD: " indicator)))
I’d only like to trigger the alert when bad? changes state, but I’d also like to take the current value of the indicator

dm313:09:24

it’s easy to do by making another ref (e.g. atom) indicator* which watches and changes together with the indicator

dm313:09:46

but that’s boilerplate, right? 🙂

dm313:09:41

may be interesting to have a concept of an “active” vs “passive” source cell

dm313:09:38

or simply getting a read-only ref view of a cell, something like

(defc= alert (when bad? (println "BAD: " (->ref indicator))))

dm313:09:21

obviously the above won’t work without hoisting macro support

alandipert13:09:58

i think the closest thing is do-watch

alandipert13:09:16

i can imagine a cell= variant that takes a do-watch function, kind of like the way refs already take validation fns

dm313:09:59

don’t follow the last approach

dm313:09:16

cell= takes an optional update function

alandipert17:09:22

oh, by cell= i mean, a macro/function you create and name for yourself :-)

alandipert17:09:27

didn't mean overload cell= more

flyboarder18:09:33

@dm3 usually I just use and within my cells

flyboarder18:09:00

Which solves the "trigger by watching other cell"

dm319:09:32

@flyboarder not sure how that helps

flyboarder19:09:43

@dm3 maybe i dont understand the question, what is the problem with your example?

flyboarder19:09:44

you could be using an anonymous cell instead

dm319:09:48

I only want alert triggered off bad? cell but also contain the latest value of indicator

flyboarder19:09:18

does this not work for you:

flyboarder19:09:48

(cell= (when bad? (println "BAD: " indicator)))

dm319:09:17

no, because this will trigger every time indicator changes if bad? is true

flyboarder19:09:44

ah so you want a debounce cell

flyboarder19:09:10

one that only triggers once or so but when your conditions have changed

flyboarder19:09:27

i think we wrote that somewhere previously

dm319:09:45

I really want a concept of a passive cell

dm319:09:56

which doesn’t trigger formulas

dm319:09:55

which makes sense to be determined at the use-site

dm319:09:26

as per my example - the indicator cell is active when determining the value of bad? but passive when used inside the alert

flyboarder19:09:33

so you dont want indicator to change once bad? is true?

dm319:09:15

yes, when used inside the alert formula

dm319:09:09

I want the latest value, but I don’t want indicator to trigger the change

dm319:09:50

another possible name - mute

dm319:09:07

(defc= alert (when bad? (println "BAD: " (muted indicator))))

flyboarder19:09:36

I’m following now, I dont think this is currently possible due to how the formula is walked

dm319:09:52

I know 🙂

dm319:09:10

hence thinking whether it makes sense to introduce a new concept

flyboarder19:09:18

can I ask what the issue is with the indicator triggering the formula?

dm319:09:53

I want it to trigger only on state change, but report the latest value

dm320:09:10

the use case might be rare enough to be solved without introducing additional concepts to Javelin

flyboarder20:09:54

@dm3 can the indicator continue to change once the alert function is called?

flyboarder20:09:06

is that why you only want one value?

flyboarder20:09:14

personally I use your example all the time

dm320:09:07

sure, it’s constantly changing

dm320:09:21

but I only want alert when bad? changes

dm320:09:50

alert is a formula cell

alandipert20:09:59

(def alert ((formula #(when % (println "BAD: " @indicator))) bad?)) just came to mind

alandipert20:09:21

i guess formula-of cleans that up a tad

dm320:09:05

yeah, the only issue is with the macro where you have to introduce something to affect hoisting

dm320:09:12

I guess I can live without that

alandipert20:09:31

maybe ~ in cell= can achieve it somehow?

alandipert20:09:51

i've forgotten again how that works

dm320:09:03

that will embed the value

dm320:09:20

actually not, sorry 🙂

dm320:09:42

if you just say ~cell it won’t do anythin

alandipert20:09:11

so ~@indicator is what you want?

dm320:09:36

no, that would bring the dereffed value into the formula

dm320:09:11

more like ~(->ref indicator)

dm320:09:40

where ->ref creates an atom with a watch on the indicator

dm320:09:08

then actually @~(->ref indicator)

dm320:09:10

this works:

(defn ->ref [c] (let [a (atom @c)] (add-watch c (gensym) (fn [_ _ _ n] (reset! a n))) a))
(defc indicator 1)
(defc= bad? (> indicator 5))
(defc= alert (when bad? (println "BAD" @~(->ref indicator))))

dm320:09:57

thx for the help

alandipert20:09:37

are you sure you need the intermediate atom?

alandipert20:09:52

i wonder about (defn ->ref [c] (deref c))

dm320:09:16

the quoted thing will become an argument to the formula

alandipert20:09:23

and then (->ref ~indicator)

dm320:09:41

won’t help as formula looks for arguments which are cells

dm320:09:54

so it must not be a cell in order to be muted

dm320:09:40

it either needs to be 1) embedded within the formula with @indicator 2) passed in a way where it’s not recognized by cell? predicate

alandipert20:09:06

maybe cell= could understand some meta on symbols

alandipert20:09:25

so you could do like (cell= {:x x :y ^passive y})

alandipert20:09:39

i'm kind of into it because then it becomes the inverse of formula-of hehe

alandipert20:09:41

formula-of-not

alandipert20:09:10

...formula-except

dm320:09:15

yeah, formula-NOT makes sense 🙂

alandipert20:09:54

hm, i need to update the templates i think