on 2736d21 help sign in
typeable/yaml/builder-test.hs
27 lines 578 B history raw
1{-# LANGUAGE OverloadedStrings #-}
2import Data.Yaml.Builder
3import qualified Data.ByteString as S
4import Data.Text (Text)
6data Person = Person
7 { name :: !Text
8 , age :: !Int
9 }
10instance ToYaml Person where
11 toYaml (Person n a) = mapping
12 [ "name" .= n
13 , "age" .= a
14 ]
16main :: IO ()
17main = do
18 S.putStr $ toByteString
19 [ Person "Alice" 57
20 , Person "Bob" 23
21 , Person "12345" 23
22 ]
23 writeYamlFile "/tmp/foo.yaml" $
24 [ Person "Alice" 57
25 , Person "Bob" 23
26 , Person "12345" 23
27 ]