Pattern-matching string converters

Fixes #1598. I'd appreciate some review; I'm new from the language, and since most of my functional programming experience comes from Common Lisp and Clojure, I'm not very familiar with idiomatic pattern-matching solutions to things.