Lift a column over a
Maybe. For example, if some people have
houses and some do not, the data that pairs them together could be
represented as:
>>> :{
let owners :: [(Person,Maybe House)]
owners =
[ (Person "Jordan" 18, Nothing)
, (Person "Ruth" 25, Just (House Red 125000))
, (Person "Sonia" 12, Just (House Green 145000))
]
:}
The column encodings defined earlier can be reused with the help of
fromMaybe:
>>> :{
let colOwners :: Colonnade Headed (Person,Maybe House) String
colOwners = mconcat
[ lmap fst colPerson
, lmap snd (fromMaybe "" colHouse)
]
:}
>>> putStr (ascii colOwners owners)
+--------+-----+-------+---------+
| Name | Age | Color | Price |
+--------+-----+-------+---------+
| Jordan | 18 | | |
| Ruth | 25 | Red | $125000 |
| Sonia | 12 | Green | $145000 |
+--------+-----+-------+---------+