@@ -32,7 +32,7 @@ the [`Time`](/docs/Signal/Time.elm) library.
3232import Native.Signal
3333import List (foldr)
3434
35−import Basics (otherwise, not)
35+import Basics (fst, snd, not)
3636import Native.Error
3737import Maybe as M
3838
@@ -127,17 +127,7 @@ does not allow undefined signals, so a base case must be provided in case the
127127first signal is not true initially. -}
128128keepWhen : Signal Bool -> a -> Signal a -> Signal a
129129keepWhen bs def sig =
130− let toMaybe : Bool -> a -> M.Maybe a
131− toMaybe b x = if b
132− then M.Just x
133− else M.Nothing
134−
135− fromJust : M.Maybe a -> a
136− fromJust m = case m of
137− M.Just x -> x
138− M.Nothing -> Native.Error.raise "Internal bug in keepWhen! Please report at https://github.com/evancz/Elm/issues?state=open"
139− in
140− fromJust <~ (keepIf M.isJust (M.Just def) (toMaybe <~ (sampleOn sig bs) ~ sig))
130+ snd <~ (keepIf fst (False, def) ((,) <~ (sampleOn sig bs) ~ sig))
141131
142132{-| Drop events when the first signal is true. When the first signal becomes
143133false, the most recent value of the second signal will be propagated. Until the