diff options
Diffstat (limited to 'src/IRE/Config.hs')
-rw-r--r-- | src/IRE/Config.hs | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/src/IRE/Config.hs b/src/IRE/Config.hs index c2b90d6..08d89a9 100644 --- a/src/IRE/Config.hs +++ b/src/IRE/Config.hs @@ -1,51 +1,47 @@ {-# LANGUAGE OverloadedStrings #-} -module IRE.Config ( - ConfigFile(..) -, YOLO(..) -, defaultConfig -) where +module IRE.Config + ( ConfigFile(..) + , YOLO(..) + , defaultConfig + ) where import Control.Applicative (empty) import Data.Aeson (FromJSON, parseJSON) -import Data.Yaml (Value(Object), (.:), (.:?), (.!=)) +import Data.Yaml (Value(Object), (.!=), (.:), (.:?)) +data ConfigFile = ConfigFile + { cfPort :: Int + , cfSocket :: Maybe FilePath + , cfYOLO :: YOLO + } deriving (Show) -data ConfigFile = ConfigFile { - cfPort :: Int -, cfSocket :: Maybe FilePath -, cfYOLO :: YOLO -} deriving (Show) - -data YOLO = YOLO { - yoloCfg :: FilePath -, yoloWeights :: FilePath -, yoloNames :: FilePath -} deriving (Show) - +data YOLO = YOLO + { yoloCfg :: FilePath + , yoloWeights :: FilePath + , yoloNames :: FilePath + } deriving (Show) defaultConfig :: ConfigFile -defaultConfig = ConfigFile { - cfPort = 8080 +defaultConfig = + ConfigFile + { cfPort = 8080 , cfSocket = Nothing - , cfYOLO = YOLO { - yoloCfg = "yolo.cfg" - , yoloWeights = "yolo.weights" - , yoloNames = "yolo.names" - } + , cfYOLO = + YOLO + { yoloCfg = "yolo.cfg" + , yoloWeights = "yolo.weights" + , yoloNames = "yolo.names" + } } instance FromJSON ConfigFile where - parseJSON (Object m) = ConfigFile <$> - m .:? "port" .!= cfPort defaultConfig - <*> m .:? "socket" .!= cfSocket defaultConfig - <*> m .:? "yolo" .!= cfYOLO defaultConfig + parseJSON (Object m) = + ConfigFile <$> m .:? "port" .!= cfPort defaultConfig <*> + m .:? "socket" .!= cfSocket defaultConfig <*> + m .:? "yolo" .!= cfYOLO defaultConfig parseJSON _ = empty instance FromJSON YOLO where - parseJSON (Object m) = YOLO <$> - m .: "cfg" - <*> m .: "weights" - <*> m .: "names" + parseJSON (Object m) = YOLO <$> m .: "cfg" <*> m .: "weights" <*> m .: "names" parseJSON _ = empty - |