@@ -9,41 +9,63 @@ data Automaton a b = Automaton (a -> (b, Automaton a b))
9run :: Automaton a b -> Signal a -> Signal b
9run :: Automaton a b -> Signal a -> Signal b
10run :: OrderedContainer c => Automaton a b -> c a -> c b
10run :: OrderedContainer c => Automaton a b -> c a -> c b
12−compose :: Automaton a b -> Automaton b c -> Automaton a c
12+(>>>) :: Automaton a b -> Automaton b c -> Automaton a c
13+(<<<) :: Automaton b c -> Automaton a b -> Automaton a c
14combine :: [Automaton a b] -> Automaton a [b]
15combine :: [Automaton a b] -> Automaton a [b]
15combine :: Container c => c (Automaton a b) -> Automaton a (c b)
16combine :: Container c => c (Automaton a b) -> Automaton a (c b)
18−pure :: (a -> b) -> Automaton a b
19+pure :: (a -> b) -> Automaton a b
19init :: b -> (a -> b -> b) -> Automaton a b
20init :: b -> (a -> b -> b) -> Automaton a b
20init' :: s -> (a -> s -> (b,s)) -> Automaton a b
21init' :: s -> (a -> s -> (b,s)) -> Automaton a b
22count :: Automaton a Int
23count :: Automaton a Int
24draggable :: Form -> Automaton (Bool,(Int,Int)) Form
25draggable :: Form -> Automaton (Bool,(Int,Int)) Form
25−foo :: (a -> b) -> Automaton b c -> Automaton a c
27+(^>>) :: (a -> b) -> Automaton b c -> Automaton a c
26−bar :: Automaton a b -> (b -> c) -> Automaton a c
28+(>>^) :: Automaton a b -> (b -> c) -> Automaton a c
30+(^<<) :: (b -> c) -> Automaton a b -> Automaton a c
31+(<<^) :: Automaton b c -> (a -> b) -> Automaton a c
31run (Automaton m0) input =
36run (Automaton m0) input =
32− lift fst $ foldp1 (\a (b, Automaton m) -> m a) m0 input
37+ lift fst $ foldp' (\a (b, Automaton m) -> m a) m0 input
34−compose (Automaton m1) (Automaton m2) =
40+ let { Automaton m1 = a1 ; Automaton m2 = a2 } in
35− Automaton
41+ Automaton
36 (\a -> let (b,m1') = m1 a in
42 (\a -> let (b,m1') = m1 a in
37− let (c,m2') = m2 b in (c, compose (Automaton m1') (Automaton m2')))
43+ let (c,m2') = m2 b in (c, Automaton m1' >>> Automaton m2'))
46+f ^>> a = pure f >>> a
47+a >>^ f = a >>> pure f
48+f ^<< a = a >>> pure f
49+a <<^ f = pure f >>> a
39combine autos =
51combine autos =
40− Automaton (\a -> let (bs,autos') = unzip $ map (\m -> m a) autos in
52+ Automaton (\a -> let (bs,autos') = unzip $ map (\m -> m a) autos in
41− (bs, combine autos'))
53+ (bs, combine autos'))
55+pure f = Automaton (\x -> (f x, pure f))
56+init s step = Automaton (\a -> let s' = step a s in (s', init s' step))
57+init' s step = Automaton (\a -> let (b,s') = step a s in (b , init s' step))
59+count = init 0 (\_ c -> c + 1)
63+{--- See the following papers for ideas on how to make this faster:
43−init s step =
65+- Functional Reactive Programming, Continued
44− Automaton (\a -> let s' = step a s in (s', init s' step))
66+- Causal commutative arrows and their optimization
46−init' s step =
68+Speeding things up is a really low priority. Language features and
47− Automaton (\a -> let (b,s') = step a s in (b, init s' step))
69+libraries with nice APIs and are way more important!
49−count = init 0 (\_ c -> c + 1)
71+--}