Elm doesn't keep track of historical values on its own, but you could use foldp
to build a list of any type of signal like this:
history : Signal a -> Signal (List a)
history =
Signal.foldp (::) []
The most recent signal value is prepended to that list. To see it in action, you could past this full example into http://elm-lang.org/try
import Graphics.Element exposing (show)
import Mouse
main =
Signal.map show <| history Mouse.x
history : Signal a -> Signal (List a)
history =
Signal.foldp (::) []
Running that example may shed light on why historical values aren't kept by default: You can quickly bloat your memory. That being said, elm-reactor
s time-travelling debugger keeps history around, but only for debugging purposes. This isn't something you'd normally want in production.