Commit 785107eb authored by Guerric Chupin's avatar Guerric Chupin

Revert Auxiliary.hs

parent e7a5c5bb
......@@ -10,7 +10,7 @@ import FRP.Yampa
stepBack :: SF a (Maybe a)
stepBack = sscan f (Nothing, Nothing) >>^ snd
where f :: (Maybe a, Maybe a) -> a -> (Maybe a, Maybe a)
f (Nothing,_) x' = (Just x', Nothing)
f (Nothing,Nothing) x' = (Just x', Nothing)
f (Just x, _) x' = (Just x', Just x)
-- Just like stepBack but the output value is always defined and is
......@@ -25,6 +25,10 @@ stepBack' = proc x -> do
onChange :: (Eq a) => SF a (Event a)
onChange = proc x -> do
x' <- stepBack -< x
let makeEvent x x'
| isNothing x' = NoEvent
| isJust x' = let x'' = fromJust x' in
if x'' == x then NoEvent else Event x
returnA -< makeEvent x x'
-- Similar to onChange but contains its initial value in the first
......@@ -32,14 +36,13 @@ onChange = proc x -> do
onChange' :: (Eq a) => SF a (Event a)
onChange' = proc x -> do
x' <- stepBack -< x
-- If it's the first value, throw an Event, else behave like onChange.
let makeEvent x x'
| isNothing x' = Event x
| isJust x' = let x'' = fromJust x' in
if x'' == x then NoEvent else Event x
returnA -< makeEvent x x'
makeEvent :: (Eq a) => a -> Maybe a -> Event a
makeEvent x x'
| isNothing x' = Event x
| otherwise = let x'' = fromJust x' in
if x'' == x then NoEvent else Event x
discard :: a -> ()
discard _ = ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment