Rewriting script parsing functions to work within the Either monad