From 74ea4aba379c94b0d7faaf03d8e7841ed3a06457 Mon Sep 17 00:00:00 2001 From: Jacky Hu Date: Tue, 14 Jun 2016 11:30:31 +0800 Subject: [PATCH] Fix all hlint errors except for pattern error --- main/Main.hs | 2 +- src/PostgREST/ApiSpec.hs | 18 +++++++++--------- src/PostgREST/App.hs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/main/Main.hs b/main/Main.hs index 24398affe..b9b8723bd 100644 --- a/main/Main.hs +++ b/main/Main.hs @@ -49,7 +49,7 @@ main = do conf' <- readOptions host <- getHostName - conf <- return conf' { configHost = host } + let conf = conf'{configHost = host} let port = configPort conf pgSettings = cs (configDatabase conf) appSettings = setPort port diff --git a/src/PostgREST/ApiSpec.hs b/src/PostgREST/ApiSpec.hs index d7a1c704c..408cc0a03 100644 --- a/src/PostgREST/ApiSpec.hs +++ b/src/PostgREST/ApiSpec.hs @@ -32,13 +32,13 @@ toSwaggerType "numeric" = SwaggerNumber toSwaggerType _ = SwaggerString makeProperty :: Column -> (Text, Referenced Schema) -makeProperty c = (colName c, Inline $ u) +makeProperty c = (colName c, Inline u) where - r = (mempty :: Schema) + r = mempty :: Schema s = if null $ colEnum c then r else r & enum_ .~ decode (encode (colEnum c)) - t = s & type_ .~ (toSwaggerType $ colType c) + t = s & type_ .~ toSwaggerType (colType c) u = t & format ?~ colType c makeProperties :: [Column] -> InsOrdHashMap Text (Referenced Schema) @@ -49,7 +49,7 @@ makeDefinition (t, cs, _) = let tn = tableName t in (tn, (mempty :: Schema) & type_ .~ SwaggerObject - & properties .~ (makeProperties cs)) + & properties .~ makeProperties cs) makeDefinitions :: [(Table, [Column], [Text])] -> InsOrdHashMap Text Schema makeDefinitions ti = fromList $ map makeDefinition ti @@ -73,7 +73,7 @@ makeRowFilter c = & pattern ?~ makeOperatorPattern) makeRowFilters :: [Column] -> [Param] -makeRowFilters cs = map makeRowFilter cs +makeRowFilters = map makeRowFilter makeOrderItems :: [Column] -> [Text] makeOrderItems cs = @@ -163,7 +163,7 @@ makeDeleteParams = [ makePreferParam ["return=representation", "return=minimal"] ] makePathItem :: (Table, [Column], [Text]) -> (FilePath, PathItem) -makePathItem (t, cs, _) = ("/" ++ (unpack tn), p $ tableInsertable t) +makePathItem (t, cs, _) = ("/" ++ unpack tn, p $ tableInsertable t) where tOp = (mempty :: Operation) & tags .~ Set.fromList [tn] @@ -194,11 +194,11 @@ apiSpec ti h p = (mempty :: Swagger) & basePath ?~ "/" & schemes ?~ [Http] & info .~ ((mempty :: Info) - & version .~ (pack prettyVersion) + & version .~ pack prettyVersion & title .~ "PostgREST API" & description ?~ "This is a dynamic API generated by PostgREST") & host .~ h' - & definitions .~ (makeDefinitions ti) - & paths .~ (makePathItems ti) + & definitions .~ makeDefinitions ti + & paths .~ makePathItems ti where h' = Just $ Host h (Just (fromInteger p)) diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index ac686d368..a03afd9ed 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -220,13 +220,13 @@ app dbStructure conf apiRequest = where toTableInfo :: [Table] -> [(Table, [Column], [Text])] - toTableInfo ts = map (\t -> + toTableInfo = map (\t -> let tSchema = tableSchema t tTable = tableName t cols = filter (filterCol tSchema tTable) $ dbColumns dbStructure pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys in - (t, cols, pkeys)) ts + (t, cols, pkeys)) encodeApi :: [(Table, [Column], [Text])] -> BL.ByteString encodeApi ti = encode $ apiSpec ti host port host = configHost conf