Functorise PIPE over EVENTS

We now have
- available: immediately returns data available now
- wait: blocks until n units of data are available

Signed-off-by: David Scott <dave.scott@citrix.com>