
I wonder if this would be a place to add a function returning the pair of the read and write capabilities (for the lack of a better word) of a value.
something like:
rwPair:: v α -> (ReadOnly v α , WriteOnly v α) rwPair a = (readOnly a, writeOnly a)
sorry for the lame name, but my name game is off today.
This particular function comes handy when playing with passing channels or pointers around. It might be worth it to have a dedicated type for that as well.
What would this dedicated type look like?
Something along the lines of * a type alias: type ReadWrite v α = (ReadOnly v α , WriteOnly v α) * or a data type: data ReadWrite v α = ReadWrite {reader:: ReadOnly v α, writer:: WriteOnly v α } The intent is to be able to recognise the available capabilities. Then we could write a Link type, which is the sum of all four possibilities and allowing pattern matching on capabilities. This is similar to links in pi-calculus. I'm not sure if a link type should be in your library though. My gut feeling is it should be in a separate library, which implements a trusted kernel, which guarantees linearity - i.e ReadOnly and WriteOnly to be used only once - either shallow, guaranteeing that the projection can be taken only once, or deep providing guarantees for 'proper' linearity. Sorry, I digress, that is a pet subject I've been playing with on and off.
BTW thanks for pointing me to pointers! Of course a Ptr is also a mutable variable so I've added instances for them. Pleasure to be of help, even if it was by accident
Cheers, Vlado