on master help sign in
Smarter isNumeric (. is not quoted)
3e3d9a3Michael Snoyman
ChangeLog.md+5
@@ -1,3 +1,8 @@
1+## 0.8.22.1
2+
3+* Make numeric string detection slightly smarter so, e.g., `.` does
4+ not get quoted
5+
1## 0.8.22
6## 0.8.22
2
7
3* Update to libyaml hosted on Github [#105](https://github.com/snoyberg/yaml/issues/105)
8* Update to libyaml hosted on Github [#105](https://github.com/snoyberg/yaml/issues/105)
Data/Yaml/Internal.hs+4−3
@@ -284,10 +284,11 @@ specialStrings = HashSet.fromList $ T.words
284 "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 ~"
284 "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 ~"
285
285
286isNumeric :: Text -> Bool
286isNumeric :: Text -> Bool
287−isNumeric =
287+isNumeric t =
288− T.all isNumeric'
288+ T.all isNumeric' t && T.any isNumber t
289 where
289 where
290− isNumeric' c = ('0' <= c && c <= '9')
290+ isNumber c = '0' <= c && c <= '9'
291+ isNumeric' c = isNumber c
291 || c == 'e'
292 || c == 'e'
292 || c == 'E'
293 || c == 'E'
293 || c == '.'
294 || c == '.'
test/Data/YamlSpec.hs+5
@@ -70,6 +70,7 @@ spec = do
70 it "encode/decode strings" caseEncodeDecodeStrings
70 it "encode/decode strings" caseEncodeDecodeStrings
71 it "decode invalid file" caseDecodeInvalid
71 it "decode invalid file" caseDecodeInvalid
72 it "processes datatypes" caseDataTypes
72 it "processes datatypes" caseDataTypes
73+ it "encode invalid numbers" caseEncodeInvalidNumbers
73 describe "Data.Yaml.Pretty" $ do
74 describe "Data.Yaml.Pretty" $ do
74 it "encode/decode" caseEncodeDecodeDataPretty
75 it "encode/decode" caseEncodeDecodeDataPretty
75 it "encode/decode strings" caseEncodeDecodeStringsPretty
76 it "encode/decode strings" caseEncodeDecodeStringsPretty
@@ -434,6 +435,10 @@ caseDataTypes =
434 , ("null", D.Null)
435 , ("null", D.Null)
435 ]
436 ]
436
437
438+caseEncodeInvalidNumbers :: Assertion
439+caseEncodeInvalidNumbers =
440+ D.encode (D.String ".") @?= ".\n"
441+
437caseDataTypesPretty :: Assertion
442caseDataTypesPretty :: Assertion
438caseDataTypesPretty =
443caseDataTypesPretty =
439 D.decode (Pretty.encodePretty Pretty.defConfig val) @?= Just val
444 D.decode (Pretty.encodePretty Pretty.defConfig val) @?= Just val
yaml.cabal+1−1
@@ -1,5 +1,5 @@
1name: yaml
1name: yaml
2−version: 0.8.22
2+version: 0.8.22.1
3license: BSD3
3license: BSD3
4license-file: LICENSE
4license-file: LICENSE
5author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov
5author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov