No title

Anonymous Coward 2018-03-12 16:45:00.762562 UTC

1data BuildOptions = BuildOptions { libs :: [String]
2 , includePaths :: [String]
3 , compiler :: String
4 , compilerFlags :: [String]
5 }
6 deriving Show
7
8instance FromJSON BuildOptions where
9 parseJSON (Object val) = BuildOptions <$>
10 val .: "libs" <*>
11 val .: "includePaths" <*>
12 val .: "compiler" <*>
13 val .: "compilerFlags"
14 -- A non-Object value is of the wrong type, so fail.
15 --}
16 parseJSON _ = error "Can't parse BuildOptions from YAML/JSON"
17
18main = do
19 ymlData <- BS.readFile "project.yaml"
20 let options = Data.Yaml.decode ymlData :: Maybe BuildOptions
21 -- Print it, just for show
22 print $ fromJust options