code: func SampleGen(population interface{}, n int, rng *rand.Rand) interface{} {
  	chk := ty.Check(
  		new(func([]ty.A, int, *rand.Rand) []ty.A),
  		population, n, rng)
  	rpop, tsamp := chk.Args[0], chk.Returns[0]
  
  	popLen := rpop.Len()
  	if n == 0 {
  		return reflect.MakeSlice(tsamp, 0, 0).Interface()
  	}
  	if n > popLen {
  		n = popLen
  	}
  
  	// TODO(burntsushi): Implement an algorithm that doesn't depend on
  	// the size of the population.
  
  	rsamp := reflect.MakeSlice(tsamp, n, n)
  	choices := rng.Perm(popLen)
  	for i := 0; i < n; i++ {
  		rsamp.Index(i).Set(rpop.Index(choices[i]))
  	}
  	return rsamp.Interface()
  }
docs: // SampleGen has a parametric type:
  //
  //	func SampleGen(population []A, n int, rng *rand.Rand) []A
  //
  // SampleGen returns a random sample of size `n` from a list
  // `population` using a given random number generator `rng`.
  // All elements in `population` have an equal chance of being selected.
  // If `n` is greater than the size of `population`, then `n` is set to
  // the size of the population.