Proposal: unifying modules, records and code blocks #1012
Replies: 11 comments 2 replies
-
@berekuk I am agreeing to changes for inner blocks. Inner blocks can export the variables as records However, I won't change the implementation for files.
|
Beta Was this translation helpful? Give feedback.
-
Back to your answers
Performance loss. I have started to use Squiggle in the implementation of Squiggle. And it will go more and more in that direction. That magnifies the performance loss. Sometimes, it is more straightforward to just use the language instead of dealing with complicated corresponding APIs. Debugging. You're right just bindings are not enough. Ozzie already asked me: It would be nice if we could debug the bindings of local blocks. Like you say much more is needed for debugging: lambdas, local variables of inner blocks...
The whole essay above.
The whole essay above. |
Beta Was this translation helpful? Give feedback.
-
Now, all your import ideas are OKAnd I don't see any conflict about them and they are achievable. {Except hacking records to hide private variables} What I see wrong is that "We could do that in a minute because there is no need for bindings". Hacking for immediate results part. In fact, I am putting them into my job queue immediately. We will do that kind of import and we wont unify bindings and results |
Beta Was this translation helpful? Give feedback.
-
I assume In this case, the author of the code is either confused about some fundamentals of how Squiggle works, or they really intended to return that result. But also...
You could put
Let's ask Sam? I haven't heard from him on this proposal yet, it'd be interesting to see if he'd be opposed to it, and why.
I hope not. I won't comment on code examples below this point because I don't like the variation with
Again, let's see what Sam and Quinn are going to say, then? Maybe I'll manage to convince them that end expression (with implicit generated record if it's missing) is enough. At least I'm hopeful. |
Beta Was this translation helpful? Give feedback.
-
End expression (with implicit generated record if it's missing): If it is missing then we have to put the result into the bindings! That is the problem. Bindings are needed even if the expression is there or is missing. There is no case only the final expression is OK (for UI). |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Another note is that we often don't want to trigger the record viewer on bindings. This is because the number of declared variables at the top level scope could be large, and have already been displayed in different cells, and possibly even different notebooks! It can also include math and utility functions that just pollutes the result that you want to show (which is often just nothing for a collection of bindings). For instance, Squiggle already has this feature. Check this out! This is my GiveDirectly analysis: |
Beta Was this translation helpful? Give feedback.
-
Some notes: @berekuk @Hazelfire ReducerProject has 2 API functions: getResult, getBindings instead of getResultAndBindingsTuple The technical reason is that if you won't display the bindings yet or if you don't need them then you are not triggering any conversion process or memory consumption. So I got away from the idea of delivering the result and bindings bundled together. And this way bindings are always there whether there is a result or not. There are no partials anymore to construct bindings if there is no result. If one wishes a tuple then it is simply (getResult, getBindings)... Also sometime next week, each file will start to have its own local bindings. Standard library or bindings of depended files will not propagate In fact, when Sam @Hazelfire wanted bindings to be always there I simply could not do it. Because solving that problems was requiring the use of a state monad that seemed to mess the code too much as there is no mention of monads in Rescript like in Haskell. Of course I had to solve the monad problem for other purposes like collecting performance statistics. I was having the nightmare of changing the result of every function to pass the state around. Then I found a workaround that does not mess or change the code. The new version of Reducer in ReducerProject is equipped with a State monad to collect bindings, performance statistics, function result caching, and other kinds of debug data in the future. Bindings are there in the state monad even before the result is calculated after 2 months of planning and plotting. |
Beta Was this translation helpful? Give feedback.
-
@Hazelfire, thanks so much! This clarifies a lot. I have some new ideas now about how to maybe get the best of both worlds, but it might take me some time to figure out and communicate properly. I'll focus on fixing lambda viewers in ReducerProject for today and come back to this thread later. |
Beta Was this translation helpful? Give feedback.
-
This proposal still has its problems and it seems like we'll have to release imports without doing this, but just a quick note...
The new 0.5 interpreter doesn't have this problem anymore. Imported bindings are stored in a separate layer (scope) from the local bindings, and we could render just the locals. |
Beta Was this translation helpful? Give feedback.
-
(We have since made progress here, closing) |
Beta Was this translation helpful? Give feedback.
-
Resharing from discussion in Slack: https://docs.google.com/document/d/1QK-y35KRWpZSiGvfZY0QB-cfqYg0WbaWA2e8xoSf0-8/edit
Summary
(examples and rationale are explained in the linked document)
Beta Was this translation helpful? Give feedback.
All reactions