Difference between revisions of "Yampa/switch"

From HaskellWiki
Jump to navigation Jump to search
 
Line 8: Line 8:
 
</source>
 
</source>
   
A switch in Yampa provides change of behavior of signal functions (SF) during runtime. The <pre>switch</pre> function is the simplest form which can only be switched once. The signature is read like this: "Be a SF which is always fed a signal of type 'in' and returns a signal of type 'out'. Start with an initial SF of the same type but which may also return a transition event of type 'Event t'. In case of an Event, Yampa feeds the variable 't' to the continuation function 'k' which produces the new SF based on the variable 't', again with the same input and output types."
+
A switch in Yampa provides change of behavior of signal functions (SF) during runtime. The function 'switch' is the simplest form which can only be switched once. The signature is read like this: "Be a SF which is always fed a signal of type 'in' and returns a signal of type 'out'. Start with an initial SF of the same type but which may also return a transition event of type 'Event t'. In case of an Event, Yampa feeds the variable 't' to the continuation function 'k' which produces the new SF based on the variable 't', again with the same input and output types."
   
 
{{Yampa Switches}}
 
{{Yampa Switches}}

Latest revision as of 08:43, 2 July 2011

Yampa switch.png (download original Yampa switch.svg)

switch :: SF in (out, Event t)
       -> (t -> SF in out)
       -> SF in out

A switch in Yampa provides change of behavior of signal functions (SF) during runtime. The function 'switch' is the simplest form which can only be switched once. The signature is read like this: "Be a SF which is always fed a signal of type 'in' and returns a signal of type 'out'. Start with an initial SF of the same type but which may also return a transition event of type 'Event t'. In case of an Event, Yampa feeds the variable 't' to the continuation function 'k' which produces the new SF based on the variable 't', again with the same input and output types."

Yampa switches