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 conf' <- readOptions
host <- getHostName host <- getHostName
conf <- return conf' { configHost = host } let conf = conf'{configHost = host}
let port = configPort conf let port = configPort conf
pgSettings = cs (configDatabase conf) pgSettings = cs (configDatabase conf)
appSettings = setPort port appSettings = setPort port
+9 -9
View File
@@ -32,13 +32,13 @@ toSwaggerType "numeric" = SwaggerNumber
toSwaggerType _ = SwaggerString toSwaggerType _ = SwaggerString
makeProperty :: Column -> (Text, Referenced Schema) makeProperty :: Column -> (Text, Referenced Schema)
makeProperty c = (colName c, Inline $ u) makeProperty c = (colName c, Inline u)
where where
r = (mempty :: Schema) r = mempty :: Schema
s = if null $ colEnum c s = if null $ colEnum c
then r then r
else r & enum_ .~ decode (encode (colEnum c)) else r & enum_ .~ decode (encode (colEnum c))
t = s & type_ .~ (toSwaggerType $ colType c) t = s & type_ .~ toSwaggerType (colType c)
u = t & format ?~ colType c u = t & format ?~ colType c
makeProperties :: [Column] -> InsOrdHashMap Text (Referenced Schema) makeProperties :: [Column] -> InsOrdHashMap Text (Referenced Schema)
@@ -49,7 +49,7 @@ makeDefinition (t, cs, _) =
let tn = tableName t in let tn = tableName t in
(tn, (mempty :: Schema) (tn, (mempty :: Schema)
& type_ .~ SwaggerObject & type_ .~ SwaggerObject
& properties .~ (makeProperties cs)) & properties .~ makeProperties cs)
makeDefinitions :: [(Table, [Column], [Text])] -> InsOrdHashMap Text Schema makeDefinitions :: [(Table, [Column], [Text])] -> InsOrdHashMap Text Schema
makeDefinitions ti = fromList $ map makeDefinition ti makeDefinitions ti = fromList $ map makeDefinition ti
@@ -73,7 +73,7 @@ makeRowFilter c =
& pattern ?~ makeOperatorPattern) & pattern ?~ makeOperatorPattern)
makeRowFilters :: [Column] -> [Param] makeRowFilters :: [Column] -> [Param]
makeRowFilters cs = map makeRowFilter cs makeRowFilters = map makeRowFilter
makeOrderItems :: [Column] -> [Text] makeOrderItems :: [Column] -> [Text]
makeOrderItems cs = makeOrderItems cs =
@@ -163,7 +163,7 @@ makeDeleteParams =
[ makePreferParam ["return=representation", "return=minimal"] ] [ makePreferParam ["return=representation", "return=minimal"] ]
makePathItem :: (Table, [Column], [Text]) -> (FilePath, PathItem) makePathItem :: (Table, [Column], [Text]) -> (FilePath, PathItem)
makePathItem (t, cs, _) = ("/" ++ (unpack tn), p $ tableInsertable t) makePathItem (t, cs, _) = ("/" ++ unpack tn, p $ tableInsertable t)
where where
tOp = (mempty :: Operation) tOp = (mempty :: Operation)
& tags .~ Set.fromList [tn] & tags .~ Set.fromList [tn]
@@ -194,11 +194,11 @@ apiSpec ti h p = (mempty :: Swagger)
& basePath ?~ "/" & basePath ?~ "/"
& schemes ?~ [Http] & schemes ?~ [Http]
& info .~ ((mempty :: Info) & info .~ ((mempty :: Info)
& version .~ (pack prettyVersion) & version .~ pack prettyVersion
& title .~ "PostgREST API" & title .~ "PostgREST API"
& description ?~ "This is a dynamic API generated by PostgREST") & description ?~ "This is a dynamic API generated by PostgREST")
& host .~ h' & host .~ h'
& definitions .~ (makeDefinitions ti) & definitions .~ makeDefinitions ti
& paths .~ (makePathItems ti) & paths .~ makePathItems ti
where where
h' = Just $ Host h (Just (fromInteger p)) h' = Just $ Host h (Just (fromInteger p))
+2 -2
View File
@@ -220,13 +220,13 @@ app dbStructure conf apiRequest =
where where
toTableInfo :: [Table] -> [(Table, [Column], [Text])] toTableInfo :: [Table] -> [(Table, [Column], [Text])]
toTableInfo ts = map (\t -> toTableInfo = map (\t ->
let tSchema = tableSchema t let tSchema = tableSchema t
tTable = tableName t tTable = tableName t
cols = filter (filterCol tSchema tTable) $ dbColumns dbStructure cols = filter (filterCol tSchema tTable) $ dbColumns dbStructure
pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys pkeys = map pkName $ filter (filterPk tSchema tTable) allPrKeys
in in
(t, cols, pkeys)) ts (t, cols, pkeys))
encodeApi :: [(Table, [Column], [Text])] -> BL.ByteString encodeApi :: [(Table, [Column], [Text])] -> BL.ByteString
encodeApi ti = encode $ apiSpec ti host port encodeApi ti = encode $ apiSpec ti host port
host = configHost conf host = configHost conf