on e2109cd help sign in
53 lines 1.1 kB history raw
1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE QuasiQuotes #-}
4module Config where
6import Data.Text (Text)
7import qualified Data.Yaml as Y
8import Data.Yaml (FromJSON(..), (.:))
9import Text.RawString.QQ
10import Data.ByteString (ByteString)
11import Control.Applicative
13configYaml :: ByteString
14configYaml = [r|
15resolver: lts-3.7
16packages:
17 - ./yesod-core
18 - ./yesod-static
19 - ./yesod-persistent
20 - ./yesod-newsfeed
21 - ./yesod-form
22 - ./yesod-auth
23 - ./yesod-auth-oauth
24 - ./yesod-sitemap
25 - ./yesod-test
26 - ./yesod-bin
27 - ./yesod
28 - ./yesod-eventsource
29 - ./yesod-websockets
31# Needed for LTS 2
32extra-deps:
33- wai-app-static-3.1.4.1
34|]
36data Config =
37 Config {
38 resolver :: Text
39 , packages :: [FilePath]
40 , extraDeps :: [Text]
41 } deriving (Eq, Show)
43instance FromJSON Config where
44 parseJSON (Y.Object v) =
45 Config <$>
46 v .: "resolver" <*>
47 v .: "packages" <*>
48 v .: "extra-deps"
49 parseJSON _ = fail "Expected Object for Config value"
51main :: IO ()
52main =
53 print $ (Y.decode configYaml :: Maybe Config)