I was looking in to pre-existing variant types and found 
<https://github.com/yglukhov/variant/blob/master/variant.nim>

Something a bit clever I tried was using `method` to make it possible to pass 
`$` down to a variant type's concrete subtype.
    
    
    method box_to_string(self: Box): string =
       "<boxed type: " & $self.code.int & ">"
    
    method box_to_string[T](self: BoxConcrete[T]): string =
       $self.value
    
    proc `$`*(self: Box): string =
      box_to_string(self)
    
    
    Run

This absolutely worked, but the compiler says generic methods are deprecated. 
Bummer.

Reply via email to