+ wrap = mapM wrap1
+ wrap1 s
+ | null s = die "Wrapping empty value"
+ | '\'' `elem` s = die "Single quote in value to be wrapped"
+ -- We want to be able to assume things like <space><quote> is the
+ -- start of a value, so check there are no spaces in confusing
+ -- positions
+ | head s == ' ' = die "Leading space in value to be wrapped"
+ | last s == ' ' = die "Trailing space in value to be wrapped"
+ | otherwise = return ("\'" ++ s ++ "\'")