on 56cc7ce help sign in
typeable/yaml/parser-test.hs
22 lines 473 B history raw
1{-# LANGUAGE OverloadedStrings #-}
2import Data.Yaml.Parser
3import Data.Conduit
4import Text.Libyaml
5import Control.Applicative
6import Data.Text (Text)
8data Person = Person
9 { name :: !Text
10 , age :: !Int
11 }
12 deriving (Show)
14instance FromYaml Person where
15 fromYaml = withMapping "Person" $ \o -> Person
16 <$> o .: "name"
17 <*> o .: "age"
19main :: IO ()
20main = do
21 persons <- readYamlFile "/tmp/foo.yaml"
22 mapM_ print (persons :: [Person])