From 9df04a3040c7b849eb1c4d82632ee7434c5da547 Mon Sep 17 00:00:00 2001
From: Jake Wheat <jakewheatmail@gmail.com>
Date: Sun, 1 Sep 2019 11:52:17 +0100
Subject: [PATCH] fix some imports and exports, particularly stop reexporting
 all the dialect stuff everywhere

---
 Language/SQL/SimpleSQL/Lex.lhs    |  2 +-
 Language/SQL/SimpleSQL/Parse.lhs  |  9 +++++----
 Language/SQL/SimpleSQL/Pretty.lhs |  7 ++++++-
 Language/SQL/SimpleSQL/Syntax.lhs |  3 ---
 tools/SimpleSqlParserTool.lhs     | 12 ++++--------
 5 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/Language/SQL/SimpleSQL/Lex.lhs b/Language/SQL/SimpleSQL/Lex.lhs
index 83eab3e..0cd940d 100644
--- a/Language/SQL/SimpleSQL/Lex.lhs
+++ b/Language/SQL/SimpleSQL/Lex.lhs
@@ -24,8 +24,8 @@ directly without the separately testing lexing stage.
 >     ,prettyToken
 >     ,prettyTokens
 >     ,ParseError(..)
->     ,Dialect(..)
 >     ,tokenListWillPrintAndLex
+>     ,ansi2011
 >     ) where
 
 > import Language.SQL.SimpleSQL.Dialect
diff --git a/Language/SQL/SimpleSQL/Parse.lhs b/Language/SQL/SimpleSQL/Parse.lhs
index 51d5047..ba5f684 100644
--- a/Language/SQL/SimpleSQL/Parse.lhs
+++ b/Language/SQL/SimpleSQL/Parse.lhs
@@ -192,20 +192,21 @@ fixing them in the syntax but leaving them till the semantic checking
 >                    ,try,many,many1,(<|>),choice,eof
 >                    ,optionMaybe,optional,runParser
 >                    ,chainl1, chainr1,(<?>))
-> -- import Text.Parsec.String (Parser)
 > import Text.Parsec.Perm (permute,(<$?>), (<|?>))
 > import Text.Parsec.Prim (getState, token)
 > import Text.Parsec.Pos (newPos)
 > import qualified Text.Parsec.Expr as E
 > import Data.List (intercalate,sort,groupBy)
 > import Data.Function (on)
+> import Data.Maybe
+> import Text.Parsec.String (GenParser)
+
 > import Language.SQL.SimpleSQL.Syntax
 > import Language.SQL.SimpleSQL.Combinators
 > import Language.SQL.SimpleSQL.Errors
-> --import Language.SQL.SimpleSQL.Dialect
+> import Language.SQL.SimpleSQL.Dialect
 > import qualified Language.SQL.SimpleSQL.Lex as L
-> import Data.Maybe
-> import Text.Parsec.String (GenParser)
+
 
 = Public API
 
diff --git a/Language/SQL/SimpleSQL/Pretty.lhs b/Language/SQL/SimpleSQL/Pretty.lhs
index 3d0e5a7..c5894dd 100644
--- a/Language/SQL/SimpleSQL/Pretty.lhs
+++ b/Language/SQL/SimpleSQL/Pretty.lhs
@@ -13,8 +13,8 @@
 
 TODO: there should be more comments in this file, especially the bits
 which have been changed to try to improve the layout of the output.
+Try to do this when this code is ported to a modern pretty printing lib.
 
-> import Language.SQL.SimpleSQL.Syntax
 > --import Language.SQL.SimpleSQL.Dialect
 > import Text.PrettyPrint (render, vcat, text, (<>), (<+>), empty, parens,
 >                          nest, Doc, punctuate, comma, sep, quotes,
@@ -22,6 +22,11 @@ which have been changed to try to improve the layout of the output.
 > import Data.Maybe (maybeToList, catMaybes)
 > import Data.List (intercalate)
 
+
+> import Language.SQL.SimpleSQL.Syntax
+> import Language.SQL.SimpleSQL.Dialect
+
+
 > -- | Convert a query expr ast to concrete syntax.
 > prettyQueryExpr :: Dialect -> QueryExpr -> String
 > prettyQueryExpr d = render . queryExpr d
diff --git a/Language/SQL/SimpleSQL/Syntax.lhs b/Language/SQL/SimpleSQL/Syntax.lhs
index 082be7c..22d61c8 100644
--- a/Language/SQL/SimpleSQL/Syntax.lhs
+++ b/Language/SQL/SimpleSQL/Syntax.lhs
@@ -57,14 +57,11 @@
 >     ,PrivilegeAction(..)
 >     ,AdminOptionFor(..)
 >     ,GrantOptionFor(..)
->      -- * Dialects
->     ,module Language.SQL.SimpleSQL.Dialect
 >      -- * Comment
 >     ,Comment(..)
 >     ) where
 
 > import Data.Data
-> import Language.SQL.SimpleSQL.Dialect
 
 > -- | Represents a value expression. This is used for the expressions
 > -- in select lists. It is also used for expressions in where, group
diff --git a/tools/SimpleSqlParserTool.lhs b/tools/SimpleSqlParserTool.lhs
index d4c9523..4e81c69 100644
--- a/tools/SimpleSqlParserTool.lhs
+++ b/tools/SimpleSqlParserTool.lhs
@@ -18,13 +18,9 @@ indent: parse then pretty print sql
 
 > import Language.SQL.SimpleSQL.Pretty
 > import Language.SQL.SimpleSQL.Parse
-> import Language.SQL.SimpleSQL.Syntax
 > import Language.SQL.SimpleSQL.Lex
 
 
-> dialect :: Dialect
-> dialect = ansi2011
-
 > main :: IO ()
 > main = do
 >     args <- getArgs
@@ -71,7 +67,7 @@ indent: parse then pretty print sql
 >       (f,src) <- getInput args
 >       either (error . peFormattedError)
 >           (putStrLn . ppShow)
->           $ parseStatements dialect f Nothing src
+>           $ parseStatements ansi2011 f Nothing src
 >   )
 
 > lexCommand :: (String,[String] -> IO ())
@@ -81,7 +77,7 @@ indent: parse then pretty print sql
 >       (f,src) <- getInput args
 >       either (error . peFormattedError)
 >              (putStrLn . intercalate ",\n" . map show)
->              $ lexSQL dialect f Nothing src
+>              $ lexSQL ansi2011 f Nothing src
 >   )
 
 
@@ -91,7 +87,7 @@ indent: parse then pretty print sql
 >   ,\args -> do
 >       (f,src) <- getInput args
 >       either (error . peFormattedError)
->           (putStrLn . prettyStatements dialect)
->           $ parseStatements dialect f Nothing src
+>           (putStrLn . prettyStatements ansi2011)
+>           $ parseStatements ansi2011 f Nothing src
 
 >   )