Browse Source

Clean some syntax up thanks to hlint

tags/v0.2.2.0
Peter J. Jones 7 years ago
parent
commit
a264ec7b9e

+ 1
- 1
Network/API/TheMovieDB/Generic.hs View File

@@ -16,7 +16,7 @@ import Data.Aeson
-- Helper function to fetch and decode JSON.
getAndParse :: FromJSON a => Context -> Path -> Params -> IO (Either Error a)
getAndParse ctx path params =
do httpResult <- (ioFunc ctx) (apiKey ctx) path params
do httpResult <- ioFunc ctx (apiKey ctx) path params
return $ case httpResult of
Left err -> Left err
Right body -> maybe (parseErr body) Right $ decode body

+ 2
- 2
Network/API/TheMovieDB/Types/Configuration.hs View File

@@ -33,10 +33,10 @@ data Configuration = Configuration
}

instance FromJSON Configuration where
parseJSON (Object v) = do
parseJSON (Object v) =
Configuration <$> images "base_url"
<*> images "secure_base_url"
<*> imagesM "poster_sizes" []
where images key = (v .: "images") >>= (\x -> x .: key)
where images key = (v .: "images") >>= (.: key)
imagesM key def = (v .: "images") >>= (\x -> x .:? key .!= def)
parseJSON _ = empty

+ 1
- 1
Network/API/TheMovieDB/Util.hs View File

@@ -79,4 +79,4 @@ loadKey = liftM msum . sequence $ [env, xdgConfig, config, home]
-- | Uses 'loadKey' to fetch an API 'Key' and wrap it into a default
-- 'Context' using 'mkContext'.
loadContext :: IO (Maybe Context)
loadContext = liftM (maybe Nothing (Just . mkContext)) loadKey
loadContext = liftM (fmap mkContext) loadKey

+ 2
- 2
Test/TheMovieDB.hs View File

@@ -32,7 +32,7 @@ goodMovieFieldsTest = TestCase $ do
assertEqual "movieID" 105 (movieID movie)
assertEqual "movieTitle" "Back to the Future" (movieTitle movie)
assertBool "movieOverview" $
"Eighties teenager" `isPrefixOf` (movieOverview) movie
"Eighties teenager" `isPrefixOf` movieOverview movie
assertEqual "movieGenres" 4 (length $ movieGenres movie)
assertEqual "moviePopularity" 80329.688 $ moviePopularity movie
assertEqual "moviePosterPath" "/pTpxQB1N0waaSc3OSn0e9oc8kx9.jpg" $
@@ -63,5 +63,5 @@ unitTests = TestList
]

main = do counts <- runTestTT unitTests
let bad = (errors counts) + (failures counts)
let bad = errors counts + failures counts
when (bad > 0) exitFailure

+ 1
- 1
example/Main.hs View File

@@ -43,7 +43,7 @@ main = do args <- getArgs
let context = fromJust contextM
cfg <- config context
case args of
["key"] -> do putStrLn $ apiKey context
["key"] -> putStrLn $ apiKey context

["search", query] -> do movies <- search context query
mapM_ printMovieHeader movies

Loading…
Cancel
Save