Sounds that you actually need
    
    
    type
      
      Some[T] = tuple
        value: T
      
      None = tuple
      
      Maybe[T] = Some[T] or None
    
    proc either[T](m: Maybe[T], alternative: T): T =
      when m is Some[T]:
        return m.value
      else:
        return alternative
    

P.S.
    edited - replaced if with when

Reply via email to