Generating lens state functions which use the underlying transformer code