As I get more familiar with Gambit, I find it's notion of ports to be really really useful. However, I don't know how to create these structures myself. Can someone point me to some sample code? A really great example would be something like:

(define-type tagged-data tag data)

then, as a piece of data is written to the output port, it's tagged with a (increasing number), and when it's read off the input port, it's a piece of tagged data

so ssuppose I wrote
'a 'b 'c 'd 'e to the port

then when I read from it, I get back

(make-tagged-data 1 'a)
(make-tagged-data 2 'b)
...
(make-tagged-data 5 'e)

The point of this isn't this particular problem, but to understand what abstractions I need to provide when writing my own ports.

Thanks!