Open rudymatela opened 7 years ago
Maybe this could be solved by adding yet another function to the Generalizable typeclass?
class Generalizable a where
...
valid :: a -> Bool
valid = True
instance Generalizable Nat where
...
valid (Nat n) = n >= 0
The output for the above program is:
The conditional generalization is correct. However it is only correct for data values that do not follow the data invariant of Nat.
Thanks to @ColinRunciman for discovering this.