`Gene` will not work, nor will `Gene3` above ... you cannot build a runtime 
dynamic type out of generics, which are a compile-time feature. I advise 
reading and understanding what the manual says about type classes:

> Whilst the syntax of type classes appears to resemble that of ADTs/algebraic 
> data types in ML-like languages, it should be understood that type classes 
> are static constraints to be enforced at type instantiations. Type classes 
> are not really types in themselves, but are instead a system of providing 
> generic "checks" that ultimately resolve to some singular type. Type classes 
> do not allow for runtime type dynamism, unlike object variants or methods.

There you have it: object variants (`Gene2`) or methods ... i.e., define a base 
class derived from RootObj, and then define your various object types derived 
from the base; you then specify different behaviors for the different object 
types by defining methods (like `proc` but with the `method` keyword instead) 
taking the different types as arguments ... this is the standard 
object-oriented approach. 

Reply via email to