-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why not InputWidget{T} <: Signal{T}? #1
Comments
Ah. Right now, it's actually possible to create a signal of |
Detecting cycles in the graph and throwing an exception should be pretty easy. Since most |
Why not just have |
But the question is: If you made One thing we could do is have an In this case, we can have s = Slider(....)
lift(x -> RGB(x,x,x), s) having the rank check in |
I don't understand the difference between having an |
My thinking is that the s1 = Slider("x1", 0.0, 0.0, 1.0, 0.0001, Input(0.0))
input2 = Input(0.0) # Let's say I want to constrain this value to be <= s1^2
s2 = lift(x -> Slider("x2", min(input2.value, x*x), 0.0, x*x, 0.0001, input2), s1.input) If s1 = Slider("x", 0.0, 0.0, 1.0, 0.001)
s2 = lift(x->Slider("x2", min(x*x, s2.value), 0.0, x*x, 0.001), s1)
# The type of s2 ends up being Signal{Signal},
# s2.value is not defined in the beginning so this would crash Elm has had a few iterations on how it deals with Input elements. My design above is roughly what they have settled for. I hope I was clear. In general, I think it pays to separate the concept of a widget from that of an input node in the signal graph. The InputWidget is the view, and the Input field is the model it updates. There can be any logic that updates the view. |
I don't see the problem with |
Also, how do you initialize the value to the initial slider value though? I could't figure it out. @one-more-minute What do you think about this? |
It would definitely make sense to be able to implicitly treat things like I think the way to do this would be to have a function which returns the concrete signal(x::Input) = x
signal(x::InputWidget) = x.input
# then
lift(f :: Function, output_type :: Type, inputs...) =
Lift{output_type}(f, map(signal, inputs)...) That would be a really easy way to get the nicer interface:
which is very close to what we ultimately want to have. If you wanted to be even more general you could dispense with the |
I still feel that there is something fundamentally broken and confusing about an abstraction in which an (By the way, here is yet another global dictionary that should really be a type field. If you call that field As for creating inputs that affect widgets, a One option, if you have an |
There is no more an x=Slider(0:0.01:1)
@lift RGB(x,x,x) works! |
Sounds good! |
I don't see why it you have a separation between
InputWidget
andInput
, i.e. you create a widget and thenattach!
an input to it.Why not simply make the
InputWidget
a type ofSignal
? Then I could simply do e.g.The text was updated successfully, but these errors were encountered: