A domain type gives program values the shape of a real-world concept, such as a meteor with size, mass, coordinates, and time. It belongs to the domain model rather than the storage scheme. section 11.2.1 section 12.1.1
Keep domain types separate from database types when persistence introduces its own representations:
- Map a domain type to a database model before storing it, rather than exposing database-specific keys, timestamps, or fundamental types to domain logic. section 11.2.1 section 12.1.1
- Use conversion functions in both directions so changes such as extracting coordinates into a separate type do not require changing the database representation. section 12.1.1
data Meteor = Meteor
{ size :: Int
, mass :: Int
, azimuth :: Float
, altitude :: Float
, timestamp :: DateTime
}
The Meteor declaration makes the domain concept concrete with native fields for size, mass, coordinates, and timestamp. section 12.1.1
