module Data.Yaml.Extended
( module Data.Yaml
, toString
, toList
) where
import qualified Data.Text as T
import qualified Data.Vector as V
import Data.Yaml
import Data.Scientific
toString :: Value -> Maybe String
toString :: Value -> Maybe String
toString (String Text
t) = forall a. a -> Maybe a
Just (Text -> String
T.unpack Text
t)
toString (Bool Bool
True) = forall a. a -> Maybe a
Just String
"true"
toString (Bool Bool
False) = forall a. a -> Maybe a
Just String
"false"
toString (Number Scientific
d) | Scientific -> Bool
isInteger Scientific
d = forall a. a -> Maybe a
Just (FPFormat -> Maybe Int -> Scientific -> String
formatScientific FPFormat
Fixed (forall a. a -> Maybe a
Just Int
0) Scientific
d)
| Bool
otherwise = forall a. a -> Maybe a
Just (forall a. Show a => a -> String
show Scientific
d)
toString Value
_ = forall a. Maybe a
Nothing
toList :: Value -> Maybe [Value]
toList :: Value -> Maybe [Value]
toList (Array Array
a) = forall a. a -> Maybe a
Just (forall a. Vector a -> [a]
V.toList Array
a)
toList Value
_ = forall a. Maybe a
Nothing