diff options
author | Joris | 2015-09-02 18:42:19 +0200 |
---|---|---|
committer | Joris | 2015-09-02 18:42:19 +0200 |
commit | 18c793df31969024213d18624323dd74c3be542d (patch) | |
tree | fbe15266596b057a624559d6b3124c7f8e6c012c /src | |
parent | 02102713eae95fd6f42ff7681a640e43c5ba6d3d (diff) |
Adding output in order to know if the application get the correct material
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 5 | ||||
-rw-r--r-- | src/Model/Json/Search.hs | 10 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Main.hs b/src/Main.hs index d561419..f9054af 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -64,8 +64,9 @@ getHtmlPerfumes material = do Left error -> return . Left . T.pack $ error Right searches -> - case getMaterialIdentifier searches of + case getMaterialSearch searches of Nothing -> return . Left $ T.concat [ "No material identifier found for ", material ] - Just identifier -> do + Just (Search identifier _ name) -> do + T.putStrLn $ T.concat [ "Found material « ", name, " » for ", material, "." ] fmap parsePerfumes <$> getPage (getMaterialURL identifier) diff --git a/src/Model/Json/Search.hs b/src/Model/Json/Search.hs index b31b548..74f0ec9 100644 --- a/src/Model/Json/Search.hs +++ b/src/Model/Json/Search.hs @@ -2,7 +2,7 @@ module Model.Json.Search ( Search(..) - , getMaterialIdentifier + , getMaterialSearch ) where import Control.Monad (mzero) @@ -15,14 +15,16 @@ import Data.List (find) data Search = Search { identifier :: Text , kind :: Text + , name :: Text } deriving (Show) instance FromJSON Search where parseJSON (Object v) = Search <$> v .: "id" <*> - v .: "type" + v .: "type" <*> + v .: "name" parseJSON _ = mzero -getMaterialIdentifier :: [Search] -> Maybe Text -getMaterialIdentifier = fmap identifier . find ((==) "matiere" . kind) +getMaterialSearch :: [Search] -> Maybe Search +getMaterialSearch = find ((==) "matiere" . kind) |