juxt

martinklepsch 2018-12-13T17:54:57.005400Z

aero question incoming: I have a custom reader that reads a file if a certain profile is used. Now that file is usually not present and only supplied in production environments:

:cljdoc/version #profile {:prod #slurp "CLJDOC_VERSION"
                           :default "dev"}
I think because everything is implemented using reader tags the file is being read regardless of what profile is being used, causing an exception in non-production environments. Does anyone have advice around dealing with this situation?

martinklepsch 2018-12-13T18:05:21.005800Z

of course Deferred is the answer: https://github.com/juxt/aero#deferreds

dominicm 2018-12-13T19:45:09.006500Z

I have something that makes aero lazy

dominicm 2018-12-13T19:45:18.006900Z

Deferreds aren't always perfect.

mccraigmccraig 2018-12-14T11:15:24.011100Z

what deficiencies are you thinking of ? i use Deferreds for just about everything on the backend which isn't a pure fn...

dominicm 2018-12-14T11:40:41.011300Z

#join[#state 1, #state 2]

dominicm 2018-12-14T11:40:50.011500Z

That will 💥

mccraigmccraig 2018-12-14T11:43:24.011700Z

what op is #join @dominicm?

dominicm 2018-12-14T11:43:56.011900Z

Same as (str #state 1, #state 2)

mccraigmccraig 2018-12-14T11:45:33.012100Z

dyu mean where #state 1 and #state 2 are Deferred ?

dominicm 2018-12-14T14:24:22.012300Z

Yeah

mccraigmccraig 2018-12-14T14:53:06.012500Z

so you see exceptions when you stringify two Deferreds ? that's weird, i've never seen anything like that

mccraigmccraig 2018-12-14T14:53:39.012700Z

although i suppose it would be rare for me to stringify more than one Deferred without having combined them first

dominicm 2018-12-14T21:31:32.016300Z

You can't really do anything with a deferred if your result is non-walkable

mccraigmccraig 2018-12-14T22:29:08.016500Z

what do you mean by non-walkable @dominicm ? we commonly have opaque objects in deferreds, so presumably you mean something else ?

dominicm 2018-12-14T22:32:19.016700Z

I'm thinking the other way round, a string isn't walkable. Anything that creates an opaque object, cannot take a deferred as a return value.

mccraigmccraig 2018-12-14T22:51:22.016900Z

do you have some example code ? i return Deferred<String> all the time without any trouble, so i think i'm misunderstanding something

dominicm 2018-12-15T06:47:42.019900Z

Implement #state as something that returns deferred<string>

dominicm 2018-12-15T06:53:06.020100Z

❯ replme aero           
[Rebel readline] Type :repl/help for online help info
user=&gt; (require '[aero.core :as aero])
nil
user=&gt; (defmethod aero/reader 'state
  #_=&gt;   [_ _ value]
  #_=&gt;   (aero/deferred value))
#object[clojure.lang.MultiFn 0x474c9131 "clojure.lang.MultiFn@474c9131"]
user=&gt; (aero/read-config (java.io.StringReader. "#join [#state 1 #state 2]"))
"aero.core.Deferred@c23667ddaero.core.Deferred@ec3736c9"
That's not what you wanted as a result! 😄

dominicm 2018-12-15T06:53:44.020400Z

Same thing was true for #ref, but I made it specialer

dominicm 2018-12-15T06:59:24.020700Z

The problem is that deferred is really a patch over the eagerness of aero. What you need is a lazy resolution mechanism. I based my solution around macros & functions. Macros (e.g. #profile) can lazily operate on what they're given. Functions have everything they're given pre-resolved. This should remove any need for deferred.

mccraigmccraig 2018-12-15T08:37:21.020900Z

oh, wow, now i understand - :rolling_on_the_floor_laughing: - you are talking about aero.core.Deferred and i am talking about manifold.deferred.IDeferred !

mccraigmccraig 2018-12-15T08:39:33.021100Z

which, looking at the conversation history, is entirely my fault - looks like i dyslexed into the Deferred i was familiar with 😊

mccraigmccraig 2018-12-15T09:42:02.021300Z

so now i understand what you are talking about, i think it's quite similar to a problem i had with our own app-context factory - in cljs i had factory fns which returned a promise of something, say a file-area, and i wanted other components to depend on that file-area

mccraigmccraig 2018-12-15T09:43:32.021500Z

in order to do this i made the app-context factory return a Promise<app-context> - and once everything is Promise based it's fine to compose promises

dominicm 2018-12-15T10:18:39.021700Z

Yep. But the root of the problem is deeper.

dominicm 2018-12-13T19:45:38.007600Z

It's a major rewrite though, and it's living in a hacked up alternative branch

dominicm 2018-12-13T19:45:45.008Z

But the tests pass 😁

martinklepsch 2018-12-13T21:09:04.008800Z

https://github.com/ztellman/aleph/issues/441 since yada is based on aleph (IIRC) this might be interesting for juxt folks... cc @dominicm et al

dominicm 2018-12-13T21:09:29.009300Z

@malcolmsparks more so 😊

martinklepsch 2018-12-13T21:11:38.010100Z

Yeah, pinged you because I wasn't sure how often Malcolm is around here 🙂

dominicm 2018-12-13T21:12:33.010300Z

He lurks

dominicm 2018-12-13T21:12:46.010800Z

I just answer quicker because I'm addicted to my phone