AsValueEntity connects a database entity representation with its domain type. It keeps conversion logic separate from the generic loading workflow, so a typed load can return a domain value instead of exposing storage details. section 11.2.4 section 11.2.3
The class defines two directional conversions:
- toValueEntity converts a domain value into the associated ValueEntity representation used by the database model. section 11.2.4
- fromValueEntity receives a KeyEntity and stored ValueEntity, then reconstructs the domain value. section 11.2.4
- loadEntity combines AsValueEntity with DBEntity: it loads raw data, decodes it, and converts the typed value into the requested destination type. section 11.2.4 section 11.2.3
Meteor conversion
The Meteor instance maps Meteor to KVDBMeteor in toValueEntity. Its fromValueEntity implementation accepts MeteorKey and KVDBMeteor, then rebuilds Meteor while leaving the primary-key decision explicit. section 11.2.4
class DBEntity db entity | entity -> db where
toDBKey #1
:: KeyEntity entity -> KVDBKey
toDBValue #2
:: ValueEntity entity -> KVDBValue
fromDBValue #3
:: KVDBValue -> Maybe (ValueEntity entity)
The surrounding type-level interface shows how ValueEntity participates in database-specific key, value, and decoding operations. section 11.2.4
