# Module carboxyl::lift
[−]
[src]

Lifting of n-ary functions.

A lift maps a function on values to a function on signals. Given a function of
type `F: Fn(A, B, …) -> R`

and signals of types `Signal<A>, Signal<B>, …`

the
`lift!`

macro creates a `Signal<R>`

, whose content is computed using the
function.

Currently lift is only implemented for functions with up to four arguments. This limitation is due to the current implementation strategy (and maybe limitations of Rust's type system), but it can be increased to arbitrary but finite arity if required.

# Example

let sink_a = Sink::new(); let sink_b = Sink::new(); let product = lift!( |a, b| a * b, &sink_a.stream().hold(0), &sink_b.stream().hold(0) ); assert_eq!(product.sample(), 0); sink_a.send(3); sink_b.send(5); assert_eq!(product.sample(), 15);

## Functions

lift0 |
Lift a 0-ary function. |

lift1 |
Lift a unary function. |

lift2 |
Lift a binary function. |

lift3 |
Lift a ternary function. |

lift4 |
Lift a quarternary function. |