Eric, a very late question
In object oriented languages, we have the flexibility of defining sub-classes late after super class has been defined. The two definitions need not be done simultaneously. Moreover, there is no limit on the number of sub-classes baring the case of sealed types (which could still be circumvented using containment and defining casts).
In relation to the analogy of algebraic types and class hierarchies, what is the way in Haskell to extend the types as we can do in object oriented languages.
data Answer = No | Yes
data AnswerEx = FromAnswer Answer | Unknown
fromAnswerEx :: AnswerEx -> Answer
fromAnswerEx FromAnswer a = a
fromAnswerEx Unknown = No -- in Haskell we have to generate a value of Answer type here
We could surely define functions for explicit conversion e.g. fromAnswerEx but the compiles can not use them automatically. In code given below we have to use the explicit conversions.
answers = [Yes, No, fromAnswerEx Unknown, fromAnswerEx FromAnswer Yes]
The following will not work.
answers = [Yes, No, Unknown, FromAnswer Yes]
It is possible there in object oriented languages.
Is there any pattern/idiom in Haskell to achieve same?