Fix all hlint errors except for pattern error

This commit is contained in:
Jacky Hu
2016-06-18 10:18:43 +08:00
parent 4b0c5cb36f
commit 74ea4aba37
3 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -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
+9 -9
View File
@@ -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))
+2 -2
View File
@@ -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