title: Nim: standard way to convert integer/string to enum
body: <p>The question is Nim language specific.
  I am looking for a standard to way to convert integer/string into enum in a type safe way. Converting from enum to integer/string is easy using ord() and $(), but i can't find an easily way to make opposite transformation.</p>
  
  <p>Suppose I have the following type declaration</p>
  
  <pre><code>ProductGroup {.pure.} = enum
    Food = (3, "Food and drinks"),
    kitchen = (9, "Kitchen appliance and cutlery"),
    Bedroom = (15, "Pillows, Beddings and stuff"),
    Bathroom = (17, "Shower gels and shampoo")
  </code></pre>
  
  <p>I am looking for a standard way to do:</p>
  
  <pre><code>const
     product1 : seq[ProductGroup] = xxSomethingxx(@[3, 3, 17, 9, 15])
  
     product2 : seq[ProductGroup] = zzSomethingzz(@["Kitchen appliance and cutlery", "Kitchen appliance and cutlery", "Shower gels and shampoo"]) 
  
     product3 : seq[ProductGroup] = xxSomethingxx(@[2]) ## compilation error "2 does not convert into ProductGroup"
  </code></pre>