Make cached STM references work over data defined, stored and retrieved with persistent (from the Yesod web framework)