|
|
|
|
|
by tome
3154 days ago
|
|
Does this meet your criteria of "first-class" property? It works on any entity that "has" and "age", at least according to my definition of those things! -- The class definition can often be entirely elided
-- with Generics or Template Haskell. Instance
-- definitions can generally require minimal or no
-- implementation either
class HasAge r age | r -> age where
getAge :: r -> age
setAge :: r -> age -> r
isOld :: HasAge r => r -> Bool
isOld r = getAge r > 30
|
|