File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -252,11 +252,18 @@ incorporateAliases :: RawExpr -> CoreExpr
252
252
incorporateAliases (RawExpr e _) = e -- TODO: Yaml aliases
253
253
254
254
-- | Parse eu-annotated active YAML into a CoreExpr
255
+ --
256
+ -- If the data is entirely blank, return an empty block (despite this
257
+ -- being invalid yaml)
255
258
parseYamlExpr :: String -> BS. ByteString -> IO CoreExpr
256
259
parseYamlExpr inputName s =
257
- catchJust yamlError
258
- (incorporateAliases <$> runConduitRes (decode s .| sinkActiveRawExpr))
259
- (throwM . yamlExceptionToDataParseException inputName)
260
+ if BS. null s
261
+ then
262
+ return $ anon block []
263
+ else
264
+ catchJust yamlError
265
+ (incorporateAliases <$> runConduitRes (decode s .| sinkActiveRawExpr))
266
+ (throwM . yamlExceptionToDataParseException inputName)
260
267
where
261
268
yamlError :: YamlException -> Maybe YamlException
262
269
yamlError = Just
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ main = hspec spec
16
16
spec :: Spec
17
17
spec =
18
18
describe " Yaml parser" $ do
19
+ it " Accepts empty input" $ parseYamlExpr " <test>" " " `shouldReturn` block []
19
20
it " Parses key value" $
20
21
parseYamlExpr " <test>" " a: !!int 1234" `shouldReturn`
21
22
letexp [(" a" , int 1234 )] (block [element " a" $ var " a" ])
You can’t perform that action at this time.
0 commit comments