Q:

Scala Enum to Map [cannot prove ...]

I have this enum : 
object PhsIndType extends Enumeration{
  type PhsIndType = Value
  val A : Value = Value(1)
  val R : Value= Value(2)
  val O : Value = Value(3)
  val E : Value = Value(4)
}

And i'm trying to load it into a map for easier use : 
    val map = PhsIndType.values.toMap[AnyVal, AnyVal]

I've tried using every type I could think of instead of AnyVal, but I always get the error : 
Cannot prove that enumeration.PhsIndType.Value <:< (AnyVal, AnyVal).
val map = PhsIndType.values.toMap[AnyVal, AnyVal]

Anyone has a fix ? 
Thanks for your time. 

A:

The signature of toMap is:
toMap[T, U](implicit ev: A <:< (T, U)): immutable.Map[T, U]

That means that the underlying collection needs to have element of type Tuple2.
The type of PhsIndType.values is PhsIndType.ValueSet and not of type Tuple2
To achieve the desired result you want, you need to convert the underlying collection into type of (T,U) or Tuple2 and you can this by mapping:
scala> :paste
// Entering paste mode (ctrl-D to finish)

  object PhsIndType extends Enumeration {
    type PhsIndType = Value
    val A : Value = Value(1)
    val R : Value= Value(2)
    val O : Value = Value(3)
    val E : Value = Value(4)
  }

  PhsIndType.values.map(x => (x.id, x)).toMap

// Exiting paste mode, now interpreting.

defined object PhsIndType
res0: scala.collection.immutable.Map[Int,PhsIndType.Value] = Map(1 -> A, 2 -> R, 3 -> O, 4 -> E)

