on bbcd0ab help sign in
54 lines 1.2 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
12import Prelude -- Ensure Applicative is in scope and we have no warnings, before/after AMP.
14configYaml :: ByteString
15configYaml = [r|
16resolver: lts-3.7
17packages:
18 - ./yesod-core
19 - ./yesod-static
20 - ./yesod-persistent
21 - ./yesod-newsfeed
22 - ./yesod-form
23 - ./yesod-auth
24 - ./yesod-auth-oauth
25 - ./yesod-sitemap
26 - ./yesod-test
27 - ./yesod-bin
28 - ./yesod
29 - ./yesod-eventsource
30 - ./yesod-websockets
32# Needed for LTS 2
33extra-deps:
34- wai-app-static-3.1.4.1
35|]
37data Config =
38 Config {
39 resolver :: Text
40 , packages :: [FilePath]
41 , extraDeps :: [Text]
42 } deriving (Eq, Show)
44instance FromJSON Config where
45 parseJSON (Y.Object v) =
46 Config <$>
47 v .: "resolver" <*>
48 v .: "packages" <*>
49 v .: "extra-deps"
50 parseJSON _ = fail "Expected Object for Config value"
52main :: IO ()
53main =
54 print $ (Y.decode configYaml :: Maybe Config)