More resilient `isNumeric`
Should reduce cases of unneeded quoting
commitc1b471189a7fb71ee547688edcf71d9e1474bb4a
authorMichael Snoyman <michael@snoyman.com>
dateMon 9 Jul 2018, 12:45 (8 years ago)
parent6d7187f
ChangeLog.md+1
@@ -4,6 +4,7 @@
44
55* Escape keys as necessary [#137](https://github.com/snoyberg/yaml/issues/137)
66* Support hexadecimal and octal number values [#135](https://github.com/snoyberg/yaml/issues/135)
7+* More resilient `isNumeric` (should reduce cases of unneeded quoting)
78* hpackify
89* src subdir
910
src/Data/Yaml/Internal.hs+1−12
@@ -296,15 +296,4 @@ specialStrings = HashSet.fromList $ T.words
296296 "y Y yes Yes YES n N no No NO true True TRUE false False FALSE on On ON off Off OFF null Null NULL ~ *"
297297
298298isNumeric :: Text -> Bool
299−isNumeric t =
300− T.all isNumeric' t && T.any isNumber t
301− where
302− isNumber c = '0' <= c && c <= '9'
303− isNumeric' c = isNumber c
304− || c == 'e'
305− || c == 'E'
306− || c == 'o'
307− || c == 'x'
308− || c == '.'
309− || c == '-'
310− || c == '+'
299+isNumeric = either (const False) (const True) . textToScientific