summaryrefslogtreecommitdiff
path: root/src/Data/Yaml/Extended.hs
blob: 099e945ad3f596497868ac438a01bed7e3cf574b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

toString :: Value -> Maybe String
toString (String t)     = Just (T.unpack t)
toString (Bool   True)  = Just "true"
toString (Bool   False) = Just "false"
toString (Number d)     = Just (show d)
toString _              = Nothing

toList :: Value -> Maybe [Value]
toList (Array a) = Just (V.toList a)
toList _         = Nothing