on master help sign in
Removed operators, renamed some functions, as advised by Evan.
9823941Jeff Smits
libraries/Automaton.elm+8−20
@@ -84,38 +84,26 @@ hiddenState base fun = loop base (pure (\(i,s) ->
84 let (o,s') = fun i s
84 let (o,s') = fun i s
85 in (s',o)))
85 in (s',o)))
86
86
87−(>>>) : Automaton i inter -> Automaton inter o -> Automaton i o
88−(>>>) = before
89−
90after : Automaton inter o -> Automaton i inter -> Automaton i o
87after : Automaton inter o -> Automaton i inter -> Automaton i o
91after g f = f `before` g
88after g f = f `before` g
92
89
93−(<<<) : Automaton inter o -> Automaton i inter -> Automaton i o
94−(<<<) = after
95−
96-- AFRP name: second
90-- AFRP name: second
97extendUp: Automaton i o -> Automaton (extra,i) (extra,o)
91extendUp: Automaton i o -> Automaton (extra,i) (extra,o)
98extendUp auto =
92extendUp auto =
99 let swap (a, b) = (b, a)
93 let swap (a, b) = (b, a)
100− in pure swap >>> extendDown auto >>> pure swap
94+ in pure swap `before` extendDown auto `before` pure swap
101
95
102-- (parallel composition)
96-- (parallel composition)
103−stack: Automaton i1 o1 -> Automaton i2 o2 -> Automaton (i1,i2) (o1,o2)
97+pair: Automaton i1 o1 -> Automaton i2 o2 -> Automaton (i1,i2) (o1,o2)
104−stack f g = extendDown f >>> extendUp g
98+pair f g = extendDown f `before` extendUp g
105
99
106−(***): Automaton i1 o1 -> Automaton i2 o2 -> Automaton (i1,i2) (o1,o2)
107−(***) = stack
108−
109−and : Automaton i o1 -> Automaton i o2 -> Automaton i (o1,o2)
100+branch : Automaton i o1 -> Automaton i o2 -> Automaton i (o1,o2)
110−and f g =
101+branch f g =
111 let double = pure (\i -> (i,i))
102 let double = pure (\i -> (i,i))
112− in double >>> stack f g
103+ in double `before` pair f g
113−
114−(&&&) : Automaton i o1 -> Automaton i o2 -> Automaton i (o1,o2)
115−(&&&) = and
116
104
117combi: Automaton i o -> Automaton i [o] -> Automaton i [o]
105combi: Automaton i o -> Automaton i [o] -> Automaton i [o]
118−combi a1 a2 = (a1 &&& a2) >>> pure (uncurry (::))
106+combi a1 a2 = (a1 `branch` a2) `before` pure (uncurry (::))
119
107
120-- Combine a list of automatons into a single automaton that produces a list.
108-- Combine a list of automatons into a single automaton that produces a list.
121combine : [Automaton i o] -> Automaton i [o]
109combine : [Automaton i o] -> Automaton i [o]
@@ -123,7 +111,7 @@ combine autos =
123 let l = length autos
111 let l = length autos
124 in if l == 0
112 in if l == 0
125 then pure (\_ -> [])
113 then pure (\_ -> [])
126− else foldr combi (last autos >>> pure (\a -> [a])) (take (l-1) autos)
114+ else foldr combi (last autos `before` pure (\a -> [a])) (take (l-1) autos)
127
115
128
116
129-- Examples of automata
117-- Examples of automata