ex6.10 - add generalised unit function to State companion object