Skip to content

Commit 88dc8da

Browse files
Rename Text to String (#18)
1 parent 6ffffdf commit 88dc8da

9 files changed

Lines changed: 13 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* Improve rendering parse errors
66
* Include filepath in error messages when `decodeFileWith` fails
77

8+
API changes:
9+
* Rename `Text` constructor to `String` in `ValueData`
10+
811
## v0.2.1
912

1013
* Add `KDL.Applicative`

src/KDL/Decoder/Arrow.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ any = valueDataDecoderPrim (SchemaOr $ map SchemaOne [minBound .. maxBound]) pur
10201020
-- | Decode a KDL text value.
10211021
text :: DecodeArrow Value a Text
10221022
text = valueDataDecoderPrim (SchemaOne TextSchema) $ \case
1023-
Value{data_ = Text s} -> pure s
1023+
Value{data_ = String s} -> pure s
10241024
v -> decodeThrow DecodeError_ValueDecodeFail{expectedType = "text", value = v}
10251025

10261026
-- | Decode a KDL number value.

src/KDL/Parser/Internal.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ p_value = label "value" $ do
440440

441441
(data_, repr) <-
442442
withSource . choice . map try $
443-
[ Text <$> p_string
443+
[ String <$> p_string
444444
, p_number
445445
, p_keyword
446446
]

src/KDL/Render.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ renderValue Value{..} =
101101

102102
renderValueData :: ValueData -> Text
103103
renderValueData = \case
104-
Text s -> renderString s
104+
String s -> renderString s
105105
Number x -> (Text.pack . show) x
106106
Bool b -> if b then "#true" else "#false"
107107
Inf -> "#inf"

src/KDL/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ valueFormat :: Value -> Maybe ValueFormat
338338
valueFormat = (.format)
339339

340340
data ValueData
341-
= Text Text
341+
= String Text
342342
| Number Scientific
343343
| Bool Bool
344344
| Inf

test/KDL/Decoder/ArrowSpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ apiSpec = do
854854
, entries =
855855
[ Entry
856856
{ name = Nothing
857-
, value = Value{ann = Nothing, data_ = Text "test", format = Nothing}
857+
, value = Value{ann = Nothing, data_ = String "test", format = Nothing}
858858
, format = Nothing
859859
}
860860
]
@@ -894,7 +894,7 @@ apiSpec = do
894894
, format = Nothing
895895
}
896896
KDL.decodeWith decoder config
897-
`shouldBe` Right [val $ Number 1, val $ Text "asdf", val $ Bool True]
897+
`shouldBe` Right [val $ Number 1, val $ String "asdf", val $ Bool True]
898898

899899
describe "text" $ do
900900
it "decodes text value" $ do

test/KDL/Decoder/MonadSpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ apiSpec = do
848848
, entries =
849849
[ Entry
850850
{ name = Nothing
851-
, value = Value{ann = Nothing, data_ = Text "test", format = Nothing}
851+
, value = Value{ann = Nothing, data_ = String "test", format = Nothing}
852852
, format = Nothing
853853
}
854854
]
@@ -888,7 +888,7 @@ apiSpec = do
888888
, format = Nothing
889889
}
890890
KDL.decodeWith decoder config
891-
`shouldBe` Right [val $ Number 1, val $ Text "asdf", val $ Bool True]
891+
`shouldBe` Right [val $ Number 1, val $ String "asdf", val $ Bool True]
892892

893893
describe "text" $ do
894894
it "decodes text value" $ do

test/KDL/__snapshots__/ParserSpec.snap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ NodeList
3232
, value =
3333
Value
3434
{ ann = Nothing
35-
, data_ = Text "world"
35+
, data_ = String "world"
3636
, format = Just ValueFormat { repr = "world" }
3737
}
3838
, format =

test/kdl-hs-test-decoder.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ encodeEntry entry =
5656

5757
encodeValueData :: KDL.ValueData -> Aeson.Value
5858
encodeValueData = \case
59-
KDL.Text s -> val "string" (Text.unpack s)
59+
KDL.String s -> val "string" (Text.unpack s)
6060
KDL.Number x -> val "number" (Scientific.formatScientific Scientific.Fixed Nothing x)
6161
KDL.Bool x -> val "boolean" (if x then "true" else "false")
6262
KDL.Inf -> val "number" "inf"

0 commit comments

Comments
 (0)