Interpreter is a language (or program) to evaluate expressions and execute code. The intent is to keep the evaluation lazy and pure. There are 3 different kinds of methods in the interpreter pattern / Algebra.
Monad typeclass
trait Monad[F[_]]:
def pure[A](a: A): F[A]
def flatMap[A, B](fa: F[A])(f: A → F[B]): F[B]
pure(a).flatMap(f) = f(a)
m.flatMap(pure) = m
m.flatMap(g).flatMap(h) = m.flatMap(b => g(b).flatMap(h))