On this page:

1 Data Hose Types

A Tank is an accumulator. It is fed datum values one at a time until receiving the 'EOS datum value or the Tank itself determines it is done at which point the accumulated value is drained from the Tank and returned.

 (require pipe/types) package: pipe


Stream : (U D 'Nothing 'EOS)

A Stream is a parameterized type of D datum or the symbols 'Nothing or 'EOS

So for example, a (Stream String). 'EOS denotes an end of stream marker. 'Nothing is a no-op step, and may be viewed as a ’null’ datum value. The envisioned utility of supporting a no-op step is primarily in asynch IO Tanks.


Tank : (U (Done D A) (Continue D A))


(struct Done (stream accum))

  stream : (Stream D)
  accum : A
The Done structure is the return or completion value of an Tank. Generally an Tank completes when an 'EOS marker is feed to the Tank from somewhere upstream.


(struct Continue (step))

  step : ((Stream D) -> (Tank D A))
The Continue structure holds the Tank’s continuation or callback procedure. To feed the next datum from the stream into the tank the callback step procedure is invoked with the datum.


(drain tank)  A

  tank : (Tank D A)
Extract the accumulated valued from a Tank. If the Tank is 'Done return the accumulated value. If the Tank is ready to 'Continue, then drain feeds a 'EOS, which moves the Tank to a 'Done state and then extracts the accumulated value.