@@ -4,14 +4,16 @@
4-- it can be used.
4-- it can be used.
5module Automaton where
5module Automaton where
7+import Signal (lift,foldp)
7data Automaton a b = Step (a -> (Automaton a b, b))
9data Automaton a b = Step (a -> (Automaton a b, b))
9-- Run an automaton on a given signal. The automaton steps forward
11-- Run an automaton on a given signal. The automaton steps forward
10-- whenever the input signal updates.
12-- whenever the input signal updates.
11run : Automaton a b -> b -> Signal a -> Signal b
13run : Automaton a b -> b -> Signal a -> Signal b
12−run (Step f) base inputs =
14+run auto base inputs =
13 let step a (Step f, _) = f a
15 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
16-- Step an automaton forward once with a given input.
18-- Step an automaton forward once with a given input.
17step : a -> Automaton a b -> (Automaton a b, b)
19step : a -> Automaton a b -> (Automaton a b, b)