Solution (source code)

= Solution

Define an <implicit conversion> in the scope where client code uses the added methods:
``
import scala.language.implicitConversions

implicit def stringToDist(s: String): DistFromString =
  new DistFromString(s)
``
Then, for example,
``
val support = "Scala".getDom
val p = "Scala".getProb('a')
``
The <Scala> <compiler> can convert the receiver to `DistFromString` when the requested member is absent from `String`. The conversion must be imported or otherwise visible, and constructing the <finite probability distribution> retains the nonempty-<string> <precondition> of part (b).
$$
\boxed{\texttt{implicit def stringToDist(s: String): DistFromString}.}
$$