Fork me on GitHub
#hyperfiddle
<
2022-12-12
>
Dustin Getz13:12:36

This is a fun r/haskell thread from moi, might as well build in public here https://www.reddit.com/r/haskell/comments/ziyj87/are_electrical_circuits_free_applicatives/

🤓 2
Ben Sless18:12:21

Only as long as you don't model time

Ben Sless18:12:25

But since you're dealing with partially ordered signals, have you looked at timely dataflow and differential datalog?

xificurC18:12:43

feed us with your links

Ben Sless18:12:39

Ping me in about 30 minutes if I forget? But these are the terms you'd find in papers, first result in google

Ben Sless19:12:36

This will lead you to the relevant papers, too, some are in the repos

Ben Sless19:12:46

While this deals with datalog, it covers the problem of modeling closed circuit calculations

Ben Sless19:12:37

It's been a while since I read the papers but I can give you a qrd

xificurC19:12:42

thanks! From a quick glance these seem to support discrete computations balanced across a cluster of workers

Ben Sless19:12:45

That too, but only given the following constraints: partitioning and/or partial ordering, sort of like merge sort

Dustin Getz19:12:30

i will look again at mcsherry, thanks

Ben Sless20:12:00

How much of Clojure does Photon support?

Dustin Getz20:12:20

hand waving over todos

Dustin Getz20:12:41

there are some super interesting edge cases

Ben Sless20:12:16

Asking because I'm theorizing the overhead of implementing all the basic operators as differentiable signals

👀 1
xificurC20:12:40

case op
    (ns ns* deftype* defrecord* var)
    (throw (ex-info "Unsupported operation." {:op op :args args}))

Dustin Getz20:12:02

I am specifically looking to understand a pure continuous time model, i think a system can be modeled in CT all the way up until you introduce transactions at which point you have db = App(db) (a discrete iteration) or alternately db = Σ [t=0..T] App(t)Δt (app is a reactive function that returns transaction directives over time, a log)

Ben Sless20:12:49

Continuous time is hard, I'd just do discrete time

Ben Sless20:12:01

In continuous time you can have no partial ordering

Ben Sless20:12:18

And good luck modelling / solving feedback loops

Dustin Getz20:12:28

that's where we're at right now

Dustin Getz20:12:43

we already have the discrete version, it works fine

Ben Sless20:12:19

With feedback loops, too?

Dustin Getz20:12:21

yeah we cycle by reactive assignment, Leo did the initial work here

(defmacro with-cycle [[s i] & body]
  `(let [a# (atom ~i) ~s (p/watch a#)]
     (reset! a# (do ~@body))))

Dustin Getz20:12:37

that's well defined in missionary master (it may always have been, i dont recall)

Dustin Getz20:12:50

this runs, it's a datomic backed webform and models transactions as a closed loop over client/server; it has load states, queries, edits, everything

Ben Sless20:12:13

I don't know if the entire system could be modeled in continuous time because the communication between client and server is definitely discrete, but a local context could perhaps be reasoned about in continuous domain

Dustin Getz20:12:37

Leo solved that, the network runtime is discrete but the userland model (photon functions) is signals

Dustin Getz20:12:23

our reactive p/fns ("photon signal functions") can be thought of as including a reader/writer monad for network events (I think that's a fair summary), obviously the internals are discrete

Dustin Getz20:12:42

the network stuff is entirely abstracted, it doesn't leak to userland at all except at the entrypoint

Ben Sless20:12:47

I think I'm out of my depth here because I'm not really familiar with photon

Dustin Getz20:12:38

"differentiable signals" your definition of this is mcsherry?

Ben Sless20:12:37

From learning Signal Processing and lots of related material in uni

Ben Sless20:12:14

in discrete time it maps to modelling every function with deltas, for example (merge A+da B+db) = (merge A B + merge da B + merge A db + merge da db)

Ben Sless20:12:46

Then the differential is just the difference

Dustin Getz20:12:07

got it, i think what we have in the gist above is that

Dustin Getz20:12:16

db = Σ [t=0..T] App(t)Δt App(t) is the App fn, it basically returns datomic txn values in response to user interaction. i took some liberties with control flow to get good syntax

Dustin Getz20:12:23

maybe you mean something different, i'm not sure

Dustin Getz20:12:48

(datomic txn values are literal database deltas)

Ben Sless20:12:41

Yeah, I meant it for all data, not just the db, but maybe you don't need that I should go sleep, I'll be more coherent tomorrow

🙂 1
Dustin Getz20:12:29

the datomic types are probably making it hard to reason about for us both, if the "database" was just a shared global counter and "deltas" were just [1 1 1 1 1] i think it would be more clear

Dustin Getz20:12:24

the dom syntax is macros also, the macros emit simple effects like dom/appendChild dom/setText dom/removeChild (supervised by missionary of course for lifecycle guarantees) - that might count as programming with derivatives

Dustin Getz20:12:38

another problem is that photon has full clojure interop, so even if photon DAGs/circuits could be like symbolically differentiable (?) in the equational sense, and maybe they are?, the clojure/java/js interop is not

Ben Sless18:12:25

But since you're dealing with partially ordered signals, have you looked at timely dataflow and differential datalog?