From e61672ebf8503962644a3594dc22498a595d9c24 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Tue, 17 Dec 2013 20:27:11 +0200 Subject: [PATCH] hlint --- Language/SQL/SimpleSQL/Fixity.lhs | 2 +- Language/SQL/SimpleSQL/Parser.lhs | 4 ++-- Language/SQL/SimpleSQL/Pretty.lhs | 2 +- Language/SQL/SimpleSQL/Syntax.lhs | 2 +- TODO | 18 +++++++++++++++--- tools/Language/SQL/SimpleSQL/Postgres.lhs | 2 +- tools/Language/SQL/SimpleSQL/ScalarExprs.lhs | 9 +++++---- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Language/SQL/SimpleSQL/Fixity.lhs b/Language/SQL/SimpleSQL/Fixity.lhs index 1a4e63d..a38741a 100644 --- a/Language/SQL/SimpleSQL/Fixity.lhs +++ b/Language/SQL/SimpleSQL/Fixity.lhs @@ -117,7 +117,7 @@ the fixity code. > var = HSE.Var . HSE.UnQual . HSE.Ident > sym = HSE.UnQual . HSE.Symbol > name n = case n of -> QName q -> "\"" ++ q +> QName q -> '"' ++ q > Name m -> m > orderExps = map (toHaskell . (\(OrderField a _ _) -> a)) > orderInf = map (\(OrderField _ b c) -> (b,c)) diff --git a/Language/SQL/SimpleSQL/Parser.lhs b/Language/SQL/SimpleSQL/Parser.lhs index cb97a05..009c0ea 100644 --- a/Language/SQL/SimpleSQL/Parser.lhs +++ b/Language/SQL/SimpleSQL/Parser.lhs @@ -183,8 +183,8 @@ always used with the optionSuffix combinator. > partitionBy = try (keyword_ "partition") >> > keyword_ "by" >> commaSep1 scalarExpr' > frameClause = -> mkFrame <$> (choice [FrameRows <$ keyword_ "rows" -> ,FrameRange <$ keyword_ "range"]) +> mkFrame <$> choice [FrameRows <$ keyword_ "rows" +> ,FrameRange <$ keyword_ "range"] > <*> frameStartEnd > frameStartEnd = > choice diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs index 9313bac..16be481 100644 --- a/Language/SQL/SimpleSQL/Pretty.lhs +++ b/Language/SQL/SimpleSQL/Pretty.lhs @@ -101,7 +101,7 @@ > scalarExpr (PrefixOp f e) = name f <+> scalarExpr e > scalarExpr (PostfixOp f e) = scalarExpr e <+> name f -> scalarExpr e@(BinOp _ op _) | op `elem` [(Name "and"), (Name "or")] = +> scalarExpr e@(BinOp _ op _) | op `elem` [Name "and", Name "or"] = > -- special case for and, or, get all the ands so we can vcat them > -- nicely > case ands e of diff --git a/Language/SQL/SimpleSQL/Syntax.lhs b/Language/SQL/SimpleSQL/Syntax.lhs index 3d489ef..fba7565 100644 --- a/Language/SQL/SimpleSQL/Syntax.lhs +++ b/Language/SQL/SimpleSQL/Syntax.lhs @@ -66,7 +66,7 @@ > -- order by, to regular function application > | AggregateApp > {aggName :: Name -- ^ aggregate function name -> ,aggDistinct :: (Maybe Duplicates)-- ^ distinct +> ,aggDistinct :: Maybe Duplicates -- ^ distinct > ,aggArgs :: [ScalarExpr]-- ^ args > ,aggOrderBy :: [OrderField] -- ^ order by > } diff --git a/TODO b/TODO index 7ba561e..be88d0e 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,15 @@ - next release: +add to website: pretty printed tpch, maybe other queries as + demonstration + +check haddock +reformat the source for some of the tests + +---- + +next release after that: + review tests to copy from hssqlppp collate? -> postfix operator which binds very tightly: @@ -21,8 +30,6 @@ review syntax to replace maybe and bool with better ctors ---- -add to website: pretty printed tpch, maybe other queries as - demonstration demo: convert tpch to sql server syntax exe processor ---- @@ -61,6 +68,11 @@ left factor parsing code in remaining places quasi quotes? +ast checker: checks the ast represents valid syntax, the parser + doesn't check as much as it could, and this can also be used to + check generated trees. Maybe this doesn't belong in this package + though? + = sql support proper character sets for identifiers, escapes, etc. diff --git a/tools/Language/SQL/SimpleSQL/Postgres.lhs b/tools/Language/SQL/SimpleSQL/Postgres.lhs index 78c9a94..506013c 100644 --- a/tools/Language/SQL/SimpleSQL/Postgres.lhs +++ b/tools/Language/SQL/SimpleSQL/Postgres.lhs @@ -9,7 +9,7 @@ revisited when the dialect support is added. > --import Language.SQL.SimpleSQL.Syntax > postgresTests :: TestItem -> postgresTests = Group "postgresTests" $ map ParseQueryExpr $ +> postgresTests = Group "postgresTests" $ map ParseQueryExpr lexical syntax section diff --git a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs index 5f358ba..61dd4f2 100644 --- a/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs +++ b/tools/Language/SQL/SimpleSQL/ScalarExprs.lhs @@ -227,7 +227,8 @@ Tests for parsing scalar expressions > [("count(*)",App "count" [Star]) > ,("sum(a order by a)" -> ,AggregateApp "sum" Nothing [Iden "a"] [(OrderField (Iden "a") Asc NullsOrderDefault)]) +> ,AggregateApp "sum" Nothing [Iden "a"] +> [OrderField (Iden "a") Asc NullsOrderDefault]) > ,("sum(all a)" > ,AggregateApp "sum" (Just All) [Iden "a"] []) @@ -248,11 +249,11 @@ Tests for parsing scalar expressions > ,WindowApp "max" [Iden "a"] [Iden "b",Iden "c"] [] Nothing) > ,("sum(a) over (order by b)" -> ,WindowApp "sum" [Iden "a"] [] [(OrderField (Iden "b") Asc NullsOrderDefault)] Nothing) +> ,WindowApp "sum" [Iden "a"] [] [OrderField (Iden "b") Asc NullsOrderDefault] Nothing) > ,("sum(a) over (order by b desc,c)" -> ,WindowApp "sum" [Iden "a"] [] [(OrderField (Iden "b") Desc NullsOrderDefault) -> ,(OrderField (Iden "c") Asc NullsOrderDefault)] Nothing) +> ,WindowApp "sum" [Iden "a"] [] [OrderField (Iden "b") Desc NullsOrderDefault +> ,OrderField (Iden "c") Asc NullsOrderDefault] Nothing) > ,("sum(a) over (partition by b order by c)" > ,WindowApp "sum" [Iden "a"] [Iden "b"] [OrderField (Iden "c") Asc NullsOrderDefault] Nothing)