toy hmm in scala