Programmatic data access
Unlike the built-in field access functionality in programming languages, lenses are defined entirely programmatically. In the previous section, we used them rather rigidly to access actual fields of data types. Nothing forces those fields to be present, and we can deviate from them if we want.
Virtual fields
Consider the following data type for claiming car trip expenses:
data Trip = MkTrip { _origin :: String , _destination :: String , _distanceInKm :: Float }
The distance is stored in kilometers and comes with an appropriate lens:
distanceInKm :: Lens' Trip Float distanceInKm t (MkTrip o d km) = fmap (\km' -> MkTrip o d km') (t km)
However...