old changes
made all changes necessary to replace all mentions of error with Left. TODO: improve the code to avoid explicit case statements; use case for regular bind in a nonobvious way, or monad transformers, or some third possibility?