type Action = NextFrame Time | Resize Vectorresizes : Signal Actionresizes = Signal.map (\(x,y) -> Resize { x = toFloat x, y = toFloat y }) Window.dimensionsappStartMailbox : Mailbox ()appStartMailbox = Signal.mailbox ()port appStart : Signal (Task error ())port appStart = Signal.constant (Signal.send appStartMailbox.address ())firstResize : Signal ActionfirstResize = Signal.sampleOn appStartMailbox.signal resizesactions : Signal Actionactions = Signal.mergeMany [ firstResize , nextframes , resizes ]main = Signal.map view (Signal.foldp update initial actions)--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/h-WAC3kgrOU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For reference, here is a version of your minimal example using foldp' as suggested earlier:
import Window
import Graphics.Element as Element
import Signal
import Signal.Extra
main = Signal.map Element.show model
model = Signal.Extra.foldp' (\d s -> {s | window <- d}) (\d -> { window = d }) Window.dimensions
Don’t you agree that this is a magnitude simpler than the Task-based approach? I would also consider it more idiomatic. And no “further prompting” is necessary (if I understand correctly what you meant by that).
Note that the above will not work on share-elm, but that’s just because it relies on http://package.elm-lang.org/packages/Apanatshka/elm-signal-extra/5.3.0, which is not installed there.
--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
Ah, cool. I thought that by “prompting” you meant some signally concept, like forcing an additional event or so. :-)
@Evan, maybe an example like this (which is representative of other questions in the past), and the difference between a foldp' solution vs. the temptation to reach for Tasks in such a situation, could motivate adding foldp' to core, or at least to https://github.com/elm-lang/core/issues/322 ?
I guess this would require StartApp using foldp' instead of foldp. So, a feature request there?
Due to this line and this line, your update a config.init tries to pattern-match a Nothing (coming from messages.signal) against a Just action (in the first argument position of update). An immediate solution would be to replace messages.signal :: List.map (Signal.map Just) config.inputs by List.map (Signal.map Just) config.inputs ++ [messages.signal] in the first of those places mentioned above.
However, that’s not to say that should necessarily be how StartApp works in general. For example, if config.inputs has several signals, you will only take the initial value of the first of them into account (which in your case is okay, since there is only one signal in inputs).
So, there are design considerations here that should be made for StartApp: Should the package support model initialisation based on the initial value(s) of input signals? If so, how exactly? Maybe bring those up as issues in the StartApp repository.