@@ -4,14 +4,16 @@
44-- it can be used.
55module Automaton where
66
7+import Signal (lift,foldp)
8+
79data Automaton a b = Step (a -> (Automaton a b, b))
810
911-- Run an automaton on a given signal. The automaton steps forward
1012-- whenever the input signal updates.
1113run : Automaton a b -> b -> Signal a -> Signal b
12−run (Step f) base inputs =
14+run auto base inputs =
1315 let step a (Step f, _) = f a
14− in lift snd $ foldp step base inputs
16+ in lift (\(x,y) -> y) <| foldp step (auto,base) inputs
1517
1618-- Step an automaton forward once with a given input.
1719step : a -> Automaton a b -> (Automaton a b, b)