Separate reading and writing references.

Add a pure reader in the Identity monad (no WriteRef instance).
Due to some weird issue, I had to add some extra type annotations which
should not be required.