
João Cristóvão
writes:
The case is that for very long and complex structures, filled with trivial values, and with an obvious default value, writing that default value is a task best left for the compiler, with the help of generics.
Ah, I see your point. Perhaps a compromise solution is possible: A given type can have a generically defined Trivial value if all its members are either also Trivial, OR they have Monoid instances with an mempty value. This way, I know that any Trivial value tree is, at its leaves, composed of trivial or mempty values, giving a principled meaning of 'emptiness', even though the Trivial instance may not itself form a Monoid. The Trivial class would further not allow explicit instances. The core types like Int would have hard-coded trivial values in 'base'; but if you want to define triviality for an ADT in some specific way, it would require making a Monoid instance to demonstrate what emptiness means relative to an operation. John