content: 
  
  {-# LANGUAGE TupleSections,ScopedTypeVariables,DeriveDataTypeable,OverloadedStrings #-}
  -- UUAGC 0.9.53.1 (hssqlppp/src/Database/HsSqlPpp/Internals/AstInterna)
  module Database.HsSqlPpp.Internals.AstInternal(
      --from the ag files:
      --ast nodes
      Statement (..)
     ,QueryExpr (..)
     ,WithQueryList
     ,WithQuery(..)
     ,FnBody (..)
     ,SetClause (..)
     ,SetClauseList
     ,TableRef (..)
     ,JoinExpr (..)
     ,JoinType (..)
     ,JoinHint (..)
     ,SelectList (..)
     ,SelectItem (..)
     ,CopyFromSource (..)
     ,CopyToSource(..)
     ,CopyToOption(..)
     ,CopyFromOption(..)
     ,TablePartitionDef(..)
     ,TablePartitionDateTimeInterval(..)
     ,AttributeDef (..)
     ,RowConstraint (..)
     ,TableOption(..)
     ,AlterDatabaseOperation(..)
     ,AlterTableOperation(..)
     ,AlterTableAction(..)
     ,AlterSequenceOperation(..)
     ,AlterSequenceAction(..)
     ,AlterColumnAction(..)
     ,AlterSchemaOperation(..)
     ,Constraint (..)
     ,TypeAttributeDef (..)
     ,ParamDef (..)
     ,VarDef (..)
     ,RaiseType (..)
     ,CombineType (..)
     ,Volatility (..)
     ,Language (..)
     ,TypeName (..)
     ,DropType (..)
     ,Cascade (..)
     ,Direction (..)
     ,Distinct (..)
     ,NullsOrder(..)
     ,Natural (..)
     ,IfExists (..)
     ,Replace(..)
     ,RestartIdentity (..)
     ,ScalarExpr (..)
     ,Name(..)
     ,nameComponents
     ,NameComponent(..)
     ,ncStr
     ,IntervalField(..)
     ,ExtractField(..)
     ,FrameClause(..)
     ,OdbcLiteralType(..)
     ,InList (..)
     ,LiftFlavour(..)
     ,TriggerWhen(..)
     ,TriggerEvent(..)
     ,TriggerFire(..)
     ,QueryHint(..)
     ,StatementList
     ,ScalarExprListStatementListTripleList
     ,ScalarExprListStatementListTriple
     ,ScalarExprList
     ,ParamDefList
     ,AttributeDefList
     ,ConstraintList
     ,TypeAttributeDefList
     ,TypeNameList
     ,NameTypeNameListPair
     ,NameTypeNameListPairList
     ,ScalarExprStatementListPairList
     --,SetClauseList
     ,CaseScalarExprListScalarExprPairList
     ,MaybeScalarExpr
     ,TableRefList
     ,ScalarExprListList
     ,SelectItemList
     ,OnExpr
     ,RowConstraintList
     ,VarDefList
     ,ScalarExprStatementListPair
     ,CaseScalarExprListScalarExprPair
     ,ScalarExprDirectionPair
     ,ScalarExprDirectionPairList
     ,MaybeBoolExpr
     ,MaybeSelectList
     ,SetValue(..)
     ,AlterTableActionList
     ,NameComponentList
     ,MaybeNameComponentList
     -- typechecking
     ,typeCheckStatements
     --,typeCheckParameterizedStatement
     ,typeCheckScalarExpr
     --,typeCheckScalarExprEnv
     ,typeCheckQueryExpr
     ,TypeCheckFlags(..)
     ,addExplicitCasts
     ,addImplicitCasts
     -- annotation
     ,Annotation(..)
     --,TypeExtra(..)
     ,SourcePosition
     ,ParameterizedStatementType
     ,getAnnotation
     ,updateAnnotation
     ,emptyAnnotation
     ,makeSelect
     --,canonicalizeTypeNames
  ) where
  
  --import Data.Maybe
  --import Data.Either
  --import Data.List
  --import Control.Applicative
  import Data.Data
  --import Data.Char
  --import Control.Monad.State
  --import Control.Arrow
  
  import Data.Generics
  import Data.Generics.Uniplate.Data
  --import Debug.Trace
  --import Text.Show.Pretty
  
  
  --import Database.HsSqlPpp.Internals.TypesInternal
  
  --import Database.HsSqlPpp.Internals.TypeChecking.TypeConversion
  --import Database.HsSqlPpp.Internals.TypeChecking.Environment hiding (JoinType(..))
  
  --import Database.HsSqlPpp.Internals.Catalog.CatalogInternal (NameComponent(..),ncStr)
  
  --import Database.HsSqlPpp.Utils.Utils
  --import Database.HsSqlPpp.Internals.Dialect
  --import Data.Text (Text)
  import qualified Data.Text as T
  --import qualified Data.Text.Lazy as LT
  
  -- very bad, we use types in the syntax outside of the already exception
  -- in the annotation (which can be removed when the annotation type
  -- becomes a type parameters
  -- can replace the use of type extra with (typename,int,int) triple
  -- to fix this
  --import Database.HsSqlPpp.Internals.TypesInternal (TypeExtra)
  
  
  
  {-# LINE 2 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
  
  import Data.Text (Text)
  import qualified Database.HsSqlPpp.Internals.TypeChecking.Environment as E
  import Database.HsSqlPpp.Internals.TypeChecking.Environment (Environment)
  import Database.HsSqlPpp.Internals.TypesInternal
  import Database.HsSqlPpp.Internals.Dialect
  import Database.HsSqlPpp.Internals.Catalog.CatalogInternal
  import Database.HsSqlPpp.Internals.Catalog.CatalogTypes
  import Database.HsSqlPpp.Internals.Catalog.CatalogBuilder
  import Database.HsSqlPpp.Internals.TypeChecking.TypeConversion.TypeConversion
  
  -- todo: find a better way to do this, this information should come
  -- via the dialect or catalog in the attributes
  import Database.HsSqlPpp.Dialects.OdbcCatalog
  
  import Control.Monad
  import Data.List
  import Data.Maybe
  import Data.Char
  import Text.Read
  import Control.Applicative
  {-# LINE 182 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 14 "hssqlppp/src/Database/HsSqlPpp/Internals/Annotation.ag" #-}
  
  import qualified Database.HsSqlPpp.Internals.TypesInternal as T
  import qualified Database.HsSqlPpp.Internals.Catalog.CatalogTypes as C
  
  {-# LINE 189 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  {-# LINE 76 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
  
  -- todo: replace the other nmcString function with this one
  -- which uses either instead of error
  xnmcString :: NameComponent -> Either [TypeError] Text
  xnmcString (QNmc n) = Right $ T.pack n
  xnmcString (Nmc n) = Right $ T.pack $ map toLower n
  xnmcString (AntiNameComponent _) = Left [InternalError "tried to get nmc string from antinamecomponent"]
  {-# LINE 198 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 197 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
  
  splitTypeExtraList:: Maybe [TypeExtra] -> Maybe (TypeExtra,[TypeExtra])
  splitTypeExtraList mte = mte >>= f
    where
      f [] = Nothing
      f (et:ets') = Just (et,ets')
  {-# LINE 207 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 218 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
  
  
  -- | thet name to choose for a column in a select list which doesn't
  -- have an explicit name - these are postgresql's rules
  columnName :: ScalarExpr -> NameComponent
  columnName (Identifier _ i) = last $ nameComponents i
  columnName (App _ (Name _ ncs) _) = last ncs
  columnName (Cast _ _ (SimpleTypeName _ (Name _ ncs))) = last ncs
  columnName (ImplicitCast _ e _) = columnName e
  columnName (WindowApp _ (App _ (Name _ ncs) _) _ _ _) = last ncs
  columnName (AggregateApp _ _ (App _ (Name _ ncs) _) _) = last ncs
  columnName _ = QNmc "?column?"
  {-# LINE 222 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 160 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
  
  convertJoinType:: JoinType -> E.JoinType
  convertJoinType LeftOuter = E.LeftOuter
  convertJoinType RightOuter = E.RightOuter
  convertJoinType FullOuter = E.FullOuter
  convertJoinType _ = E.Inner
  {-# LINE 231 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 82 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
  
  secondM :: Functor f => (t -> f a) -> (t1, t) -> f (t1, a)
  secondM f (a,b) = (a,) <$> f b
  {-# LINE 237 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 47 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
  
  needsImplicitCast:: Bool -> TypeExtra -> TypeExtra -> Bool
  needsImplicitCast expectedCast upType expType
      = tePrecision upType /= tePrecision expType
        || teScale upType /= teScale expType
        || teNullable upType /= teNullable expType
            && nullabilityCast
        ||  teType upType /= teType expType
            && (not . null) (nub [teType upType, teType expType] \\ [ScalarType "varchar", ScalarType "text",ScalarType "nvarchar"])
    where
      nullabilityCast = expectedCast
  -- this function appeared because nullability does not always influence the type to cast to
  implicitCastType:: Bool -> TypeExtra -> TypeExtra -> TypeExtra
  implicitCastType expectedCast upType expType
      = expType{tePrecision = precision, teScale = scale, teNullable = nullability}
    where
      nullabilityCast = expectedCast
      nullabilitySource = if nullabilityCast then expType else upType
      precisionSource = expType
      nullability = teNullable nullabilitySource
      precision = tePrecision precisionSource
      scale = teScale precisionSource
  {-# LINE 262 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 513 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
  
  getMaybeIntsFromLiterals :: [ScalarExpr] -> MatchAppLiteralList
  getMaybeIntsFromLiterals sel = map extractor sel
    where
     extractor :: ScalarExpr -> Maybe Int
     extractor (NumberLit _ s) = readMaybe s :: Maybe Int
     extractor _ = Nothing
  {-# LINE 272 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 796 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
  
  classifyInteger :: Dialect -> String -> Either [TypeError] Text
  classifyInteger d s = maybe (Left []) Right $ case (readMaybe s :: Maybe Integer) of
                        -- assuming number literals are always positive
                        Just n | n < (2 ^ (31 :: Integer)) -> ansiTypeNameToDialect d "int"
                               | n < (2 ^ (63 :: Integer)) -> ansiTypeNameToDialect d "bigint"
                        _ -> ansiTypeNameToDialect d "numeric"
  {-# LINE 282 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 26 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
  
  
  -- | some options when typechecking
  data TypeCheckFlags =
      TypeCheckFlags
      { -- | add qualifiers to unqualified ids where possible
       tcfAddQualifiers :: Bool
       -- | add full aliases to every tableref and subselect
      ,tcfAddFullTablerefAliases :: Bool
       -- | add explicit aliases to all select items
      ,tcfAddSelectItemAliases :: Bool
       -- | expand stars in select lists to explicit list columns
      ,tcfExpandStars :: Bool
      ,tcfDialect :: Dialect}
      deriving (Show,Eq)
  
  -- | Typechecks the ast, and returns the updated catalog (which
  -- includes changes from any ddl statements in the ast).
  typeCheckStatements :: TypeCheckFlags -> Catalog -> [Statement] -> (Catalog,[Statement])
  typeCheckStatements f cat sts =
      let t = _sem_Root (Root sts)
          ta = _wrap_Root t Inh_Root {_cat_Inh_Root = cat
                                    ,_flags_Inh_Root = f
                                    {-,_lib_Inh_Root = emptyBindings
                                    ,_idenv_Inh_Root = emptyIDEnv "tcs"-}}
          tl = _annotatedTree_Syn_Root ta
          cat1 = cat --_producedCat_Syn_Root ta
      in case tl of
           Root r -> (cat1,fixTree (tcfDialect f) r)
  -- | Typecheck a query expr
  typeCheckQueryExpr :: TypeCheckFlags -> Catalog -> QueryExpr -> QueryExpr
  typeCheckQueryExpr f cat qe =
     let (_,[QueryStatement _ qe']) = typeCheckStatements f cat [QueryStatement emptyAnnotation qe]
     in qe'
  
  -- | Not working yet. Typechecks a statement possibly containing ?
  -- placeholders. These are annotated with the 'inferred type', and the
  -- stType annotation on the return value can be used to get this info
  -- easily. Returns Left if the statement is not a query,insert,update or delete
  -- statement
  {-typeCheckParameterizedStatement :: TypeCheckFlags -> Catalog -> Statement -> Either String Statement
  typeCheckParameterizedStatement f cat st =
      case st of
        QueryStatement _ _ -> tc
        Insert _ _ _ _ _ -> tc
        Update _ _ _ _ _ _ -> tc
        Delete _ _ _ _ _ -> tc
        _ -> Left "requires select, update, insert or delete statement"
      where
        tc = let tl = typeCheckStatements f cat [st]
             in case tl of
                  (_,[st1]) -> Right st1
                  _ -> error "impossible happened in typeCheckPS!"
  -}
  {-
  -- | type check a scalar expr
  typeCheckScalarExpr :: TypeCheckFlags -> Catalog -> ScalarExpr -> ScalarExpr
  typeCheckScalarExpr f cat ex =
      let t = _sem_ScalarExprRoot (ScalarExprRoot ex)
          rt = (_annotatedTree_Syn_ScalarExprRoot
                (_wrap_ScalarExprRoot t Inh_ScalarExprRoot {_cat_Inh_ScalarExprRoot = cat
                                                          ,_flags_Inh_ScalarExprRoot = f
                                                          ,_downEnv_Inh_ScalarExprRoot = E.emptyEnvironment
                                                          {-,_lib_Inh_ScalarExprRoot = emptyBindings
                                                          ,_idenv_Inh_ScalarExprRoot = emptyIDEnv "t
  cse"-}}))
      in case rt of
           ScalarExprRoot e -> fixTree e -}
  
  typeCheckScalarExpr ::  TypeCheckFlags -> Catalog -> Environment
                            -> ScalarExpr -> ScalarExpr
  typeCheckScalarExpr f cat env ex =
      let t = _sem_ScalarExprRoot (ScalarExprRoot ex)
          rt = _annotatedTree_Syn_ScalarExprRoot
                  $ _wrap_ScalarExprRoot t
                      Inh_ScalarExprRoot{_cat_Inh_ScalarExprRoot = cat
                                        ,_flags_Inh_ScalarExprRoot = f
                                        ,_downEnv_Inh_ScalarExprRoot = env}
      in case rt of
           ScalarExprRoot e -> fixTree (tcfDialect f) e
  
  {-# LINE 366 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 158 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
  
  
  -- | run on a typechecked tree. Finds all the places where an implicit
  -- cast has been used in the typechecking and inserts an explicit cast
  addExplicitCasts :: Data a => a -> a
  addExplicitCasts = transformBi removeDoubleCasts . transformBi addCast
    where
      addCast :: ScalarExpr -> ScalarExpr
      addCast e = fromMaybe e $ do
                    t <- anImplicitCast (getAnnotation e)
                    n <- nameOfType $ teType t
                    return $ Cast emptyAnnotation e n
      -- addCast isn't very smart, so remove any unneeded casts
      -- that it has inserted. Only do this when have two
      -- nested casts which cast to the same type, so this
      -- shouldn't cause problems with sane sql
      removeDoubleCasts :: ScalarExpr -> ScalarExpr
      removeDoubleCasts e = case e of
        (Cast a (Cast _ e' t1) t)
           | resetAnnotations t1 == resetAnnotations t -> Cast a e' t
        e' -> e'
      resetAnnotations = transformBi (const emptyAnnotation)
  -- | variation of the above, which uses ImplicitCast ctor
  addImplicitCasts :: Data a => Catalog -> a -> a
  addImplicitCasts cat = transformBi removeDoubleCasts . transformBi addCast
    where
      addCast:: ScalarExpr -> ScalarExpr
      addCast e = fromMaybe e $ do
                    te <- anImplicitCast ann'
                    -- ImplicitCastToDo: why anImplicitCast is not Nothing above Star
                    _ <- nameOfType $ teType te -- in order to preserve the old logic
                    -- guard $ isCastable e $ teType te
                    guard $ anType ann' /= Just te
                    return $ ImplicitCast emptyAnnotation e te
        where
          _isCastable:: ScalarExpr -> Type -> Bool
          _isCastable e' to = fromMaybe False $ do
              from <- liftM teType $ anType $ getAnnotation e'
              either  (const $ if from == UnknownType then Just True else Nothing) Just
                      $ catCast cat ImplicitCastContext from to
          ann' = getAnnotation e
      removeDoubleCasts:: ScalarExpr -> ScalarExpr
      removeDoubleCasts e = fst $ accumulateCasts e
      -- For each implicit cast, if there is a sequence of implicit casts right under it,
      --    that remained after bottom-up application of the algorithm being described:
      --  1. Check if there is a type in the sequence (of argument types of implicit casts),
      --      which is implicitly castable to the target type of the current implicit cast,
      --      according to the current catalog.
      --  2. If there is such a type, replace a sequence of casts that starts at this type with
      --      a single cast, and shorten the list of casts to be further investigated (snd of
      --      output type of this function).
      --    2.1. Analyze the list bottom-up, so that the longest possible sequence of casts is
      --      replaced.
      --  3. If there is no such a type, just add the current cast to the list.
      -- Reset the list on a node other than ImplicitCast.
      accumulateCasts:: ScalarExpr -> (ScalarExpr,[(ScalarExpr,Type)])
      accumulateCasts e = case e of
          ImplicitCast a e' te
            ->  let (e1,ets) = accumulateCasts e'
                    eStart = ImplicitCast a e1 te
                    isCastable (_,t) = either (const False) id
                        $ catCast cat ImplicitCastContext t $ teType te
                    f z xs = case dropWhile (not . isCastable) xs of
                        [] -> z
                        xs'@((e'',_):rest) -> f (ImplicitCast a e'' te, xs') rest
                in case anType $ getAnnotation e1 of
                      Nothing -> (eStart,[]) -- cut here (should not happen in practice)
                      Just te1 -> f (eStart, (e1, teType te1):ets) ets
          _ -> (e,[])
  
  nameOfType :: Type -> Maybe TypeName
  nameOfType (ScalarType t) = Just $ SimpleTypeName emptyAnnotation (Name emptyAnnotation [Nmc $ T.unpack t])
  -- a hack to support precision cast from string literals
  nameOfType UnknownType = Just $ SimpleTypeName emptyAnnotation (Name emptyAnnotation [Nmc "unknown"])
  nameOfType (DomainType t) = Just $ SimpleTypeName emptyAnnotation (Name emptyAnnotation [Nmc $ T.unpack t])
  nameOfType (EnumType t) = Just $ SimpleTypeName emptyAnnotation (Name emptyAnnotation [Nmc $ T.unpack t])
  nameOfType (NamedCompositeType t) = Just $ SimpleTypeName emptyAnnotation (Name emptyAnnotation [Nmc $ T.unpack t])
  nameOfType _ = Nothing
  
  -- hack for various fixups
  fixTree :: Data a => Dialect -> a -> a
  fixTree = fixMssqlDates
  
  {-
  
  
  disgusting hack to fix up datediff,datepart, convert and other
  functions which accept a fixed list of keywords for one or more of the
  arguments for sql server: set the type for the first argument to type
  in if it is in the acceptable list.
  
  This is really bad. What happens is that the normal typechecker will
  check the keyword as an identifier and (usually!) put in unknown
  identifier error. Then, when the function is typechecked, it will
  ignore the type for this argument. After we've finished, the type
  error is replaced with int type here.
  
  The proper fix:
  
  I think a good way to look at these is to consider them fixed enums
  which can only accept a literal (and not an enum valued
  expression). We set a flag/enum thing in the typecheck environment of
  the identifier, so that it can check the identifier fits one of the
  valid functions in the identifier itself. Then, there doesn't need to
  be a fix here, and typechecking the function should work without a
  hack here too. The typechecking of the function itself still needs
  some special casing (e.g. for the convert function in odbc (and
  similar in regular sql server syntax), the result type depends on the
  value of the 'enum'. This can be implemented in a similar way to the
  literal ints being passed to the function type checker.
  
  This will be fixed with the rewrite of the findcallmatch/matchapp/a
  million different fns for precision and nullability/tcApplike mess.
  
  -}
  
  fixMssqlDates :: Data a => Dialect -> a -> a
  fixMssqlDates d = transformBi $ \x -> case x of
    App aa nm@(Name _ [Nmc fn]) [Identifier ai tn@(Name _ [Nmc tnn]),a,b]
      | map toLower fn `elem` ["datediff","dateadd"]
      , map toLower tnn `elem` dateparts ->
        App aa nm [Identifier (nai ai) tn,a,b]
    App aa nm@(Name _ [Nmc fn]) [Identifier ai tn@(Name _ [Nmc tnn]),a]
      | map toLower fn == "datepart"
      , map toLower tnn `elem` dateparts ->
        App aa nm [Identifier (nai ai) tn,a]
    App aa nm@(Name _ [Nmc fn]) [a,Identifier ai tn@(Name _ [Nmc tnn])]
      | map toLower fn == "convert"
      , map toLower tnn `elem` map fst odbcConvertTypes ->
        App aa nm [a,Identifier (nai ai) tn]
    App aa nm@(Name _ [Nmc fn]) (Identifier ai tn@(Name _ [Nmc tnn]):as)
      | map toLower fn `elem` ["timestampadd","timestampdiff"]
      , map toLower tnn `elem` odbcIntervalTypes ->
        App aa nm (Identifier (nai ai) tn:as)
    x' -> x'
    where
        dateparts :: [String]
        dateparts = ["day","dd","d","month","mm","m","year","yyyy"
                    ,"yy","quarter","qq","q","dayofyear","doy","dy","y"
                    ,"weekday","dw","week","ww","wk","hour","hh"
                    ,"minute","mi","n","second","ss","s","millisecond","ms"
                    ,"microsecond","mcs","nanosecond","ns"]
        -- todo: use canonical tsql name for typeInt
        nai ai = ai {anType = (mkTypeExtraNN . ScalarType) <$> ansiTypeNameToDialect d "int"
                    ,anErrs = []}
  
  
  -- temp utility function
  
  {-canonicalizeType :: Dialect -> Type -> Type
  canonicalizeType d (ScalarType t) = ScalarType $ canonicalizeTypeName d t
  canonicalizeType _ t = t-}
  
  {-# LINE 522 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 20 "hssqlppp/src/Database/HsSqlPpp/Internals/Annotation.ag" #-}
  
  -- | Represents a source file position, usually set by the parser.
  type SourcePosition = (FilePath,Int,Int)
  
  -- | Statement type is used for getting type information for a
  -- parameterized statement. The first part is the args that the
  -- parameterized statement needs, and the second is the names and types
  -- of the output columns. No way to signal that a statement returns
  -- exactly one row at the moment
  type ParameterizedStatementType = ([T.Type],[(String,T.Type)])
  
  {-# LINE 536 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 52 "hssqlppp/src/Database/HsSqlPpp/Internals/Annotation.ag" #-}
  
  
  --some simple wrappers around uniplate for internal use. I'm not sure
  --which of these are actually used
  
  -- | An annotation value with no information.
  emptyAnnotation :: Annotation
  emptyAnnotation = Annotation Nothing Nothing [] Nothing []
  
  -- | get the annotation for the root element of the tree passed
  getAnnotation :: Data a => a -> Annotation
  getAnnotation = head . childrenBi
  
  --don't know how to do this one with uniplate
  
  -- | Update the first annotation in a tree using the function supplied
  updateAnnotation :: Data a => (Annotation -> Annotation) -> a -> a
  updateAnnotation f = gmapT (mkT f)
  
  {-# LINE 558 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 519 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  nameComponents :: Name -> [NameComponent]
  nameComponents (Name _ is) = is
  -- todo: don't use error
  nameComponents (AntiName _) = error "tried to get namecomponents of antiname"
  {-# LINE 566 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  
  
  data LiftFlavour = LiftAny | LiftAll
                     deriving (Show,Eq,Typeable,Data)
  
  data Direction = Asc | Desc
                   deriving (Show,Eq,Typeable,Data)
  
  data NullsOrder = NullsDefault | NullsFirst | NullsLast
                   deriving (Show,Eq,Typeable,Data)
  
  data Distinct = Distinct | All
                  deriving (Show,Eq,Typeable,Data)
  
  -- maybe should improve this, since you can have at least union
  -- distinct and union all just like select distinct and select all
  
  data CombineType = Except | Union | Intersect | UnionAll
                     deriving (Show,Eq,Typeable,Data)
  
  data IntervalField = IntervalYear
                     | IntervalMonth
                     | IntervalDay
                     | IntervalHour
                     | IntervalMinute
                     | IntervalSecond
                     | IntervalYearToMonth
                     | IntervalDayToHour
                     | IntervalDayToMinute
                     | IntervalDayToSecond
                     | IntervalHourToMinute
                     | IntervalHourToSecond
                     | IntervalMinuteToSecond
                       deriving (Show,Eq,Typeable,Data)
  
  data ExtractField = ExtractCentury
                    | ExtractDay
                    | ExtractDecade
                    | ExtractDow
                    | ExtractDoy
                    | ExtractEpoch
                    | ExtractHour
                    | ExtractIsodow
                    | ExtractIsoyear
                    | ExtractMicroseconds
                    | ExtractMillennium
                    | ExtractMilliseconds
                    | ExtractMinute
                    | ExtractMonth
                    | ExtractQuarter
                    | ExtractSecond
                    | ExtractTimezone
                    | ExtractTimezoneHour
                    | ExtractTimezoneMinute
                    | ExtractWeek
                    | ExtractYear
                      deriving (Show,Eq,Typeable,Data)
  
  -- todo: this needs fixing, it is currently based on limited frame options
  data FrameClause = FrameUnboundedPreceding
                   | FrameUnboundedFull
                   | FrameRowsUnboundedPreceding
                     deriving (Show,Eq,Typeable,Data)
  
  
  data OdbcLiteralType = OLDate
                       | OLTime
                       | OLTimestamp
                         deriving (Show,Eq,Typeable,Data)
  {-# LINE 639 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 693 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data JoinType = Inner | LeftOuter| RightOuter | FullOuter | Cross
                  deriving (Show,Eq,Typeable,Data)
  data JoinHint = Loop | Hash | Merge
                  deriving (Show,Eq,Typeable,Data)
  data Natural = Natural | Unnatural
                 deriving (Show,Eq,Typeable,Data)
  {-# LINE 649 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 711 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  -- | 'default' valued select, use for creating select values
  --
  -- > makeSelect :: QueryExpr
  -- > makeSelect = Select
  -- >              {ann = emptyAnnotation
  -- >              ,selDistinct = All
  -- >              ,selSelectList = (SelectList emptyAnnotation [])
  -- >              ,selTref = []
  -- >              ,selWhere = Nothing
  -- >              ,selGroupBy = []
  -- >              ,selHaving = Nothing
  -- >              ,selOrderBy = []
  -- >              ,selLimit = Nothing
  -- >              ,selOffset = Nothing
  -- >              ,selOption = []}
  --
  -- On its own, it isn't valid syntax: to use it you have to replace
  -- the select list at minimum
  --
  -- use something like this
  --
  -- > s = makeSelect {selSelectList = sl [se $ i "a"]
  -- >                ,selTref = [tref "t"]}
  -- >     where
  -- >         a = emptyAnnotation
  -- >         sl = SelectList a
  -- >         se = SelExp a
  -- >         i = Identifier a
  -- >         tref t = Tref a (Name a [Nmc t])
  
  makeSelect :: QueryExpr
  makeSelect = Select
               {ann = emptyAnnotation
               ,selDistinct = All
               ,selSelectList = (SelectList emptyAnnotation [])
               ,selTref = []
               ,selWhere = Nothing
               ,selGroupBy = []
               ,selHaving = Nothing
               ,selOrderBy = []
               ,selLimit = Nothing
               ,selOffset = Nothing
               ,selOption = []}
  {-# LINE 696 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1021 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data CopyFromSource = CopyFilename String
                      | Stdin
                        deriving (Show,Eq,Typeable,Data)
  data CopyToSource = CopyTable Name [NameComponent]
                    | CopyQuery QueryExpr
                      deriving (Show,Eq,Typeable,Data)
  
  data CopyFromOption = CopyFromFormat String
                      | CopyFromDelimiter String
                      | CopyFromErrorLog String
                      | CopyFromErrorVerbosity Int
                      | CopyFromParsers String
                      | CopyFromDirectory
                      | CopyFromOffset Integer
                      | CopyFromLimit Integer
                      | CopyFromErrorThreshold Int
                      | CopyFromNewlineFormat String
                    deriving (Show,Eq,Typeable,Data)
  
  data CopyToOption = CopyToFormat String
                    | CopyToDelimiter String
                    | CopyToErrorLog String
                    | CopyToErrorVerbosity Int
                    deriving (Show,Eq,Typeable,Data)
  
  {-# LINE 725 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data TableOption =
         TableOptionStringVal [String] String
       | TableOptionNameVal [String] [Name]
       | TableOptionNumberVal [String] String
       | TableOptionKeywords [String]
         deriving (Show,Eq,Typeable,Data)
  
  {-# LINE 736 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1122 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data TablePartitionDateTimeInterval = Year | Month | Day | Hour | Minute | Second | Millisecond
                                   deriving (Show,Eq,Typeable,Data)
  {-# LINE 742 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1185 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data SetValue
      = SetStr Annotation String
      | SetId Annotation String
      | SetNum Annotation Double
        deriving (Show,Eq,Typeable,Data)
  
  
  data TriggerWhen = TriggerBefore | TriggerAfter
                     deriving (Show,Eq,Typeable,Data)
  data TriggerEvent = TInsert| TUpdate | TDelete | AntiTriggerEvent String
                      deriving (Show,Eq,Typeable,Data)
  data TriggerFire = EachRow | EachStatement
                     deriving (Show,Eq,Typeable,Data)
  
  data DropType = Table
                | Domain
                | View
                | Type
                | Database
                | User
                | Login
                | Schema
                  deriving (Show,Eq,Typeable,Data)
  
  data Cascade = Cascade | Restrict
                 deriving (Show,Eq,Typeable,Data)
  
  
  
  data IfExists = Require | IfExists
                  deriving (Show,Eq,Typeable,Data)
  
  
  data RestartIdentity = RestartIdentity | ContinueIdentity
                         deriving (Show,Eq,Typeable,Data)
  
  {-# LINE 782 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1228 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data Replace = Replace | NoReplace
                 deriving (Show,Eq,Typeable,Data)
  
  data Volatility = Volatile | Stable | Immutable
                    deriving (Show,Eq,Typeable,Data)
  
  -- todo: fix the fn body to support to support other languages
  -- just as as string for now
  -- probably change Language to be a string also
  
  data Language = Sql | Plpgsql
                  deriving (Show,Eq,Typeable,Data)
  {-# LINE 798 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1267 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data RaiseType = RNotice | RException | RError
                   deriving (Show,Eq,Typeable,Data)
  
  {-# LINE 805 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1281 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  data QueryHint = QueryHintPartitionGroup | QueryHintColumnarHostGroup
                   deriving (Show,Eq,Typeable,Data)
  
  {-# LINE 812 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  
  {-# LINE 1387 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.ag" #-}
  
  -- TODO: move this somewhere better
  -- | run canonicalizeTypeName on all the TypeName nodes in an ast
  {-canonicalizeTypeNames :: Data a => Dialect -> a -> a
  canonicalizeTypeNames d =
     (transformBi $ \x ->
         case x of
           ScalarType s -> ScalarType $ canonicalizeTypeName d s
           x' -> x')
     . (transformBi $ \x ->
         case x of
           SimpleTypeName a tn -> SimpleTypeName a (c tn)
           PrecTypeName a tn i -> PrecTypeName a (c tn) i
           Prec2TypeName a tn i i1 -> Prec2TypeName a (c tn) i i1
           x' -> x')
     where
       c (Name a [Nmc nc]) = Name a [Nmc $ T.unpack $ canonicalizeTypeName d $ T.pack nc]
       c z = z-}
  
  {-# LINE 834 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
  -- AlterColumnAction -------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterColumnAction 
           originalTree         : AlterColumnAction 
     alternatives:
        alternative SetDataType:
           child ann            : Annotation 
           child typ            : TypeName 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative SetNotNull:
           child ann            : Annotation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DropNotNull:
           child ann            : Annotation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative SetDefault:
           child ann            : Annotation 
           child def            : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DropDefault:
           child ann            : Annotation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterColumnAction = SetDataType (Annotation) (TypeName)
                         | SetNotNull (Annotation)
                         | DropNotNull (Annotation)
                         | SetDefault (Annotation) (ScalarExpr)
                         | DropDefault (Annotation)
                         deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterColumnAction :: AlterColumnAction ->
                           T_AlterColumnAction
  _sem_AlterColumnAction (SetDataType _ann _typ) =
      (_sem_AlterColumnAction_SetDataType (_sem_Annotation _ann) (_sem_TypeName _typ))
  _sem_AlterColumnAction (SetNotNull _ann) =
      (_sem_AlterColumnAction_SetNotNull (_sem_Annotation _ann))
  _sem_AlterColumnAction (DropNotNull _ann) =
      (_sem_AlterColumnAction_DropNotNull (_sem_Annotation _ann))
  _sem_AlterColumnAction (SetDefault _ann _def) =
      (_sem_AlterColumnAction_SetDefault (_sem_Annotation _ann) (_sem_ScalarExpr _def))
  _sem_AlterColumnAction (DropDefault _ann) =
      (_sem_AlterColumnAction_DropDefault (_sem_Annotation _ann))
  -- semantic domain
  type T_AlterColumnAction = Catalog ->
                             TypeCheckFlags ->
                             (Maybe TypeExtra) ->
                             ( AlterColumnAction,AlterColumnAction)
  data Inh_AlterColumnAction = Inh_AlterColumnAction {_cat_Inh_AlterColumnAction :: Catalog,_flags_Inh_AlterColumnAction :: TypeCheckFlags,_imCast_Inh_AlterColumnAction :: (Maybe TypeExtra)}
  data Syn_AlterColumnAction = Syn_AlterColumnAction {_annotatedTree_Syn_AlterColumnAction :: AlterColumnAction,_originalTree_Syn_AlterColumnAction :: AlterColumnAction}
  _wrap_AlterColumnAction :: T_AlterColumnAction ->
                            Inh_AlterColumnAction ->
                            Syn_AlterColumnAction
  _wrap_AlterColumnAction sem (Inh_AlterColumnAction _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterColumnAction _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterColumnAction_SetDataType :: T_Annotation ->
                                       T_TypeName ->
                                       T_AlterColumnAction
  _sem_AlterColumnAction_SetDataType ann_ typ_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterColumnAction
                _lhsOoriginalTree :: AlterColumnAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 24, column 37)
                _annOtpe =
                    ({-# LINE 24 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 931 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetDataType _annIannotatedTree _typIannotatedTree
                     {-# LINE 937 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetDataType _annIoriginalTree _typIoriginalTree
                     {-# LINE 943 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 949 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 955 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 961 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 967 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 973 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 979 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 985 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 991 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterColumnAction_SetNotNull :: T_Annotation ->
                                      T_AlterColumnAction
  _sem_AlterColumnAction_SetNotNull ann_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterColumnAction
                _lhsOoriginalTree :: AlterColumnAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 29, column 36)
                _annOtpe =
                    ({-# LINE 29 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1016 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetNotNull _annIannotatedTree
                     {-# LINE 1022 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetNotNull _annIoriginalTree
                     {-# LINE 1028 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1034 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1040 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1046 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1052 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1058 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterColumnAction_DropNotNull :: T_Annotation ->
                                       T_AlterColumnAction
  _sem_AlterColumnAction_DropNotNull ann_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterColumnAction
                _lhsOoriginalTree :: AlterColumnAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 23, column 37)
                _annOtpe =
                    ({-# LINE 23 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1081 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropNotNull _annIannotatedTree
                     {-# LINE 1087 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropNotNull _annIoriginalTree
                     {-# LINE 1093 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterColumnAction_SetDefault :: T_Annotation ->
                                      T_ScalarExpr ->
                                      T_AlterColumnAction
  _sem_AlterColumnAction_SetDefault ann_ def_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _defOdownEnv :: Environment
                _defOexpectedCast :: Bool
                _defOexpectedType :: (Maybe TypeExtra)
                _defOodbcFunction :: Bool
                _defOassignmentCastContext :: Bool
                _lhsOannotatedTree :: AlterColumnAction
                _lhsOoriginalTree :: AlterColumnAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _defOcat :: Catalog
                _defOflags :: TypeCheckFlags
                _defOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _defIannotatedTree :: ScalarExpr
                _defIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _defIoriginalTree :: ScalarExpr
                _defIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 25, column 36)
                _annOtpe =
                    ({-# LINE 25 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1159 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 26, column 36)
                _defOdownEnv =
                    ({-# LINE 26 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 1165 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 27, column 36)
                _defOexpectedCast =
                    ({-# LINE 27 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 1171 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 28, column 36)
                _defOexpectedType =
                    ({-# LINE 28 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 1177 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 131, column 18)
                _defOodbcFunction =
                    ({-# LINE 131 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 1183 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 807, column 36)
                _defOassignmentCastContext =
                    ({-# LINE 807 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 1189 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetDefault _annIannotatedTree _defIannotatedTree
                     {-# LINE 1195 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetDefault _annIoriginalTree _defIoriginalTree
                     {-# LINE 1201 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1207 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1213 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1219 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1225 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1231 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _defOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1237 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _defOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1243 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _defOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1249 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _defIannotatedTree,_defIcolExprs,_defIoriginalTree,_defIupType) =
                    def_ _defOassignmentCastContext _defOcat _defOdownEnv _defOexpectedCast _defOexpectedType _defOflags _defOimCast _defOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterColumnAction_DropDefault :: T_Annotation ->
                                       T_AlterColumnAction
  _sem_AlterColumnAction_DropDefault ann_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterColumnAction
                _lhsOoriginalTree :: AlterColumnAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 22, column 37)
                _annOtpe =
                    ({-# LINE 22 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1274 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropDefault _annIannotatedTree
                     {-# LINE 1280 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropDefault _annIoriginalTree
                     {-# LINE 1286 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1292 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1298 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1304 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1310 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1316 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterDatabaseOperation --------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterDatabaseOperation 
           originalTree         : AlterDatabaseOperation 
     alternatives:
        alternative RenameDatabase:
           child ann            : Annotation 
           child newName        : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterDatabaseOperation = RenameDatabase (Annotation) (Name)
                              deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterDatabaseOperation :: AlterDatabaseOperation ->
                                T_AlterDatabaseOperation
  _sem_AlterDatabaseOperation (RenameDatabase _ann _newName) =
      (_sem_AlterDatabaseOperation_RenameDatabase (_sem_Annotation _ann) (_sem_Name _newName))
  -- semantic domain
  type T_AlterDatabaseOperation = Catalog ->
                                  TypeCheckFlags ->
                                  (Maybe TypeExtra) ->
                                  ( AlterDatabaseOperation,AlterDatabaseOperation)
  data Inh_AlterDatabaseOperation = Inh_AlterDatabaseOperation {_cat_Inh_AlterDatabaseOperation :: Catalog,_flags_Inh_AlterDatabaseOperation :: TypeCheckFlags,_imCast_Inh_AlterDatabaseOperation :: (Maybe TypeExtra)}
  data Syn_AlterDatabaseOperation = Syn_AlterDatabaseOperation {_annotatedTree_Syn_AlterDatabaseOperation :: AlterDatabaseOperation,_originalTree_Syn_AlterDatabaseOperation :: AlterDatabaseOperation}
  _wrap_AlterDatabaseOperation :: T_AlterDatabaseOperation ->
                                 Inh_AlterDatabaseOperation ->
                                 Syn_AlterDatabaseOperation
  _wrap_AlterDatabaseOperation sem (Inh_AlterDatabaseOperation _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterDatabaseOperation _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterDatabaseOperation_RenameDatabase :: T_Annotation ->
                                               T_Name ->
                                               T_AlterDatabaseOperation
  _sem_AlterDatabaseOperation_RenameDatabase ann_ newName_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _newNameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterDatabaseOperation
                _lhsOoriginalTree :: AlterDatabaseOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _newNameOcat :: Catalog
                _newNameOflags :: TypeCheckFlags
                _newNameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _newNameIannotatedTree :: Name
                _newNameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 30, column 45)
                _annOtpe =
                    ({-# LINE 30 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1384 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 31, column 45)
                _newNameOtpe =
                    ({-# LINE 31 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1390 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RenameDatabase _annIannotatedTree _newNameIannotatedTree
                     {-# LINE 1396 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RenameDatabase _annIoriginalTree _newNameIoriginalTree
                     {-# LINE 1402 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1408 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1414 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1420 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1426 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1432 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1438 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1444 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1450 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _newNameIannotatedTree,_newNameIoriginalTree) =
                    newName_ _newNameOcat _newNameOflags _newNameOimCast _newNameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterSchemaOperation ----------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterSchemaOperation 
           originalTree         : AlterSchemaOperation 
     alternatives:
        alternative AlterSchemaName:
           child ann            : Annotation 
           child newName        : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSchemaOwner:
           child ann            : Annotation 
           child newName        : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterSchemaOperation = AlterSchemaName (Annotation) (Name)
                            | AlterSchemaOwner (Annotation) (Name)
                            deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterSchemaOperation :: AlterSchemaOperation ->
                              T_AlterSchemaOperation
  _sem_AlterSchemaOperation (AlterSchemaName _ann _newName) =
      (_sem_AlterSchemaOperation_AlterSchemaName (_sem_Annotation _ann) (_sem_Name _newName))
  _sem_AlterSchemaOperation (AlterSchemaOwner _ann _newName) =
      (_sem_AlterSchemaOperation_AlterSchemaOwner (_sem_Annotation _ann) (_sem_Name _newName))
  -- semantic domain
  type T_AlterSchemaOperation = Catalog ->
                                TypeCheckFlags ->
                                (Maybe TypeExtra) ->
                                ( AlterSchemaOperation,AlterSchemaOperation)
  data Inh_AlterSchemaOperation = Inh_AlterSchemaOperation {_cat_Inh_AlterSchemaOperation :: Catalog,_flags_Inh_AlterSchemaOperation :: TypeCheckFlags,_imCast_Inh_AlterSchemaOperation :: (Maybe TypeExtra)}
  data Syn_AlterSchemaOperation = Syn_AlterSchemaOperation {_annotatedTree_Syn_AlterSchemaOperation :: AlterSchemaOperation,_originalTree_Syn_AlterSchemaOperation :: AlterSchemaOperation}
  _wrap_AlterSchemaOperation :: T_AlterSchemaOperation ->
                               Inh_AlterSchemaOperation ->
                               Syn_AlterSchemaOperation
  _wrap_AlterSchemaOperation sem (Inh_AlterSchemaOperation _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterSchemaOperation _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterSchemaOperation_AlterSchemaName :: T_Annotation ->
                                              T_Name ->
                                              T_AlterSchemaOperation
  _sem_AlterSchemaOperation_AlterSchemaName ann_ newName_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSchemaOperation
                _lhsOoriginalTree :: AlterSchemaOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _newNameOcat :: Catalog
                _newNameOflags :: TypeCheckFlags
                _newNameOimCast :: (Maybe TypeExtra)
                _newNameOtpe :: (Either [TypeError] TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _newNameIannotatedTree :: Name
                _newNameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 32, column 44)
                _annOtpe =
                    ({-# LINE 32 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1529 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSchemaName _annIannotatedTree _newNameIannotatedTree
                     {-# LINE 1535 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSchemaName _annIoriginalTree _newNameIoriginalTree
                     {-# LINE 1541 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1547 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1553 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1559 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1565 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1571 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1577 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1583 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1589 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (chain)
                _newNameOtpe =
                    ({-# LINE 46 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     error "missing rule: AlterSchemaOperation.AlterSchemaName.newName.tpe"
                     {-# LINE 1595 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _newNameIannotatedTree,_newNameIoriginalTree) =
                    newName_ _newNameOcat _newNameOflags _newNameOimCast _newNameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSchemaOperation_AlterSchemaOwner :: T_Annotation ->
                                               T_Name ->
                                               T_AlterSchemaOperation
  _sem_AlterSchemaOperation_AlterSchemaOwner ann_ newName_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _newNameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSchemaOperation
                _lhsOoriginalTree :: AlterSchemaOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _newNameOcat :: Catalog
                _newNameOflags :: TypeCheckFlags
                _newNameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _newNameIannotatedTree :: Name
                _newNameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 33, column 45)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1627 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 34, column 45)
                _newNameOtpe =
                    ({-# LINE 34 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1633 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSchemaOwner _annIannotatedTree _newNameIannotatedTree
                     {-# LINE 1639 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSchemaOwner _annIoriginalTree _newNameIoriginalTree
                     {-# LINE 1645 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1651 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1657 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1663 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1669 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1675 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1681 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1687 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1693 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _newNameIannotatedTree,_newNameIoriginalTree) =
                    newName_ _newNameOcat _newNameOflags _newNameOimCast _newNameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterSequenceAction -----------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterSequenceAction 
           originalTree         : AlterSequenceAction 
     alternatives:
        alternative AlterSequenceIncrement:
           child ann            : Annotation 
           child incr           : {Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceMin:
           child ann            : Annotation 
           child min            : {Maybe Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceMax:
           child ann            : Annotation 
           child max            : {Maybe Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceStart:
           child ann            : Annotation 
           child start          : {Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceRestart:
           child ann            : Annotation 
           child restart        : {Maybe Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceCache:
           child ann            : Annotation 
           child cache          : {Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterSequenceAction = AlterSequenceIncrement (Annotation) (Integer)
                           | AlterSequenceMin (Annotation) ((Maybe Integer))
                           | AlterSequenceMax (Annotation) ((Maybe Integer))
                           | AlterSequenceStart (Annotation) (Integer)
                           | AlterSequenceRestart (Annotation) ((Maybe Integer))
                           | AlterSequenceCache (Annotation) (Integer)
                           deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterSequenceAction :: AlterSequenceAction ->
                             T_AlterSequenceAction
  _sem_AlterSequenceAction (AlterSequenceIncrement _ann _incr) =
      (_sem_AlterSequenceAction_AlterSequenceIncrement (_sem_Annotation _ann) _incr)
  _sem_AlterSequenceAction (AlterSequenceMin _ann _min) =
      (_sem_AlterSequenceAction_AlterSequenceMin (_sem_Annotation _ann) _min)
  _sem_AlterSequenceAction (AlterSequenceMax _ann _max) =
      (_sem_AlterSequenceAction_AlterSequenceMax (_sem_Annotation _ann) _max)
  _sem_AlterSequenceAction (AlterSequenceStart _ann _start) =
      (_sem_AlterSequenceAction_AlterSequenceStart (_sem_Annotation _ann) _start)
  _sem_AlterSequenceAction (AlterSequenceRestart _ann _restart) =
      (_sem_AlterSequenceAction_AlterSequenceRestart (_sem_Annotation _ann) _restart)
  _sem_AlterSequenceAction (AlterSequenceCache _ann _cache) =
      (_sem_AlterSequenceAction_AlterSequenceCache (_sem_Annotation _ann) _cache)
  -- semantic domain
  type T_AlterSequenceAction = Catalog ->
                               TypeCheckFlags ->
                               (Maybe TypeExtra) ->
                               ( AlterSequenceAction,AlterSequenceAction)
  data Inh_AlterSequenceAction = Inh_AlterSequenceAction {_cat_Inh_AlterSequenceAction :: Catalog,_flags_Inh_AlterSequenceAction :: TypeCheckFlags,_imCast_Inh_AlterSequenceAction :: (Maybe TypeExtra)}
  data Syn_AlterSequenceAction = Syn_AlterSequenceAction {_annotatedTree_Syn_AlterSequenceAction :: AlterSequenceAction,_originalTree_Syn_AlterSequenceAction :: AlterSequenceAction}
  _wrap_AlterSequenceAction :: T_AlterSequenceAction ->
                              Inh_AlterSequenceAction ->
                              Syn_AlterSequenceAction
  _wrap_AlterSequenceAction sem (Inh_AlterSequenceAction _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterSequenceAction _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterSequenceAction_AlterSequenceIncrement :: T_Annotation ->
                                                    Integer ->
                                                    T_AlterSequenceAction
  _sem_AlterSequenceAction_AlterSequenceIncrement ann_ incr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceAction
                _lhsOoriginalTree :: AlterSequenceAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 35, column 50)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1802 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceIncrement _annIannotatedTree incr_
                     {-# LINE 1808 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceIncrement _annIoriginalTree incr_
                     {-# LINE 1814 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1820 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1826 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1832 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1838 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1844 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceAction_AlterSequenceMin :: T_Annotation ->
                                              (Maybe Integer) ->
                                              T_AlterSequenceAction
  _sem_AlterSequenceAction_AlterSequenceMin ann_ min_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceAction
                _lhsOoriginalTree :: AlterSequenceAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 36, column 44)
                _annOtpe =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1868 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceMin _annIannotatedTree min_
                     {-# LINE 1874 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceMin _annIoriginalTree min_
                     {-# LINE 1880 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1886 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1892 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1898 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1904 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1910 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceAction_AlterSequenceMax :: T_Annotation ->
                                              (Maybe Integer) ->
                                              T_AlterSequenceAction
  _sem_AlterSequenceAction_AlterSequenceMax ann_ max_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceAction
                _lhsOoriginalTree :: AlterSequenceAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 37, column 44)
                _annOtpe =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 1934 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceMax _annIannotatedTree max_
                     {-# LINE 1940 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceMax _annIoriginalTree max_
                     {-# LINE 1946 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 1952 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 1958 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 1964 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 1970 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 1976 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceAction_AlterSequenceStart :: T_Annotation ->
                                                Integer ->
                                                T_AlterSequenceAction
  _sem_AlterSequenceAction_AlterSequenceStart ann_ start_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceAction
                _lhsOoriginalTree :: AlterSequenceAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 38, column 46)
                _annOtpe =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2000 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceStart _annIannotatedTree start_
                     {-# LINE 2006 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceStart _annIoriginalTree start_
                     {-# LINE 2012 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2036 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2042 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceAction_AlterSequenceRestart :: T_Annotation ->
                                                  (Maybe Integer) ->
                                                  T_AlterSequenceAction
  _sem_AlterSequenceAction_AlterSequenceRestart ann_ restart_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceAction
                _lhsOoriginalTree :: AlterSequenceAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 39, column 48)
                _annOtpe =
                    ({-# LINE 39 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2066 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceRestart _annIannotatedTree restart_
                     {-# LINE 2072 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceRestart _annIoriginalTree restart_
                     {-# LINE 2078 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2084 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2090 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2096 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2102 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2108 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceAction_AlterSequenceCache :: T_Annotation ->
                                                Integer ->
                                                T_AlterSequenceAction
  _sem_AlterSequenceAction_AlterSequenceCache ann_ cache_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceAction
                _lhsOoriginalTree :: AlterSequenceAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 40, column 46)
                _annOtpe =
                    ({-# LINE 40 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2132 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceCache _annIannotatedTree cache_
                     {-# LINE 2138 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceCache _annIoriginalTree cache_
                     {-# LINE 2144 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2150 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2156 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2162 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2168 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2174 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterSequenceActionList -------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterSequenceActionList 
           originalTree         : AlterSequenceActionList 
     alternatives:
        alternative Cons:
           child hd             : AlterSequenceAction 
           child tl             : AlterSequenceActionList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type AlterSequenceActionList = [AlterSequenceAction]
  -- cata
  _sem_AlterSequenceActionList :: AlterSequenceActionList ->
                                 T_AlterSequenceActionList
  _sem_AlterSequenceActionList list =
      (Prelude.foldr _sem_AlterSequenceActionList_Cons _sem_AlterSequenceActionList_Nil (Prelude.map _sem_AlterSequenceAction list))
  -- semantic domain
  type T_AlterSequenceActionList = Catalog ->
                                   TypeCheckFlags ->
                                   (Maybe TypeExtra) ->
                                   ( AlterSequenceActionList,AlterSequenceActionList)
  data Inh_AlterSequenceActionList = Inh_AlterSequenceActionList {_cat_Inh_AlterSequenceActionList :: Catalog,_flags_Inh_AlterSequenceActionList :: TypeCheckFlags,_imCast_Inh_AlterSequenceActionList :: (Maybe TypeExtra)}
  data Syn_AlterSequenceActionList = Syn_AlterSequenceActionList {_annotatedTree_Syn_AlterSequenceActionList :: AlterSequenceActionList,_originalTree_Syn_AlterSequenceActionList :: AlterSequenceActionList}
  _wrap_AlterSequenceActionList :: T_AlterSequenceActionList ->
                                  Inh_AlterSequenceActionList ->
                                  Syn_AlterSequenceActionList
  _wrap_AlterSequenceActionList sem (Inh_AlterSequenceActionList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterSequenceActionList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterSequenceActionList_Cons :: T_AlterSequenceAction ->
                                      T_AlterSequenceActionList ->
                                      T_AlterSequenceActionList
  _sem_AlterSequenceActionList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: AlterSequenceActionList
                _lhsOoriginalTree :: AlterSequenceActionList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: AlterSequenceAction
                _hdIoriginalTree :: AlterSequenceAction
                _tlIannotatedTree :: AlterSequenceActionList
                _tlIoriginalTree :: AlterSequenceActionList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 2243 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 2249 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2255 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2261 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2267 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2273 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2279 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2285 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2291 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2297 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceActionList_Nil :: T_AlterSequenceActionList
  _sem_AlterSequenceActionList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: AlterSequenceActionList
                _lhsOoriginalTree :: AlterSequenceActionList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 2315 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 2321 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2327 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2333 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterSequenceOperation --------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterSequenceOperation 
           originalTree         : AlterSequenceOperation 
     alternatives:
        alternative AlterSequenceOwned:
           child ann            : Annotation 
           child owned          : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceRename:
           child ann            : Annotation 
           child name           : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequenceActions:
           child ann            : Annotation 
           child actions        : AlterSequenceActionList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterSequenceOperation = AlterSequenceOwned (Annotation) (Name)
                              | AlterSequenceRename (Annotation) (Name)
                              | AlterSequenceActions (Annotation) (AlterSequenceActionList)
                              deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterSequenceOperation :: AlterSequenceOperation ->
                                T_AlterSequenceOperation
  _sem_AlterSequenceOperation (AlterSequenceOwned _ann _owned) =
      (_sem_AlterSequenceOperation_AlterSequenceOwned (_sem_Annotation _ann) (_sem_Name _owned))
  _sem_AlterSequenceOperation (AlterSequenceRename _ann _name) =
      (_sem_AlterSequenceOperation_AlterSequenceRename (_sem_Annotation _ann) (_sem_Name _name))
  _sem_AlterSequenceOperation (AlterSequenceActions _ann _actions) =
      (_sem_AlterSequenceOperation_AlterSequenceActions (_sem_Annotation _ann) (_sem_AlterSequenceActionList _actions))
  -- semantic domain
  type T_AlterSequenceOperation = Catalog ->
                                  TypeCheckFlags ->
                                  (Maybe TypeExtra) ->
                                  ( AlterSequenceOperation,AlterSequenceOperation)
  data Inh_AlterSequenceOperation = Inh_AlterSequenceOperation {_cat_Inh_AlterSequenceOperation :: Catalog,_flags_Inh_AlterSequenceOperation :: TypeCheckFlags,_imCast_Inh_AlterSequenceOperation :: (Maybe TypeExtra)}
  data Syn_AlterSequenceOperation = Syn_AlterSequenceOperation {_annotatedTree_Syn_AlterSequenceOperation :: AlterSequenceOperation,_originalTree_Syn_AlterSequenceOperation :: AlterSequenceOperation}
  _wrap_AlterSequenceOperation :: T_AlterSequenceOperation ->
                                 Inh_AlterSequenceOperation ->
                                 Syn_AlterSequenceOperation
  _wrap_AlterSequenceOperation sem (Inh_AlterSequenceOperation _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterSequenceOperation _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterSequenceOperation_AlterSequenceOwned :: T_Annotation ->
                                                   T_Name ->
                                                   T_AlterSequenceOperation
  _sem_AlterSequenceOperation_AlterSequenceOwned ann_ owned_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _ownedOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceOperation
                _lhsOoriginalTree :: AlterSequenceOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _ownedOcat :: Catalog
                _ownedOflags :: TypeCheckFlags
                _ownedOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _ownedIannotatedTree :: Name
                _ownedIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 41, column 49)
                _annOtpe =
                    ({-# LINE 41 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2417 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 42, column 49)
                _ownedOtpe =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2423 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceOwned _annIannotatedTree _ownedIannotatedTree
                     {-# LINE 2429 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceOwned _annIoriginalTree _ownedIoriginalTree
                     {-# LINE 2435 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2441 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2447 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2453 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2459 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2465 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _ownedOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2471 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _ownedOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2477 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _ownedOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2483 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _ownedIannotatedTree,_ownedIoriginalTree) =
                    owned_ _ownedOcat _ownedOflags _ownedOimCast _ownedOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceOperation_AlterSequenceRename :: T_Annotation ->
                                                    T_Name ->
                                                    T_AlterSequenceOperation
  _sem_AlterSequenceOperation_AlterSequenceRename ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceOperation
                _lhsOoriginalTree :: AlterSequenceOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 43, column 50)
                _annOtpe =
                    ({-# LINE 43 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2515 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 44, column 50)
                _nameOtpe =
                    ({-# LINE 44 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2521 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceRename _annIannotatedTree _nameIannotatedTree
                     {-# LINE 2527 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceRename _annIoriginalTree _nameIoriginalTree
                     {-# LINE 2533 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2545 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2551 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2563 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2569 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterSequenceOperation_AlterSequenceActions :: T_Annotation ->
                                                     T_AlterSequenceActionList ->
                                                     T_AlterSequenceOperation
  _sem_AlterSequenceOperation_AlterSequenceActions ann_ actions_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterSequenceOperation
                _lhsOoriginalTree :: AlterSequenceOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _actionsOcat :: Catalog
                _actionsOflags :: TypeCheckFlags
                _actionsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _actionsIannotatedTree :: AlterSequenceActionList
                _actionsIoriginalTree :: AlterSequenceActionList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 45, column 51)
                _annOtpe =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2612 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceActions _annIannotatedTree _actionsIannotatedTree
                     {-# LINE 2618 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequenceActions _annIoriginalTree _actionsIoriginalTree
                     {-# LINE 2624 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2630 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2636 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2642 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2648 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2654 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actionsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2660 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actionsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2666 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actionsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2672 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _actionsIannotatedTree,_actionsIoriginalTree) =
                    actions_ _actionsOcat _actionsOflags _actionsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterTableAction --------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterTableAction 
           originalTree         : AlterTableAction 
     alternatives:
        alternative AddColumn:
           child ann            : Annotation 
           child att            : AttributeDef 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DropColumn:
           child ann            : Annotation 
           child nm             : {NameComponent}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterColumn:
           child ann            : Annotation 
           child nm             : {NameComponent}
           child act            : AlterColumnAction 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AddConstraint:
           child ann            : Annotation 
           child con            : Constraint 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterTableAction = AddColumn (Annotation) (AttributeDef)
                        | DropColumn (Annotation) (NameComponent)
                        | AlterColumn (Annotation) (NameComponent) (AlterColumnAction)
                        | AddConstraint (Annotation) (Constraint)
                        deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterTableAction :: AlterTableAction ->
                          T_AlterTableAction
  _sem_AlterTableAction (AddColumn _ann _att) =
      (_sem_AlterTableAction_AddColumn (_sem_Annotation _ann) (_sem_AttributeDef _att))
  _sem_AlterTableAction (DropColumn _ann _nm) =
      (_sem_AlterTableAction_DropColumn (_sem_Annotation _ann) _nm)
  _sem_AlterTableAction (AlterColumn _ann _nm _act) =
      (_sem_AlterTableAction_AlterColumn (_sem_Annotation _ann) _nm (_sem_AlterColumnAction _act))
  _sem_AlterTableAction (AddConstraint _ann _con) =
      (_sem_AlterTableAction_AddConstraint (_sem_Annotation _ann) (_sem_Constraint _con))
  -- semantic domain
  type T_AlterTableAction = Catalog ->
                            TypeCheckFlags ->
                            (Maybe TypeExtra) ->
                            ( AlterTableAction,AlterTableAction)
  data Inh_AlterTableAction = Inh_AlterTableAction {_cat_Inh_AlterTableAction :: Catalog,_flags_Inh_AlterTableAction :: TypeCheckFlags,_imCast_Inh_AlterTableAction :: (Maybe TypeExtra)}
  data Syn_AlterTableAction = Syn_AlterTableAction {_annotatedTree_Syn_AlterTableAction :: AlterTableAction,_originalTree_Syn_AlterTableAction :: AlterTableAction}
  _wrap_AlterTableAction :: T_AlterTableAction ->
                           Inh_AlterTableAction ->
                           Syn_AlterTableAction
  _wrap_AlterTableAction sem (Inh_AlterTableAction _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterTableAction _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterTableAction_AddColumn :: T_Annotation ->
                                    T_AttributeDef ->
                                    T_AlterTableAction
  _sem_AlterTableAction_AddColumn ann_ att_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableAction
                _lhsOoriginalTree :: AlterTableAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _attOcat :: Catalog
                _attOflags :: TypeCheckFlags
                _attOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _attIannotatedTree :: AttributeDef
                _attIoriginalTree :: AttributeDef
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 46, column 34)
                _annOtpe =
                    ({-# LINE 46 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2769 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AddColumn _annIannotatedTree _attIannotatedTree
                     {-# LINE 2775 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AddColumn _annIoriginalTree _attIoriginalTree
                     {-# LINE 2781 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2787 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2793 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2799 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2805 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2811 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2817 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2823 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2829 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _attIannotatedTree,_attIoriginalTree) =
                    att_ _attOcat _attOflags _attOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterTableAction_DropColumn :: T_Annotation ->
                                     NameComponent ->
                                     T_AlterTableAction
  _sem_AlterTableAction_DropColumn ann_ nm_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableAction
                _lhsOoriginalTree :: AlterTableAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 49, column 35)
                _annOtpe =
                    ({-# LINE 49 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2855 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropColumn _annIannotatedTree nm_
                     {-# LINE 2861 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropColumn _annIoriginalTree nm_
                     {-# LINE 2867 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2873 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2879 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2885 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2891 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2897 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterTableAction_AlterColumn :: T_Annotation ->
                                      NameComponent ->
                                      T_AlterColumnAction ->
                                      T_AlterTableAction
  _sem_AlterTableAction_AlterColumn ann_ nm_ act_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableAction
                _lhsOoriginalTree :: AlterTableAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _actOcat :: Catalog
                _actOflags :: TypeCheckFlags
                _actOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _actIannotatedTree :: AlterColumnAction
                _actIoriginalTree :: AlterColumnAction
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 48, column 36)
                _annOtpe =
                    ({-# LINE 48 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 2927 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterColumn _annIannotatedTree nm_ _actIannotatedTree
                     {-# LINE 2933 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterColumn _annIoriginalTree nm_ _actIoriginalTree
                     {-# LINE 2939 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 2945 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 2951 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2957 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2963 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2969 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 2975 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 2981 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 2987 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _actIannotatedTree,_actIoriginalTree) =
                    act_ _actOcat _actOflags _actOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterTableAction_AddConstraint :: T_Annotation ->
                                        T_Constraint ->
                                        T_AlterTableAction
  _sem_AlterTableAction_AddConstraint ann_ con_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableAction
                _lhsOoriginalTree :: AlterTableAction
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _conOcat :: Catalog
                _conOflags :: TypeCheckFlags
                _conOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _conIannotatedTree :: Constraint
                _conIoriginalTree :: Constraint
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 47, column 38)
                _annOtpe =
                    ({-# LINE 47 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 3018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AddConstraint _annIannotatedTree _conIannotatedTree
                     {-# LINE 3024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AddConstraint _annIoriginalTree _conIoriginalTree
                     {-# LINE 3030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3036 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3042 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3048 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3054 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3060 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _conOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3066 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _conOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3072 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _conOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3078 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _conIannotatedTree,_conIoriginalTree) =
                    con_ _conOcat _conOflags _conOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterTableActionList ----------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterTableActionList 
           originalTree         : AlterTableActionList 
     alternatives:
        alternative Cons:
           child hd             : AlterTableAction 
           child tl             : AlterTableActionList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type AlterTableActionList = [AlterTableAction]
  -- cata
  _sem_AlterTableActionList :: AlterTableActionList ->
                              T_AlterTableActionList
  _sem_AlterTableActionList list =
      (Prelude.foldr _sem_AlterTableActionList_Cons _sem_AlterTableActionList_Nil (Prelude.map _sem_AlterTableAction list))
  -- semantic domain
  type T_AlterTableActionList = Catalog ->
                                TypeCheckFlags ->
                                (Maybe TypeExtra) ->
                                ( AlterTableActionList,AlterTableActionList)
  data Inh_AlterTableActionList = Inh_AlterTableActionList {_cat_Inh_AlterTableActionList :: Catalog,_flags_Inh_AlterTableActionList :: TypeCheckFlags,_imCast_Inh_AlterTableActionList :: (Maybe TypeExtra)}
  data Syn_AlterTableActionList = Syn_AlterTableActionList {_annotatedTree_Syn_AlterTableActionList :: AlterTableActionList,_originalTree_Syn_AlterTableActionList :: AlterTableActionList}
  _wrap_AlterTableActionList :: T_AlterTableActionList ->
                               Inh_AlterTableActionList ->
                               Syn_AlterTableActionList
  _wrap_AlterTableActionList sem (Inh_AlterTableActionList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterTableActionList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterTableActionList_Cons :: T_AlterTableAction ->
                                   T_AlterTableActionList ->
                                   T_AlterTableActionList
  _sem_AlterTableActionList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: AlterTableActionList
                _lhsOoriginalTree :: AlterTableActionList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: AlterTableAction
                _hdIoriginalTree :: AlterTableAction
                _tlIannotatedTree :: AlterTableActionList
                _tlIoriginalTree :: AlterTableActionList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 3149 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 3155 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3161 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3167 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3173 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3179 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3185 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3191 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3197 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3203 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterTableActionList_Nil :: T_AlterTableActionList
  _sem_AlterTableActionList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: AlterTableActionList
                _lhsOoriginalTree :: AlterTableActionList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 3221 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 3227 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3233 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3239 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AlterTableOperation -----------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AlterTableOperation 
           originalTree         : AlterTableOperation 
     alternatives:
        alternative RenameTable:
           child ann            : Annotation 
           child newName        : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative RenameColumn:
           child ann            : Annotation 
           child oldName        : {NameComponent}
           child newName        : {NameComponent}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterTableActions:
           child ann            : Annotation 
           child actions        : AlterTableActionList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AlterTableOperation = RenameTable (Annotation) (Name)
                           | RenameColumn (Annotation) (NameComponent) (NameComponent)
                           | AlterTableActions (Annotation) (AlterTableActionList)
                           deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AlterTableOperation :: AlterTableOperation ->
                             T_AlterTableOperation
  _sem_AlterTableOperation (RenameTable _ann _newName) =
      (_sem_AlterTableOperation_RenameTable (_sem_Annotation _ann) (_sem_Name _newName))
  _sem_AlterTableOperation (RenameColumn _ann _oldName _newName) =
      (_sem_AlterTableOperation_RenameColumn (_sem_Annotation _ann) _oldName _newName)
  _sem_AlterTableOperation (AlterTableActions _ann _actions) =
      (_sem_AlterTableOperation_AlterTableActions (_sem_Annotation _ann) (_sem_AlterTableActionList _actions))
  -- semantic domain
  type T_AlterTableOperation = Catalog ->
                               TypeCheckFlags ->
                               (Maybe TypeExtra) ->
                               ( AlterTableOperation,AlterTableOperation)
  data Inh_AlterTableOperation = Inh_AlterTableOperation {_cat_Inh_AlterTableOperation :: Catalog,_flags_Inh_AlterTableOperation :: TypeCheckFlags,_imCast_Inh_AlterTableOperation :: (Maybe TypeExtra)}
  data Syn_AlterTableOperation = Syn_AlterTableOperation {_annotatedTree_Syn_AlterTableOperation :: AlterTableOperation,_originalTree_Syn_AlterTableOperation :: AlterTableOperation}
  _wrap_AlterTableOperation :: T_AlterTableOperation ->
                              Inh_AlterTableOperation ->
                              Syn_AlterTableOperation
  _wrap_AlterTableOperation sem (Inh_AlterTableOperation _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AlterTableOperation _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AlterTableOperation_RenameTable :: T_Annotation ->
                                         T_Name ->
                                         T_AlterTableOperation
  _sem_AlterTableOperation_RenameTable ann_ newName_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _newNameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableOperation
                _lhsOoriginalTree :: AlterTableOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _newNameOcat :: Catalog
                _newNameOflags :: TypeCheckFlags
                _newNameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _newNameIannotatedTree :: Name
                _newNameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 52, column 39)
                _annOtpe =
                    ({-# LINE 52 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 3324 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 53, column 39)
                _newNameOtpe =
                    ({-# LINE 53 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 3330 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RenameTable _annIannotatedTree _newNameIannotatedTree
                     {-# LINE 3336 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RenameTable _annIoriginalTree _newNameIoriginalTree
                     {-# LINE 3342 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3348 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3354 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3360 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3366 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3372 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3378 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3384 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _newNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3390 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _newNameIannotatedTree,_newNameIoriginalTree) =
                    newName_ _newNameOcat _newNameOflags _newNameOimCast _newNameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterTableOperation_RenameColumn :: T_Annotation ->
                                          NameComponent ->
                                          NameComponent ->
                                          T_AlterTableOperation
  _sem_AlterTableOperation_RenameColumn ann_ oldName_ newName_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableOperation
                _lhsOoriginalTree :: AlterTableOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 51, column 40)
                _annOtpe =
                    ({-# LINE 51 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 3417 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RenameColumn _annIannotatedTree oldName_ newName_
                     {-# LINE 3423 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RenameColumn _annIoriginalTree oldName_ newName_
                     {-# LINE 3429 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3435 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3441 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3447 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3453 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3459 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AlterTableOperation_AlterTableActions :: T_Annotation ->
                                               T_AlterTableActionList ->
                                               T_AlterTableOperation
  _sem_AlterTableOperation_AlterTableActions ann_ actions_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AlterTableOperation
                _lhsOoriginalTree :: AlterTableOperation
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _actionsOcat :: Catalog
                _actionsOflags :: TypeCheckFlags
                _actionsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _actionsIannotatedTree :: AlterTableActionList
                _actionsIoriginalTree :: AlterTableActionList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 50, column 45)
                _annOtpe =
                    ({-# LINE 50 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 3488 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterTableActions _annIannotatedTree _actionsIannotatedTree
                     {-# LINE 3494 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterTableActions _annIoriginalTree _actionsIoriginalTree
                     {-# LINE 3500 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3506 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3512 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3518 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3524 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3530 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actionsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3536 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actionsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3542 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _actionsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3548 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _actionsIannotatedTree,_actionsIoriginalTree) =
                    actions_ _actionsOcat _actionsOflags _actionsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- Annotation --------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
           tpe                  : Either [TypeError] TypeExtra
        synthesized attributes:
           annotatedTree        : Annotation 
           originalTree         : Annotation 
     alternatives:
        alternative Annotation:
           child anSrc          : {Maybe SourcePosition}
           child anType         : {Maybe T.TypeExtra}
           child anErrs         : {[T.TypeError]}
           child anImplicitCast : {Maybe T.TypeExtra}
           child anCatUpd       : {[C.CatalogUpdate]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  
  -- | Annotation type - one of these is attached to most of the
  -- data types used in the ast.
  -- the fields in order are:
  data Annotation = Annotation {
                               -- | source position for this node
                               anSrc :: ( Maybe SourcePosition)
                               -- | type of the node, 'Nothing' if the tree hasn't been typechecked or if a type error elsewhere prevents determining this node's type
                               ,anType :: ( Maybe T.TypeExtra)
                               -- | any type errors
                               ,anErrs :: ( [T.TypeError])
                               -- | if an implicit cast is needed between this node an its parent, this the target type of cast. If no implicit cast is needed, this is Nothing
                               ,anImplicitCast :: ( Maybe T.TypeExtra)
                               -- | any catalog updates that a statement produces, used only for ddl Statements
                               ,anCatUpd :: ( [C.CatalogUpdate])
  
      } deriving (Eq,Show,Data,Typeable)
  
  -- cata
  _sem_Annotation :: Annotation ->
                    T_Annotation
  _sem_Annotation (Annotation _anSrc _anType _anErrs _anImplicitCast _anCatUpd) =
      (_sem_Annotation_Annotation _anSrc _anType _anErrs _anImplicitCast _anCatUpd)
  -- semantic domain
  type T_Annotation = Catalog ->
                      TypeCheckFlags ->
                      (Maybe TypeExtra) ->
                      (Either [TypeError] TypeExtra) ->
                      ( Annotation,Annotation)
  data Inh_Annotation = Inh_Annotation {_cat_Inh_Annotation :: Catalog,_flags_Inh_Annotation :: TypeCheckFlags,_imCast_Inh_Annotation :: (Maybe TypeExtra),_tpe_Inh_Annotation :: (Either [TypeError] TypeExtra)}
  data Syn_Annotation = Syn_Annotation {_annotatedTree_Syn_Annotation :: Annotation,_originalTree_Syn_Annotation :: Annotation}
  _wrap_Annotation :: T_Annotation ->
                     Inh_Annotation ->
                     Syn_Annotation
  _wrap_Annotation sem (Inh_Annotation _lhsIcat _lhsIflags _lhsIimCast _lhsItpe) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast _lhsItpe
       in  (Syn_Annotation _lhsOannotatedTree _lhsOoriginalTree))
  _sem_Annotation_Annotation :: (Maybe SourcePosition) ->
                               (Maybe T.TypeExtra) ->
                               ([T.TypeError]) ->
                               (Maybe T.TypeExtra) ->
                               ([C.CatalogUpdate]) ->
                               T_Annotation
  _sem_Annotation_Annotation anSrc_ anType_ anErrs_ anImplicitCast_ anCatUpd_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast
         _lhsItpe ->
           (let _lhsOannotatedTree :: Annotation
                _lhsOoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag"(line 140, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 140 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     let t = either (const Nothing) Just _lhsItpe
                         es = either id (const []) _lhsItpe
                     in Annotation anSrc_ t es _lhsIimCast anCatUpd_
                     {-# LINE 3617 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Annotation anSrc_ anType_ anErrs_ anImplicitCast_ anCatUpd_
                     {-# LINE 3623 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Annotation anSrc_ anType_ anErrs_ anImplicitCast_ anCatUpd_
                     {-# LINE 3629 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3635 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AttributeDef ------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AttributeDef 
           originalTree         : AttributeDef 
     alternatives:
        alternative AttributeDef:
           child ann            : Annotation 
           child name           : {NameComponent}
           child typ            : TypeName 
           child cons           : RowConstraintList 
           child options        : {[TableOption]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data AttributeDef = AttributeDef (Annotation) (NameComponent) (TypeName) (RowConstraintList) (([TableOption]))
                    deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_AttributeDef :: AttributeDef ->
                      T_AttributeDef
  _sem_AttributeDef (AttributeDef _ann _name _typ _cons _options) =
      (_sem_AttributeDef_AttributeDef (_sem_Annotation _ann) _name (_sem_TypeName _typ) (_sem_RowConstraintList _cons) _options)
  -- semantic domain
  type T_AttributeDef = Catalog ->
                        TypeCheckFlags ->
                        (Maybe TypeExtra) ->
                        ( AttributeDef,AttributeDef)
  data Inh_AttributeDef = Inh_AttributeDef {_cat_Inh_AttributeDef :: Catalog,_flags_Inh_AttributeDef :: TypeCheckFlags,_imCast_Inh_AttributeDef :: (Maybe TypeExtra)}
  data Syn_AttributeDef = Syn_AttributeDef {_annotatedTree_Syn_AttributeDef :: AttributeDef,_originalTree_Syn_AttributeDef :: AttributeDef}
  _wrap_AttributeDef :: T_AttributeDef ->
                       Inh_AttributeDef ->
                       Syn_AttributeDef
  _wrap_AttributeDef sem (Inh_AttributeDef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AttributeDef _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AttributeDef_AttributeDef :: T_Annotation ->
                                   NameComponent ->
                                   T_TypeName ->
                                   T_RowConstraintList ->
                                   ([TableOption]) ->
                                   T_AttributeDef
  _sem_AttributeDef_AttributeDef ann_ name_ typ_ cons_ options_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: AttributeDef
                _lhsOoriginalTree :: AttributeDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _consOcat :: Catalog
                _consOflags :: TypeCheckFlags
                _consOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                _consIannotatedTree :: RowConstraintList
                _consIoriginalTree :: RowConstraintList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 54, column 33)
                _annOtpe =
                    ({-# LINE 54 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 3712 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AttributeDef _annIannotatedTree name_ _typIannotatedTree _consIannotatedTree options_
                     {-# LINE 3718 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AttributeDef _annIoriginalTree name_ _typIoriginalTree _consIoriginalTree options_
                     {-# LINE 3724 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3730 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3736 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3742 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3748 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3754 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3760 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3766 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3772 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _consOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3778 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _consOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3784 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _consOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3790 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
                ( _consIannotatedTree,_consIoriginalTree) =
                    cons_ _consOcat _consOflags _consOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- AttributeDefList --------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : AttributeDefList 
           originalTree         : AttributeDefList 
     alternatives:
        alternative Cons:
           child hd             : AttributeDef 
           child tl             : AttributeDefList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type AttributeDefList = [AttributeDef]
  -- cata
  _sem_AttributeDefList :: AttributeDefList ->
                          T_AttributeDefList
  _sem_AttributeDefList list =
      (Prelude.foldr _sem_AttributeDefList_Cons _sem_AttributeDefList_Nil (Prelude.map _sem_AttributeDef list))
  -- semantic domain
  type T_AttributeDefList = Catalog ->
                            TypeCheckFlags ->
                            (Maybe TypeExtra) ->
                            ( AttributeDefList,AttributeDefList)
  data Inh_AttributeDefList = Inh_AttributeDefList {_cat_Inh_AttributeDefList :: Catalog,_flags_Inh_AttributeDefList :: TypeCheckFlags,_imCast_Inh_AttributeDefList :: (Maybe TypeExtra)}
  data Syn_AttributeDefList = Syn_AttributeDefList {_annotatedTree_Syn_AttributeDefList :: AttributeDefList,_originalTree_Syn_AttributeDefList :: AttributeDefList}
  _wrap_AttributeDefList :: T_AttributeDefList ->
                           Inh_AttributeDefList ->
                           Syn_AttributeDefList
  _wrap_AttributeDefList sem (Inh_AttributeDefList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_AttributeDefList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_AttributeDefList_Cons :: T_AttributeDef ->
                               T_AttributeDefList ->
                               T_AttributeDefList
  _sem_AttributeDefList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: AttributeDefList
                _lhsOoriginalTree :: AttributeDefList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: AttributeDef
                _hdIoriginalTree :: AttributeDef
                _tlIannotatedTree :: AttributeDefList
                _tlIoriginalTree :: AttributeDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 3863 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 3869 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3875 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3881 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3887 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3893 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3899 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 3905 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 3911 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 3917 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_AttributeDefList_Nil :: T_AttributeDefList
  _sem_AttributeDefList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: AttributeDefList
                _lhsOoriginalTree :: AttributeDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 3935 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 3941 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 3947 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 3953 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- CaseScalarExprListScalarExprPair ----------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
           thenExpectedType     : Maybe TypeExtra
           whenExpectedType     : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : CaseScalarExprListScalarExprPair 
           originalTree         : CaseScalarExprListScalarExprPair 
           thenType             : Maybe TypeExtra
           upTypes              : [Maybe TypeExtra]
           whenTypes            : [Maybe TypeExtra]
     alternatives:
        alternative Tuple:
           child x1             : ScalarExprList 
           child x2             : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type CaseScalarExprListScalarExprPair = ( ScalarExprList,ScalarExpr)
  -- cata
  _sem_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair ->
                                          T_CaseScalarExprListScalarExprPair
  _sem_CaseScalarExprListScalarExprPair ( x1,x2) =
      (_sem_CaseScalarExprListScalarExprPair_Tuple (_sem_ScalarExprList x1) (_sem_ScalarExpr x2))
  -- semantic domain
  type T_CaseScalarExprListScalarExprPair = Catalog ->
                                            Environment ->
                                            TypeCheckFlags ->
                                            (Maybe TypeExtra) ->
                                            (Maybe TypeExtra) ->
                                            (Maybe TypeExtra) ->
                                            ( CaseScalarExprListScalarExprPair,CaseScalarExprListScalarExprPair,(Maybe TypeExtra),([Maybe TypeExtra]),([Maybe TypeExtra]))
  data Inh_CaseScalarExprListScalarExprPair = Inh_CaseScalarExprListScalarExprPair {_cat_Inh_CaseScalarExprListScalarExprPair :: Catalog,_downEnv_Inh_CaseScalarExprListScalarExprPair :: Environment,_flags_Inh_CaseScalarExprListScalarExprPair :: TypeCheckFlags,_imCast_Inh_CaseScalarExprListScalarExprPair :: (Maybe TypeExtra),_thenExpectedType_Inh_CaseScalarExprListScalarExprPair :: (Maybe TypeExtra),_whenExpectedType_Inh_CaseScalarExprListScalarExprPair :: (Maybe TypeExtra)}
  data Syn_CaseScalarExprListScalarExprPair = Syn_CaseScalarExprListScalarExprPair {_annotatedTree_Syn_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair,_originalTree_Syn_CaseScalarExprListScalarExprPair :: CaseScalarExprListScalarExprPair,_thenType_Syn_CaseScalarExprListScalarExprPair :: (Maybe TypeExtra),_upTypes_Syn_CaseScalarExprListScalarExprPair :: ([Maybe TypeExtra]),_whenTypes_Syn_CaseScalarExprListScalarExprPair :: ([Maybe TypeExtra])}
  _wrap_CaseScalarExprListScalarExprPair :: T_CaseScalarExprListScalarExprPair ->
                                           Inh_CaseScalarExprListScalarExprPair ->
                                           Syn_CaseScalarExprListScalarExprPair
  _wrap_CaseScalarExprListScalarExprPair sem (Inh_CaseScalarExprListScalarExprPair _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast _lhsIthenExpectedType _lhsIwhenExpectedType) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOthenType,_lhsOupTypes,_lhsOwhenTypes) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast _lhsIthenExpectedType _lhsIwhenExpectedType
       in  (Syn_CaseScalarExprListScalarExprPair _lhsOannotatedTree _lhsOoriginalTree _lhsOthenType _lhsOupTypes _lhsOwhenTypes))
  _sem_CaseScalarExprListScalarExprPair_Tuple :: T_ScalarExprList ->
                                                T_ScalarExpr ->
                                                T_CaseScalarExprListScalarExprPair
  _sem_CaseScalarExprListScalarExprPair_Tuple x1_ x2_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast
         _lhsIthenExpectedType
         _lhsIwhenExpectedType ->
           (let _x2OodbcFunction :: Bool
                _lhsOwhenTypes :: ([Maybe TypeExtra])
                _lhsOthenType :: (Maybe TypeExtra)
                _x1OexpectedTypes :: ([TypeExtra])
                _x1OexpectedCast :: Bool
                _x2OexpectedType :: (Maybe TypeExtra)
                _x2OexpectedCast :: Bool
                _x1OassignmentCastContext :: Bool
                _x2OassignmentCastContext :: Bool
                _lhsOannotatedTree :: CaseScalarExprListScalarExprPair
                _lhsOoriginalTree :: CaseScalarExprListScalarExprPair
                _lhsOupTypes :: ([Maybe TypeExtra])
                _x1Ocat :: Catalog
                _x1OdownEnv :: Environment
                _x1Oflags :: TypeCheckFlags
                _x1OimCast :: (Maybe TypeExtra)
                _x2Ocat :: Catalog
                _x2OdownEnv :: Environment
                _x2Oflags :: TypeCheckFlags
                _x2OimCast :: (Maybe TypeExtra)
                _x1IannotatedTree :: ScalarExprList
                _x1IoriginalTree :: ScalarExprList
                _x1IupTypes :: ([Maybe TypeExtra])
                _x2IannotatedTree :: ScalarExpr
                _x2IcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _x2IoriginalTree :: ScalarExpr
                _x2IupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 134, column 13)
                _x2OodbcFunction =
                    ({-# LINE 134 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 4043 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 550, column 13)
                _lhsOwhenTypes =
                    ({-# LINE 550 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _x1IupTypes
                     {-# LINE 4049 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 551, column 13)
                _lhsOthenType =
                    ({-# LINE 551 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _x2IupType
                     {-# LINE 4055 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 606, column 11)
                _x1OexpectedTypes =
                    ({-# LINE 606 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe [] repeat _lhsIwhenExpectedType
                     {-# LINE 4061 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 607, column 11)
                _x1OexpectedCast =
                    ({-# LINE 607 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 4067 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 608, column 11)
                _x2OexpectedType =
                    ({-# LINE 608 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIthenExpectedType
                     {-# LINE 4073 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 609, column 11)
                _x2OexpectedCast =
                    ({-# LINE 609 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     True
                     {-# LINE 4079 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 808, column 46)
                _x1OassignmentCastContext =
                    ({-# LINE 808 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 4085 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 809, column 46)
                _x2OassignmentCastContext =
                    ({-# LINE 809 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 4091 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IannotatedTree,_x2IannotatedTree)
                     {-# LINE 4097 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IoriginalTree,_x2IoriginalTree)
                     {-# LINE 4103 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4109 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4115 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOupTypes =
                    ({-# LINE 555 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _x1IupTypes
                     {-# LINE 4121 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4127 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 4133 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4139 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4145 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4151 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2OdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 4157 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4163 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _x1IannotatedTree,_x1IoriginalTree,_x1IupTypes) =
                    x1_ _x1OassignmentCastContext _x1Ocat _x1OdownEnv _x1OexpectedCast _x1OexpectedTypes _x1Oflags _x1OimCast
                ( _x2IannotatedTree,_x2IcolExprs,_x2IoriginalTree,_x2IupType) =
                    x2_ _x2OassignmentCastContext _x2Ocat _x2OdownEnv _x2OexpectedCast _x2OexpectedType _x2Oflags _x2OimCast _x2OodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOthenType,_lhsOupTypes,_lhsOwhenTypes)))
  -- CaseScalarExprListScalarExprPairList ------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
           thenExpectedType     : Maybe TypeExtra
           whenExpectedType     : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : CaseScalarExprListScalarExprPairList 
           originalTree         : CaseScalarExprListScalarExprPairList 
           thenTypes            : [Maybe TypeExtra]
           upTypes              : [Maybe TypeExtra]
           whenTypes            : [[Maybe TypeExtra]]
     alternatives:
        alternative Cons:
           child hd             : CaseScalarExprListScalarExprPair 
           child tl             : CaseScalarExprListScalarExprPairList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type CaseScalarExprListScalarExprPairList = [CaseScalarExprListScalarExprPair]
  -- cata
  _sem_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList ->
                                              T_CaseScalarExprListScalarExprPairList
  _sem_CaseScalarExprListScalarExprPairList list =
      (Prelude.foldr _sem_CaseScalarExprListScalarExprPairList_Cons _sem_CaseScalarExprListScalarExprPairList_Nil (Prelude.map _sem_CaseScalarExprListScalarExprPair list))
  -- semantic domain
  type T_CaseScalarExprListScalarExprPairList = Catalog ->
                                                Environment ->
                                                TypeCheckFlags ->
                                                (Maybe TypeExtra) ->
                                                (Maybe TypeExtra) ->
                                                (Maybe TypeExtra) ->
                                                ( CaseScalarExprListScalarExprPairList,CaseScalarExprListScalarExprPairList,([Maybe TypeExtra]),([Maybe TypeExtra]),([[Maybe TypeExtra]]))
  data Inh_CaseScalarExprListScalarExprPairList = Inh_CaseScalarExprListScalarExprPairList {_cat_Inh_CaseScalarExprListScalarExprPairList :: Catalog,_downEnv_Inh_CaseScalarExprListScalarExprPairList :: Environment,_flags_Inh_CaseScalarExprListScalarExprPairList :: TypeCheckFlags,_imCast_Inh_CaseScalarExprListScalarExprPairList :: (Maybe TypeExtra),_thenExpectedType_Inh_CaseScalarExprListScalarExprPairList :: (Maybe TypeExtra),_whenExpectedType_Inh_CaseScalarExprListScalarExprPairList :: (Maybe TypeExtra)}
  data Syn_CaseScalarExprListScalarExprPairList = Syn_CaseScalarExprListScalarExprPairList {_annotatedTree_Syn_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList,_originalTree_Syn_CaseScalarExprListScalarExprPairList :: CaseScalarExprListScalarExprPairList,_thenTypes_Syn_CaseScalarExprListScalarExprPairList :: ([Maybe TypeExtra]),_upTypes_Syn_CaseScalarExprListScalarExprPairList :: ([Maybe TypeExtra]),_whenTypes_Syn_CaseScalarExprListScalarExprPairList :: ([[Maybe TypeExtra]])}
  _wrap_CaseScalarExprListScalarExprPairList :: T_CaseScalarExprListScalarExprPairList ->
                                               Inh_CaseScalarExprListScalarExprPairList ->
                                               Syn_CaseScalarExprListScalarExprPairList
  _wrap_CaseScalarExprListScalarExprPairList sem (Inh_CaseScalarExprListScalarExprPairList _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast _lhsIthenExpectedType _lhsIwhenExpectedType) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOthenTypes,_lhsOupTypes,_lhsOwhenTypes) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast _lhsIthenExpectedType _lhsIwhenExpectedType
       in  (Syn_CaseScalarExprListScalarExprPairList _lhsOannotatedTree _lhsOoriginalTree _lhsOthenTypes _lhsOupTypes _lhsOwhenTypes))
  _sem_CaseScalarExprListScalarExprPairList_Cons :: T_CaseScalarExprListScalarExprPair ->
                                                   T_CaseScalarExprListScalarExprPairList ->
                                                   T_CaseScalarExprListScalarExprPairList
  _sem_CaseScalarExprListScalarExprPairList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast
         _lhsIthenExpectedType
         _lhsIwhenExpectedType ->
           (let _lhsOwhenTypes :: ([[Maybe TypeExtra]])
                _lhsOthenTypes :: ([Maybe TypeExtra])
                _lhsOannotatedTree :: CaseScalarExprListScalarExprPairList
                _lhsOoriginalTree :: CaseScalarExprListScalarExprPairList
                _lhsOupTypes :: ([Maybe TypeExtra])
                _hdOcat :: Catalog
                _hdOdownEnv :: Environment
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _hdOthenExpectedType :: (Maybe TypeExtra)
                _hdOwhenExpectedType :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOdownEnv :: Environment
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _tlOthenExpectedType :: (Maybe TypeExtra)
                _tlOwhenExpectedType :: (Maybe TypeExtra)
                _hdIannotatedTree :: CaseScalarExprListScalarExprPair
                _hdIoriginalTree :: CaseScalarExprListScalarExprPair
                _hdIthenType :: (Maybe TypeExtra)
                _hdIupTypes :: ([Maybe TypeExtra])
                _hdIwhenTypes :: ([Maybe TypeExtra])
                _tlIannotatedTree :: CaseScalarExprListScalarExprPairList
                _tlIoriginalTree :: CaseScalarExprListScalarExprPairList
                _tlIthenTypes :: ([Maybe TypeExtra])
                _tlIupTypes :: ([Maybe TypeExtra])
                _tlIwhenTypes :: ([[Maybe TypeExtra]])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 539, column 10)
                _lhsOwhenTypes =
                    ({-# LINE 539 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _hdIwhenTypes : _tlIwhenTypes
                     {-# LINE 4267 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 540, column 10)
                _lhsOthenTypes =
                    ({-# LINE 540 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _hdIthenType : _tlIthenTypes
                     {-# LINE 4273 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 4279 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 4285 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4291 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4297 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOupTypes =
                    ({-# LINE 555 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tlIupTypes
                     {-# LINE 4303 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4309 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOdownEnv =
                    ({-# LINE 554 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 4315 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4321 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4327 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOthenExpectedType =
                    ({-# LINE 602 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIthenExpectedType
                     {-# LINE 4333 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOwhenExpectedType =
                    ({-# LINE 603 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIwhenExpectedType
                     {-# LINE 4339 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4345 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOdownEnv =
                    ({-# LINE 554 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 4351 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4357 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4363 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOthenExpectedType =
                    ({-# LINE 602 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIthenExpectedType
                     {-# LINE 4369 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOwhenExpectedType =
                    ({-# LINE 603 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIwhenExpectedType
                     {-# LINE 4375 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree,_hdIthenType,_hdIupTypes,_hdIwhenTypes) =
                    hd_ _hdOcat _hdOdownEnv _hdOflags _hdOimCast _hdOthenExpectedType _hdOwhenExpectedType
                ( _tlIannotatedTree,_tlIoriginalTree,_tlIthenTypes,_tlIupTypes,_tlIwhenTypes) =
                    tl_ _tlOcat _tlOdownEnv _tlOflags _tlOimCast _tlOthenExpectedType _tlOwhenExpectedType
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOthenTypes,_lhsOupTypes,_lhsOwhenTypes)))
  _sem_CaseScalarExprListScalarExprPairList_Nil :: T_CaseScalarExprListScalarExprPairList
  _sem_CaseScalarExprListScalarExprPairList_Nil =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast
         _lhsIthenExpectedType
         _lhsIwhenExpectedType ->
           (let _lhsOwhenTypes :: ([[Maybe TypeExtra]])
                _lhsOthenTypes :: ([Maybe TypeExtra])
                _lhsOupTypes :: ([Maybe TypeExtra])
                _lhsOannotatedTree :: CaseScalarExprListScalarExprPairList
                _lhsOoriginalTree :: CaseScalarExprListScalarExprPairList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 541, column 9)
                _lhsOwhenTypes =
                    ({-# LINE 541 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 4399 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 542, column 9)
                _lhsOthenTypes =
                    ({-# LINE 542 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 4405 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 543, column 9)
                _lhsOupTypes =
                    ({-# LINE 543 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 4411 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 4417 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 4423 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4429 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4435 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOthenTypes,_lhsOupTypes,_lhsOwhenTypes)))
  -- Constraint --------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : Constraint 
           originalTree         : Constraint 
     alternatives:
        alternative UniqueConstraint:
           child ann            : Annotation 
           child name           : {String}
           child x              : {[NameComponent]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative PrimaryKeyConstraint:
           child ann            : Annotation 
           child name           : {String}
           child x              : {[NameComponent]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CheckConstraint:
           child ann            : Annotation 
           child name           : {String}
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ReferenceConstraint:
           child ann            : Annotation 
           child name           : {String}
           child atts           : {[NameComponent]}
           child table          : Name 
           child tableAtts      : {[NameComponent]}
           child onUpdate       : {Cascade}
           child onDelete       : {Cascade}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data Constraint = UniqueConstraint (Annotation) (String) (([NameComponent]))
                  | PrimaryKeyConstraint (Annotation) (String) (([NameComponent]))
                  | CheckConstraint (Annotation) (String) (ScalarExpr)
                  | ReferenceConstraint (Annotation) (String) (([NameComponent])) (Name) (([NameComponent])) (Cascade) (Cascade)
                  deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_Constraint :: Constraint ->
                    T_Constraint
  _sem_Constraint (UniqueConstraint _ann _name _x) =
      (_sem_Constraint_UniqueConstraint (_sem_Annotation _ann) _name _x)
  _sem_Constraint (PrimaryKeyConstraint _ann _name _x) =
      (_sem_Constraint_PrimaryKeyConstraint (_sem_Annotation _ann) _name _x)
  _sem_Constraint (CheckConstraint _ann _name _expr) =
      (_sem_Constraint_CheckConstraint (_sem_Annotation _ann) _name (_sem_ScalarExpr _expr))
  _sem_Constraint (ReferenceConstraint _ann _name _atts _table _tableAtts _onUpdate _onDelete) =
      (_sem_Constraint_ReferenceConstraint (_sem_Annotation _ann) _name _atts (_sem_Name _table) _tableAtts _onUpdate _onDelete)
  -- semantic domain
  type T_Constraint = Catalog ->
                      TypeCheckFlags ->
                      (Maybe TypeExtra) ->
                      ( Constraint,Constraint)
  data Inh_Constraint = Inh_Constraint {_cat_Inh_Constraint :: Catalog,_flags_Inh_Constraint :: TypeCheckFlags,_imCast_Inh_Constraint :: (Maybe TypeExtra)}
  data Syn_Constraint = Syn_Constraint {_annotatedTree_Syn_Constraint :: Constraint,_originalTree_Syn_Constraint :: Constraint}
  _wrap_Constraint :: T_Constraint ->
                     Inh_Constraint ->
                     Syn_Constraint
  _wrap_Constraint sem (Inh_Constraint _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_Constraint _lhsOannotatedTree _lhsOoriginalTree))
  _sem_Constraint_UniqueConstraint :: T_Annotation ->
                                     String ->
                                     ([NameComponent]) ->
                                     T_Constraint
  _sem_Constraint_UniqueConstraint ann_ name_ x_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Constraint
                _lhsOoriginalTree :: Constraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 62, column 35)
                _annOtpe =
                    ({-# LINE 62 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 4531 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     UniqueConstraint _annIannotatedTree name_ x_
                     {-# LINE 4537 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     UniqueConstraint _annIoriginalTree name_ x_
                     {-# LINE 4543 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4549 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4555 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4561 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4567 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4573 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Constraint_PrimaryKeyConstraint :: T_Annotation ->
                                         String ->
                                         ([NameComponent]) ->
                                         T_Constraint
  _sem_Constraint_PrimaryKeyConstraint ann_ name_ x_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Constraint
                _lhsOoriginalTree :: Constraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 59, column 39)
                _annOtpe =
                    ({-# LINE 59 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 4598 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PrimaryKeyConstraint _annIannotatedTree name_ x_
                     {-# LINE 4604 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PrimaryKeyConstraint _annIoriginalTree name_ x_
                     {-# LINE 4610 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4616 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4622 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4628 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4634 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4640 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Constraint_CheckConstraint :: T_Annotation ->
                                    String ->
                                    T_ScalarExpr ->
                                    T_Constraint
  _sem_Constraint_CheckConstraint ann_ name_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Constraint
                _lhsOoriginalTree :: Constraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 55, column 34)
                _annOtpe =
                    ({-# LINE 55 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 4677 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 56, column 34)
                _exprOdownEnv =
                    ({-# LINE 56 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 4683 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 57, column 34)
                _exprOexpectedCast =
                    ({-# LINE 57 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 4689 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 58, column 34)
                _exprOexpectedType =
                    ({-# LINE 58 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 4695 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 137, column 23)
                _exprOodbcFunction =
                    ({-# LINE 137 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 4701 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 810, column 34)
                _exprOassignmentCastContext =
                    ({-# LINE 810 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 4707 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CheckConstraint _annIannotatedTree name_ _exprIannotatedTree
                     {-# LINE 4713 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CheckConstraint _annIoriginalTree name_ _exprIoriginalTree
                     {-# LINE 4719 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4725 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4731 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4737 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4743 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4749 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4755 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4761 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4767 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Constraint_ReferenceConstraint :: T_Annotation ->
                                        String ->
                                        ([NameComponent]) ->
                                        T_Name ->
                                        ([NameComponent]) ->
                                        Cascade ->
                                        Cascade ->
                                        T_Constraint
  _sem_Constraint_ReferenceConstraint ann_ name_ atts_ table_ tableAtts_ onUpdate_ onDelete_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _tableOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Constraint
                _lhsOoriginalTree :: Constraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tableOcat :: Catalog
                _tableOflags :: TypeCheckFlags
                _tableOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tableIannotatedTree :: Name
                _tableIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 60, column 38)
                _annOtpe =
                    ({-# LINE 60 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 4804 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 61, column 38)
                _tableOtpe =
                    ({-# LINE 61 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 4810 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ReferenceConstraint _annIannotatedTree name_ atts_ _tableIannotatedTree tableAtts_ onUpdate_ onDelete_
                     {-# LINE 4816 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ReferenceConstraint _annIoriginalTree name_ atts_ _tableIoriginalTree tableAtts_ onUpdate_ onDelete_
                     {-# LINE 4822 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4828 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4834 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4840 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4846 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4852 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4858 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4864 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4870 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tableIannotatedTree,_tableIoriginalTree) =
                    table_ _tableOcat _tableOflags _tableOimCast _tableOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ConstraintList ----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ConstraintList 
           originalTree         : ConstraintList 
     alternatives:
        alternative Cons:
           child hd             : Constraint 
           child tl             : ConstraintList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ConstraintList = [Constraint]
  -- cata
  _sem_ConstraintList :: ConstraintList ->
                        T_ConstraintList
  _sem_ConstraintList list =
      (Prelude.foldr _sem_ConstraintList_Cons _sem_ConstraintList_Nil (Prelude.map _sem_Constraint list))
  -- semantic domain
  type T_ConstraintList = Catalog ->
                          TypeCheckFlags ->
                          (Maybe TypeExtra) ->
                          ( ConstraintList,ConstraintList)
  data Inh_ConstraintList = Inh_ConstraintList {_cat_Inh_ConstraintList :: Catalog,_flags_Inh_ConstraintList :: TypeCheckFlags,_imCast_Inh_ConstraintList :: (Maybe TypeExtra)}
  data Syn_ConstraintList = Syn_ConstraintList {_annotatedTree_Syn_ConstraintList :: ConstraintList,_originalTree_Syn_ConstraintList :: ConstraintList}
  _wrap_ConstraintList :: T_ConstraintList ->
                         Inh_ConstraintList ->
                         Syn_ConstraintList
  _wrap_ConstraintList sem (Inh_ConstraintList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ConstraintList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ConstraintList_Cons :: T_Constraint ->
                             T_ConstraintList ->
                             T_ConstraintList
  _sem_ConstraintList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ConstraintList
                _lhsOoriginalTree :: ConstraintList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: Constraint
                _hdIoriginalTree :: Constraint
                _tlIannotatedTree :: ConstraintList
                _tlIoriginalTree :: ConstraintList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 4941 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 4947 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 4953 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 4959 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4965 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4971 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4977 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 4983 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 4989 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 4995 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_ConstraintList_Nil :: T_ConstraintList
  _sem_ConstraintList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ConstraintList
                _lhsOoriginalTree :: ConstraintList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 5013 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 5019 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5025 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5031 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- FnBody ------------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : FnBody 
           originalTree         : FnBody 
     alternatives:
        alternative SqlFnBody:
           child ann            : Annotation 
           child sts            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative PlpgsqlFnBody:
           child ann            : Annotation 
           child blk            : Statement 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data FnBody = SqlFnBody (Annotation) (StatementList)
              | PlpgsqlFnBody (Annotation) (Statement)
              deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_FnBody :: FnBody ->
                T_FnBody
  _sem_FnBody (SqlFnBody _ann _sts) =
      (_sem_FnBody_SqlFnBody (_sem_Annotation _ann) (_sem_StatementList _sts))
  _sem_FnBody (PlpgsqlFnBody _ann _blk) =
      (_sem_FnBody_PlpgsqlFnBody (_sem_Annotation _ann) (_sem_Statement _blk))
  -- semantic domain
  type T_FnBody = Catalog ->
                  TypeCheckFlags ->
                  (Maybe TypeExtra) ->
                  ( FnBody,FnBody)
  data Inh_FnBody = Inh_FnBody {_cat_Inh_FnBody :: Catalog,_flags_Inh_FnBody :: TypeCheckFlags,_imCast_Inh_FnBody :: (Maybe TypeExtra)}
  data Syn_FnBody = Syn_FnBody {_annotatedTree_Syn_FnBody :: FnBody,_originalTree_Syn_FnBody :: FnBody}
  _wrap_FnBody :: T_FnBody ->
                 Inh_FnBody ->
                 Syn_FnBody
  _wrap_FnBody sem (Inh_FnBody _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_FnBody _lhsOannotatedTree _lhsOoriginalTree))
  _sem_FnBody_SqlFnBody :: T_Annotation ->
                          T_StatementList ->
                          T_FnBody
  _sem_FnBody_SqlFnBody ann_ sts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: FnBody
                _lhsOoriginalTree :: FnBody
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _stsOcat :: Catalog
                _stsOflags :: TypeCheckFlags
                _stsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _stsIannotatedTree :: StatementList
                _stsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 64, column 24)
                _annOtpe =
                    ({-# LINE 64 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 5105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SqlFnBody _annIannotatedTree _stsIannotatedTree
                     {-# LINE 5111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SqlFnBody _annIoriginalTree _stsIoriginalTree
                     {-# LINE 5117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5129 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5135 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5141 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5147 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5153 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5159 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5165 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _stsIannotatedTree,_stsIoriginalTree) =
                    sts_ _stsOcat _stsOflags _stsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_FnBody_PlpgsqlFnBody :: T_Annotation ->
                              T_Statement ->
                              T_FnBody
  _sem_FnBody_PlpgsqlFnBody ann_ blk_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: FnBody
                _lhsOoriginalTree :: FnBody
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _blkOcat :: Catalog
                _blkOflags :: TypeCheckFlags
                _blkOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _blkIannotatedTree :: Statement
                _blkIoriginalTree :: Statement
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 63, column 28)
                _annOtpe =
                    ({-# LINE 63 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 5196 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PlpgsqlFnBody _annIannotatedTree _blkIannotatedTree
                     {-# LINE 5202 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PlpgsqlFnBody _annIoriginalTree _blkIoriginalTree
                     {-# LINE 5208 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5214 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5220 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5226 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5232 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5238 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _blkOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5244 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _blkOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5250 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _blkOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5256 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _blkIannotatedTree,_blkIoriginalTree) =
                    blk_ _blkOcat _blkOflags _blkOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- InList ------------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe TypeExtra
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : InList 
           listType             : Either [TypeError] TypeExtra
           originalTree         : InList 
     alternatives:
        alternative InList:
           child ann            : Annotation 
           child exprs          : ScalarExprList 
           visit 0:
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative InQueryExpr:
           child ann            : Annotation 
           child sel            : QueryExpr 
           visit 0:
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
  -}
  data InList = InList (Annotation) (ScalarExprList)
              | InQueryExpr (Annotation) (QueryExpr)
              deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_InList :: InList ->
                T_InList
  _sem_InList (InList _ann _exprs) =
      (_sem_InList_InList (_sem_Annotation _ann) (_sem_ScalarExprList _exprs))
  _sem_InList (InQueryExpr _ann _sel) =
      (_sem_InList_InQueryExpr (_sem_Annotation _ann) (_sem_QueryExpr _sel))
  -- semantic domain
  type T_InList = Catalog ->
                  Environment ->
                  Bool ->
                  (Maybe TypeExtra) ->
                  TypeCheckFlags ->
                  (Maybe TypeExtra) ->
                  ( InList,(Either [TypeError] TypeExtra),InList)
  data Inh_InList = Inh_InList {_cat_Inh_InList :: Catalog,_downEnv_Inh_InList :: Environment,_expectedCast_Inh_InList :: Bool,_expectedType_Inh_InList :: (Maybe TypeExtra),_flags_Inh_InList :: TypeCheckFlags,_imCast_Inh_InList :: (Maybe TypeExtra)}
  data Syn_InList = Syn_InList {_annotatedTree_Syn_InList :: InList,_listType_Syn_InList :: (Either [TypeError] TypeExtra),_originalTree_Syn_InList :: InList}
  _wrap_InList :: T_InList ->
                 Inh_InList ->
                 Syn_InList
  _wrap_InList sem (Inh_InList _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_InList _lhsOannotatedTree _lhsOlistType _lhsOoriginalTree))
  _sem_InList_InList :: T_Annotation ->
                       T_ScalarExprList ->
                       T_InList
  _sem_InList_InList ann_ exprs_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOlistType :: (Either [TypeError] TypeExtra)
                _exprsOexpectedTypes :: ([TypeExtra])
                _exprsOexpectedCast :: Bool
                _annOimCast :: (Maybe TypeExtra)
                _exprsOassignmentCastContext :: Bool
                _lhsOannotatedTree :: InList
                _lhsOoriginalTree :: InList
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOtpe :: (Either [TypeError] TypeExtra)
                _exprsOcat :: Catalog
                _exprsOdownEnv :: Environment
                _exprsOflags :: TypeCheckFlags
                _exprsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprsIannotatedTree :: ScalarExprList
                _exprsIoriginalTree :: ScalarExprList
                _exprsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 219, column 9)
                _tpe =
                    ({-# LINE 219 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Left []
                     {-# LINE 5352 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 682, column 9)
                _lhsOlistType =
                    ({-# LINE 682 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     mapM (maybe (Left []) Right) _exprsIupTypes
                     >>= resolveResultSetTypeExtra _lhsIcat
                     {-# LINE 5359 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 684, column 9)
                _exprsOexpectedTypes =
                    ({-# LINE 684 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe [] repeat _lhsIexpectedType
                     {-# LINE 5365 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 686, column 9)
                _exprsOexpectedCast =
                    ({-# LINE 686 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5371 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 782, column 12)
                _annOimCast =
                    ({-# LINE 782 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 5377 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 811, column 21)
                _exprsOassignmentCastContext =
                    ({-# LINE 811 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5383 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     InList _annIannotatedTree _exprsIannotatedTree
                     {-# LINE 5389 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     InList _annIoriginalTree _exprsIoriginalTree
                     {-# LINE 5395 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5401 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5407 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5413 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5419 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 5425 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5431 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprsOdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 5437 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5443 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5449 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprsIannotatedTree,_exprsIoriginalTree,_exprsIupTypes) =
                    exprs_ _exprsOassignmentCastContext _exprsOcat _exprsOdownEnv _exprsOexpectedCast _exprsOexpectedTypes _exprsOflags _exprsOimCast
            in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
  _sem_InList_InQueryExpr :: T_Annotation ->
                            T_QueryExpr ->
                            T_InList
  _sem_InList_InQueryExpr ann_ sel_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _selOouterDownEnv :: (Maybe Environment)
                _lhsOlistType :: (Either [TypeError] TypeExtra)
                _selOexpectedType :: (Maybe [TypeExtra])
                _annOimCast :: (Maybe TypeExtra)
                _selOassignmentCastContext :: Bool
                _lhsOannotatedTree :: InList
                _lhsOoriginalTree :: InList
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOtpe :: (Either [TypeError] TypeExtra)
                _selOcat :: Catalog
                _selOflags :: TypeCheckFlags
                _selOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selIannotatedTree :: QueryExpr
                _selIoriginalTree :: QueryExpr
                _selIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 97, column 17)
                _selOouterDownEnv =
                    ({-# LINE 97 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Nothing
                     {-# LINE 5488 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 219, column 9)
                _tpe =
                    ({-# LINE 219 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Left []
                     {-# LINE 5494 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 689, column 9)
                _lhsOlistType =
                    ({-# LINE 689 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     st <- maybe (Left []) Right (map snd <$> _selIupType)
                     case length st of
                               0 -> Left [InternalError
                                          "got subquery with no columns? in inselect"]
                               1 -> Right $ head st
                               _ -> Right $ mkTypeExtra $ AnonymousCompositeType
                                       $ map teType st
                     {-# LINE 5507 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 699, column 9)
                _selOexpectedType =
                    ({-# LINE 699 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     liftM (map snd) _selIupType
                     {-# LINE 5513 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 783, column 17)
                _annOimCast =
                    ({-# LINE 783 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 5519 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 812, column 26)
                _selOassignmentCastContext =
                    ({-# LINE 812 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5525 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     InQueryExpr _annIannotatedTree _selIannotatedTree
                     {-# LINE 5531 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     InQueryExpr _annIoriginalTree _selIoriginalTree
                     {-# LINE 5537 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5543 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5549 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5555 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5561 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 5567 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5573 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5579 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5585 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selIannotatedTree,_selIoriginalTree,_selIupType) =
                    sel_ _selOassignmentCastContext _selOcat _selOexpectedType _selOflags _selOimCast _selOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOlistType,_lhsOoriginalTree)))
  -- JoinExpr ----------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : JoinExpr 
           originalTree         : JoinExpr 
     alternatives:
        alternative JoinOn:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           visit 0:
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative JoinUsing:
           child ann            : Annotation 
           child x              : {[NameComponent]}
           visit 0:
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
  -}
  data JoinExpr = JoinOn (Annotation) (ScalarExpr)
                | JoinUsing (Annotation) (([NameComponent]))
                deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_JoinExpr :: JoinExpr ->
                  T_JoinExpr
  _sem_JoinExpr (JoinOn _ann _expr) =
      (_sem_JoinExpr_JoinOn (_sem_Annotation _ann) (_sem_ScalarExpr _expr))
  _sem_JoinExpr (JoinUsing _ann _x) =
      (_sem_JoinExpr_JoinUsing (_sem_Annotation _ann) _x)
  -- semantic domain
  type T_JoinExpr = Catalog ->
                    Environment ->
                    TypeCheckFlags ->
                    (Maybe TypeExtra) ->
                    ( JoinExpr,JoinExpr)
  data Inh_JoinExpr = Inh_JoinExpr {_cat_Inh_JoinExpr :: Catalog,_downEnv_Inh_JoinExpr :: Environment,_flags_Inh_JoinExpr :: TypeCheckFlags,_imCast_Inh_JoinExpr :: (Maybe TypeExtra)}
  data Syn_JoinExpr = Syn_JoinExpr {_annotatedTree_Syn_JoinExpr :: JoinExpr,_originalTree_Syn_JoinExpr :: JoinExpr}
  _wrap_JoinExpr :: T_JoinExpr ->
                   Inh_JoinExpr ->
                   Syn_JoinExpr
  _wrap_JoinExpr sem (Inh_JoinExpr _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast
       in  (Syn_JoinExpr _lhsOannotatedTree _lhsOoriginalTree))
  _sem_JoinExpr_JoinOn :: T_Annotation ->
                         T_ScalarExpr ->
                         T_JoinExpr
  _sem_JoinExpr_JoinOn ann_ expr_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _exprOodbcFunction :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOexpectedCast :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: JoinExpr
                _lhsOoriginalTree :: JoinExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOcat :: Catalog
                _exprOdownEnv :: Environment
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 223, column 9)
                _tpe =
                    ({-# LINE 223 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Left []
                     {-# LINE 5675 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 140, column 14)
                _exprOodbcFunction =
                    ({-# LINE 140 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5681 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 746, column 7)
                _exprOexpectedType =
                    ({-# LINE 746 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     bt <- ansiTypeNameToDialect (tcfDialect _lhsIflags) "boolean"
                     Just $ TypeExtra (ScalarType bt) Nothing Nothing
                          $ maybe False teNullable _exprIupType
                     {-# LINE 5690 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 750, column 7)
                _exprOexpectedCast =
                    ({-# LINE 750 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5696 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 813, column 23)
                _exprOassignmentCastContext =
                    ({-# LINE 813 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5702 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     JoinOn _annIannotatedTree _exprIannotatedTree
                     {-# LINE 5708 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     JoinOn _annIoriginalTree _exprIoriginalTree
                     {-# LINE 5714 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5720 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5726 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5732 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5738 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5744 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 5750 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5756 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 5762 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5768 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5774 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_JoinExpr_JoinUsing :: T_Annotation ->
                            ([NameComponent]) ->
                            T_JoinExpr
  _sem_JoinExpr_JoinUsing ann_ x_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: JoinExpr
                _lhsOoriginalTree :: JoinExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 223, column 9)
                _tpe =
                    ({-# LINE 223 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Left []
                     {-# LINE 5801 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     JoinUsing _annIannotatedTree x_
                     {-# LINE 5807 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     JoinUsing _annIoriginalTree x_
                     {-# LINE 5813 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5819 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5825 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5831 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5837 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5843 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 5849 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- MaybeBoolExpr -----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : MaybeBoolExpr 
           originalTree         : MaybeBoolExpr 
     alternatives:
        alternative Just:
           child just           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nothing:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type MaybeBoolExpr = Maybe (ScalarExpr)
  -- cata
  _sem_MaybeBoolExpr :: MaybeBoolExpr ->
                       T_MaybeBoolExpr
  _sem_MaybeBoolExpr (Prelude.Just x) =
      (_sem_MaybeBoolExpr_Just (_sem_ScalarExpr x))
  _sem_MaybeBoolExpr Prelude.Nothing =
      _sem_MaybeBoolExpr_Nothing
  -- semantic domain
  type T_MaybeBoolExpr = Catalog ->
                         Environment ->
                         TypeCheckFlags ->
                         (Maybe TypeExtra) ->
                         ( MaybeBoolExpr,MaybeBoolExpr)
  data Inh_MaybeBoolExpr = Inh_MaybeBoolExpr {_cat_Inh_MaybeBoolExpr :: Catalog,_downEnv_Inh_MaybeBoolExpr :: Environment,_flags_Inh_MaybeBoolExpr :: TypeCheckFlags,_imCast_Inh_MaybeBoolExpr :: (Maybe TypeExtra)}
  data Syn_MaybeBoolExpr = Syn_MaybeBoolExpr {_annotatedTree_Syn_MaybeBoolExpr :: MaybeBoolExpr,_originalTree_Syn_MaybeBoolExpr :: MaybeBoolExpr}
  _wrap_MaybeBoolExpr :: T_MaybeBoolExpr ->
                        Inh_MaybeBoolExpr ->
                        Syn_MaybeBoolExpr
  _wrap_MaybeBoolExpr sem (Inh_MaybeBoolExpr _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast
       in  (Syn_MaybeBoolExpr _lhsOannotatedTree _lhsOoriginalTree))
  _sem_MaybeBoolExpr_Just :: T_ScalarExpr ->
                            T_MaybeBoolExpr
  _sem_MaybeBoolExpr_Just just_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _justOodbcFunction :: Bool
                _justOexpectedType :: (Maybe TypeExtra)
                _justOexpectedCast :: Bool
                _justOassignmentCastContext :: Bool
                _lhsOannotatedTree :: MaybeBoolExpr
                _lhsOoriginalTree :: MaybeBoolExpr
                _justOcat :: Catalog
                _justOdownEnv :: Environment
                _justOflags :: TypeCheckFlags
                _justOimCast :: (Maybe TypeExtra)
                _justIannotatedTree :: ScalarExpr
                _justIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _justIoriginalTree :: ScalarExpr
                _justIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 143, column 12)
                _justOodbcFunction =
                    ({-# LINE 143 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5923 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 762, column 7)
                _justOexpectedType =
                    ({-# LINE 762 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 5929 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 763, column 7)
                _justOexpectedCast =
                    ({-# LINE 763 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5935 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 814, column 26)
                _justOassignmentCastContext =
                    ({-# LINE 814 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 5941 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIannotatedTree
                     {-# LINE 5947 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIoriginalTree
                     {-# LINE 5953 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 5959 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 5965 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 5971 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 5977 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 5983 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 5989 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _justIannotatedTree,_justIcolExprs,_justIoriginalTree,_justIupType) =
                    just_ _justOassignmentCastContext _justOcat _justOdownEnv _justOexpectedCast _justOexpectedType _justOflags _justOimCast _justOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_MaybeBoolExpr_Nothing :: T_MaybeBoolExpr
  _sem_MaybeBoolExpr_Nothing =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: MaybeBoolExpr
                _lhsOoriginalTree :: MaybeBoolExpr
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6006 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6012 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- MaybeNameComponentList --------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : MaybeNameComponentList 
           originalTree         : MaybeNameComponentList 
     alternatives:
        alternative Just:
           child just           : NameComponentList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nothing:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type MaybeNameComponentList = Maybe (NameComponentList)
  -- cata
  _sem_MaybeNameComponentList :: MaybeNameComponentList ->
                                T_MaybeNameComponentList
  _sem_MaybeNameComponentList (Prelude.Just x) =
      (_sem_MaybeNameComponentList_Just (_sem_NameComponentList x))
  _sem_MaybeNameComponentList Prelude.Nothing =
      _sem_MaybeNameComponentList_Nothing
  -- semantic domain
  type T_MaybeNameComponentList = Catalog ->
                                  TypeCheckFlags ->
                                  (Maybe TypeExtra) ->
                                  ( MaybeNameComponentList,MaybeNameComponentList)
  data Inh_MaybeNameComponentList = Inh_MaybeNameComponentList {_cat_Inh_MaybeNameComponentList :: Catalog,_flags_Inh_MaybeNameComponentList :: TypeCheckFlags,_imCast_Inh_MaybeNameComponentList :: (Maybe TypeExtra)}
  data Syn_MaybeNameComponentList = Syn_MaybeNameComponentList {_annotatedTree_Syn_MaybeNameComponentList :: MaybeNameComponentList,_originalTree_Syn_MaybeNameComponentList :: MaybeNameComponentList}
  _wrap_MaybeNameComponentList :: T_MaybeNameComponentList ->
                                 Inh_MaybeNameComponentList ->
                                 Syn_MaybeNameComponentList
  _wrap_MaybeNameComponentList sem (Inh_MaybeNameComponentList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_MaybeNameComponentList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_MaybeNameComponentList_Just :: T_NameComponentList ->
                                     T_MaybeNameComponentList
  _sem_MaybeNameComponentList_Just just_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: MaybeNameComponentList
                _lhsOoriginalTree :: MaybeNameComponentList
                _justOcat :: Catalog
                _justOflags :: TypeCheckFlags
                _justOimCast :: (Maybe TypeExtra)
                _justIannotatedTree :: NameComponentList
                _justIoriginalTree :: NameComponentList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIannotatedTree
                     {-# LINE 6086 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIoriginalTree
                     {-# LINE 6092 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6098 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6104 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 6110 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 6116 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 6122 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _justIannotatedTree,_justIoriginalTree) =
                    just_ _justOcat _justOflags _justOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_MaybeNameComponentList_Nothing :: T_MaybeNameComponentList
  _sem_MaybeNameComponentList_Nothing =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: MaybeNameComponentList
                _lhsOoriginalTree :: MaybeNameComponentList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6138 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6144 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6150 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6156 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- MaybeScalarExpr ---------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe TypeExtra
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : MaybeScalarExpr 
           originalTree         : MaybeScalarExpr 
           upType               : Maybe TypeExtra
     alternatives:
        alternative Just:
           child just           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nothing:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type MaybeScalarExpr = Maybe (ScalarExpr)
  -- cata
  _sem_MaybeScalarExpr :: MaybeScalarExpr ->
                         T_MaybeScalarExpr
  _sem_MaybeScalarExpr (Prelude.Just x) =
      (_sem_MaybeScalarExpr_Just (_sem_ScalarExpr x))
  _sem_MaybeScalarExpr Prelude.Nothing =
      _sem_MaybeScalarExpr_Nothing
  -- semantic domain
  type T_MaybeScalarExpr = Bool ->
                           Catalog ->
                           Environment ->
                           Bool ->
                           (Maybe TypeExtra) ->
                           TypeCheckFlags ->
                           (Maybe TypeExtra) ->
                           ( MaybeScalarExpr,MaybeScalarExpr,(Maybe TypeExtra))
  data Inh_MaybeScalarExpr = Inh_MaybeScalarExpr {_assignmentCastContext_Inh_MaybeScalarExpr :: Bool,_cat_Inh_MaybeScalarExpr :: Catalog,_downEnv_Inh_MaybeScalarExpr :: Environment,_expectedCast_Inh_MaybeScalarExpr :: Bool,_expectedType_Inh_MaybeScalarExpr :: (Maybe TypeExtra),_flags_Inh_MaybeScalarExpr :: TypeCheckFlags,_imCast_Inh_MaybeScalarExpr :: (Maybe TypeExtra)}
  data Syn_MaybeScalarExpr = Syn_MaybeScalarExpr {_annotatedTree_Syn_MaybeScalarExpr :: MaybeScalarExpr,_originalTree_Syn_MaybeScalarExpr :: MaybeScalarExpr,_upType_Syn_MaybeScalarExpr :: (Maybe TypeExtra)}
  _wrap_MaybeScalarExpr :: T_MaybeScalarExpr ->
                          Inh_MaybeScalarExpr ->
                          Syn_MaybeScalarExpr
  _wrap_MaybeScalarExpr sem (Inh_MaybeScalarExpr _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_MaybeScalarExpr _lhsOannotatedTree _lhsOoriginalTree _lhsOupType))
  _sem_MaybeScalarExpr_Just :: T_ScalarExpr ->
                              T_MaybeScalarExpr
  _sem_MaybeScalarExpr_Just just_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _justOodbcFunction :: Bool
                _lhsOannotatedTree :: MaybeScalarExpr
                _lhsOoriginalTree :: MaybeScalarExpr
                _lhsOupType :: (Maybe TypeExtra)
                _justOassignmentCastContext :: Bool
                _justOcat :: Catalog
                _justOdownEnv :: Environment
                _justOexpectedCast :: Bool
                _justOexpectedType :: (Maybe TypeExtra)
                _justOflags :: TypeCheckFlags
                _justOimCast :: (Maybe TypeExtra)
                _justIannotatedTree :: ScalarExpr
                _justIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _justIoriginalTree :: ScalarExpr
                _justIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 146, column 12)
                _justOodbcFunction =
                    ({-# LINE 146 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 6239 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIannotatedTree
                     {-# LINE 6245 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIoriginalTree
                     {-# LINE 6251 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6257 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6263 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOupType =
                    ({-# LINE 109 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _justIupType
                     {-# LINE 6269 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 6275 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 6281 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 6287 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOexpectedCast =
                    ({-# LINE 111 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 6293 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOexpectedType =
                    ({-# LINE 110 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 6299 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 6305 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 6311 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _justIannotatedTree,_justIcolExprs,_justIoriginalTree,_justIupType) =
                    just_ _justOassignmentCastContext _justOcat _justOdownEnv _justOexpectedCast _justOexpectedType _justOflags _justOimCast _justOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  _sem_MaybeScalarExpr_Nothing :: T_MaybeScalarExpr
  _sem_MaybeScalarExpr_Nothing =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupType :: (Maybe TypeExtra)
                _lhsOannotatedTree :: MaybeScalarExpr
                _lhsOoriginalTree :: MaybeScalarExpr
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 120, column 15)
                _lhsOupType =
                    ({-# LINE 120 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 6332 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6338 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6344 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6350 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6356 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  -- MaybeSelectList ---------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : MaybeSelectList 
           originalTree         : MaybeSelectList 
     alternatives:
        alternative Just:
           child just           : SelectList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nothing:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type MaybeSelectList = Maybe (SelectList)
  -- cata
  _sem_MaybeSelectList :: MaybeSelectList ->
                         T_MaybeSelectList
  _sem_MaybeSelectList (Prelude.Just x) =
      (_sem_MaybeSelectList_Just (_sem_SelectList x))
  _sem_MaybeSelectList Prelude.Nothing =
      _sem_MaybeSelectList_Nothing
  -- semantic domain
  type T_MaybeSelectList = Catalog ->
                           Environment ->
                           TypeCheckFlags ->
                           (Maybe TypeExtra) ->
                           ( MaybeSelectList,MaybeSelectList)
  data Inh_MaybeSelectList = Inh_MaybeSelectList {_cat_Inh_MaybeSelectList :: Catalog,_downEnv_Inh_MaybeSelectList :: Environment,_flags_Inh_MaybeSelectList :: TypeCheckFlags,_imCast_Inh_MaybeSelectList :: (Maybe TypeExtra)}
  data Syn_MaybeSelectList = Syn_MaybeSelectList {_annotatedTree_Syn_MaybeSelectList :: MaybeSelectList,_originalTree_Syn_MaybeSelectList :: MaybeSelectList}
  _wrap_MaybeSelectList :: T_MaybeSelectList ->
                          Inh_MaybeSelectList ->
                          Syn_MaybeSelectList
  _wrap_MaybeSelectList sem (Inh_MaybeSelectList _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast
       in  (Syn_MaybeSelectList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_MaybeSelectList_Just :: T_SelectList ->
                              T_MaybeSelectList
  _sem_MaybeSelectList_Just just_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _justOexpectedCast :: Bool
                _justOexpectedType :: (Maybe [TypeExtra])
                _justOassignmentCastContext :: Bool
                _lhsOannotatedTree :: MaybeSelectList
                _lhsOoriginalTree :: MaybeSelectList
                _justOcat :: Catalog
                _justOdownEnv :: Environment
                _justOflags :: TypeCheckFlags
                _justOimCast :: (Maybe TypeExtra)
                _justIannotatedTree :: SelectList
                _justIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _justIoriginalTree :: SelectList
                _justIupEnv :: Environment
                _justIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 167, column 10)
                _justOexpectedCast =
                    ({-# LINE 167 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     False
                     {-# LINE 6428 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 168, column 10)
                _justOexpectedType =
                    ({-# LINE 168 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     Nothing
                     {-# LINE 6434 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 815, column 28)
                _justOassignmentCastContext =
                    ({-# LINE 815 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 6440 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIannotatedTree
                     {-# LINE 6446 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIoriginalTree
                     {-# LINE 6452 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6458 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6464 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 6470 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOdownEnv =
                    ({-# LINE 156 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 6476 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 6482 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 6488 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _justIannotatedTree,_justIcolExprs,_justIoriginalTree,_justIupEnv,_justIupType) =
                    just_ _justOassignmentCastContext _justOcat _justOdownEnv _justOexpectedCast _justOexpectedType _justOflags _justOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_MaybeSelectList_Nothing :: T_MaybeSelectList
  _sem_MaybeSelectList_Nothing =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: MaybeSelectList
                _lhsOoriginalTree :: MaybeSelectList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6505 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6511 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6517 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6523 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- MaybeTablePartitionDef --------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : MaybeTablePartitionDef 
           originalTree         : MaybeTablePartitionDef 
     alternatives:
        alternative Just:
           child just           : TablePartitionDef 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nothing:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type MaybeTablePartitionDef = Maybe (TablePartitionDef)
  -- cata
  _sem_MaybeTablePartitionDef :: MaybeTablePartitionDef ->
                                T_MaybeTablePartitionDef
  _sem_MaybeTablePartitionDef (Prelude.Just x) =
      (_sem_MaybeTablePartitionDef_Just (_sem_TablePartitionDef x))
  _sem_MaybeTablePartitionDef Prelude.Nothing =
      _sem_MaybeTablePartitionDef_Nothing
  -- semantic domain
  type T_MaybeTablePartitionDef = Catalog ->
                                  TypeCheckFlags ->
                                  (Maybe TypeExtra) ->
                                  ( MaybeTablePartitionDef,MaybeTablePartitionDef)
  data Inh_MaybeTablePartitionDef = Inh_MaybeTablePartitionDef {_cat_Inh_MaybeTablePartitionDef :: Catalog,_flags_Inh_MaybeTablePartitionDef :: TypeCheckFlags,_imCast_Inh_MaybeTablePartitionDef :: (Maybe TypeExtra)}
  data Syn_MaybeTablePartitionDef = Syn_MaybeTablePartitionDef {_annotatedTree_Syn_MaybeTablePartitionDef :: MaybeTablePartitionDef,_originalTree_Syn_MaybeTablePartitionDef :: MaybeTablePartitionDef}
  _wrap_MaybeTablePartitionDef :: T_MaybeTablePartitionDef ->
                                 Inh_MaybeTablePartitionDef ->
                                 Syn_MaybeTablePartitionDef
  _wrap_MaybeTablePartitionDef sem (Inh_MaybeTablePartitionDef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_MaybeTablePartitionDef _lhsOannotatedTree _lhsOoriginalTree))
  _sem_MaybeTablePartitionDef_Just :: T_TablePartitionDef ->
                                     T_MaybeTablePartitionDef
  _sem_MaybeTablePartitionDef_Just just_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: MaybeTablePartitionDef
                _lhsOoriginalTree :: MaybeTablePartitionDef
                _justOcat :: Catalog
                _justOflags :: TypeCheckFlags
                _justOimCast :: (Maybe TypeExtra)
                _justIannotatedTree :: TablePartitionDef
                _justIoriginalTree :: TablePartitionDef
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIannotatedTree
                     {-# LINE 6585 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIoriginalTree
                     {-# LINE 6591 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6597 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6603 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 6609 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 6615 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 6621 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _justIannotatedTree,_justIoriginalTree) =
                    just_ _justOcat _justOflags _justOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_MaybeTablePartitionDef_Nothing :: T_MaybeTablePartitionDef
  _sem_MaybeTablePartitionDef_Nothing =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: MaybeTablePartitionDef
                _lhsOoriginalTree :: MaybeTablePartitionDef
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6637 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 6643 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6649 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6655 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- Name --------------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
           tpe                  : Either [TypeError] TypeExtra
        synthesized attributes:
           annotatedTree        : Name 
           originalTree         : Name 
     alternatives:
        alternative Name:
           child ann            : Annotation 
           child is             : {[NameComponent]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AntiName:
           child string         : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data Name = Name (Annotation) (([NameComponent]))
            | AntiName (String)
            deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_Name :: Name ->
              T_Name
  _sem_Name (Name _ann _is) =
      (_sem_Name_Name (_sem_Annotation _ann) _is)
  _sem_Name (AntiName _string) =
      (_sem_Name_AntiName _string)
  -- semantic domain
  type T_Name = Catalog ->
                TypeCheckFlags ->
                (Maybe TypeExtra) ->
                (Either [TypeError] TypeExtra) ->
                ( Name,Name)
  data Inh_Name = Inh_Name {_cat_Inh_Name :: Catalog,_flags_Inh_Name :: TypeCheckFlags,_imCast_Inh_Name :: (Maybe TypeExtra),_tpe_Inh_Name :: (Either [TypeError] TypeExtra)}
  data Syn_Name = Syn_Name {_annotatedTree_Syn_Name :: Name,_originalTree_Syn_Name :: Name}
  _wrap_Name :: T_Name ->
               Inh_Name ->
               Syn_Name
  _wrap_Name sem (Inh_Name _lhsIcat _lhsIflags _lhsIimCast _lhsItpe) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast _lhsItpe
       in  (Syn_Name _lhsOannotatedTree _lhsOoriginalTree))
  _sem_Name_Name :: T_Annotation ->
                   ([NameComponent]) ->
                   T_Name
  _sem_Name_Name ann_ is_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast
         _lhsItpe ->
           (let _lhsOannotatedTree :: Name
                _lhsOoriginalTree :: Name
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Name _annIannotatedTree is_
                     {-# LINE 6726 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Name _annIoriginalTree is_
                     {-# LINE 6732 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6738 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6744 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 6750 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 6756 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 6762 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsItpe
                     {-# LINE 6768 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Name_AntiName :: String ->
                       T_Name
  _sem_Name_AntiName string_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast
         _lhsItpe ->
           (let _lhsOannotatedTree :: Name
                _lhsOoriginalTree :: Name
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AntiName string_
                     {-# LINE 6786 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AntiName string_
                     {-# LINE 6792 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6798 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6804 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- NameComponentList -------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : NameComponentList 
           originalTree         : NameComponentList 
     alternatives:
        alternative Cons:
           child hd             : {NameComponent}
           child tl             : NameComponentList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type NameComponentList = [(NameComponent)]
  -- cata
  _sem_NameComponentList :: NameComponentList ->
                           T_NameComponentList
  _sem_NameComponentList list =
      (Prelude.foldr _sem_NameComponentList_Cons _sem_NameComponentList_Nil list)
  -- semantic domain
  type T_NameComponentList = Catalog ->
                             TypeCheckFlags ->
                             (Maybe TypeExtra) ->
                             ( NameComponentList,NameComponentList)
  data Inh_NameComponentList = Inh_NameComponentList {_cat_Inh_NameComponentList :: Catalog,_flags_Inh_NameComponentList :: TypeCheckFlags,_imCast_Inh_NameComponentList :: (Maybe TypeExtra)}
  data Syn_NameComponentList = Syn_NameComponentList {_annotatedTree_Syn_NameComponentList :: NameComponentList,_originalTree_Syn_NameComponentList :: NameComponentList}
  _wrap_NameComponentList :: T_NameComponentList ->
                            Inh_NameComponentList ->
                            Syn_NameComponentList
  _wrap_NameComponentList sem (Inh_NameComponentList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_NameComponentList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_NameComponentList_Cons :: NameComponent ->
                                T_NameComponentList ->
                                T_NameComponentList
  _sem_NameComponentList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: NameComponentList
                _lhsOoriginalTree :: NameComponentList
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _tlIannotatedTree :: NameComponentList
                _tlIoriginalTree :: NameComponentList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) hd_ _tlIannotatedTree
                     {-# LINE 6866 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) hd_ _tlIoriginalTree
                     {-# LINE 6872 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6878 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6884 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 6890 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 6896 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 6902 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_NameComponentList_Nil :: T_NameComponentList
  _sem_NameComponentList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: NameComponentList
                _lhsOoriginalTree :: NameComponentList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 6918 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 6924 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 6930 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 6936 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- NameTypeNameListPair ----------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : NameTypeNameListPair 
           originalTree         : NameTypeNameListPair 
     alternatives:
        alternative Tuple:
           child x1             : Name 
           child x2             : TypeNameList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type NameTypeNameListPair = ( Name,TypeNameList)
  -- cata
  _sem_NameTypeNameListPair :: NameTypeNameListPair ->
                              T_NameTypeNameListPair
  _sem_NameTypeNameListPair ( x1,x2) =
      (_sem_NameTypeNameListPair_Tuple (_sem_Name x1) (_sem_TypeNameList x2))
  -- semantic domain
  type T_NameTypeNameListPair = Catalog ->
                                TypeCheckFlags ->
                                (Maybe TypeExtra) ->
                                ( NameTypeNameListPair,NameTypeNameListPair)
  data Inh_NameTypeNameListPair = Inh_NameTypeNameListPair {_cat_Inh_NameTypeNameListPair :: Catalog,_flags_Inh_NameTypeNameListPair :: TypeCheckFlags,_imCast_Inh_NameTypeNameListPair :: (Maybe TypeExtra)}
  data Syn_NameTypeNameListPair = Syn_NameTypeNameListPair {_annotatedTree_Syn_NameTypeNameListPair :: NameTypeNameListPair,_originalTree_Syn_NameTypeNameListPair :: NameTypeNameListPair}
  _wrap_NameTypeNameListPair :: T_NameTypeNameListPair ->
                               Inh_NameTypeNameListPair ->
                               Syn_NameTypeNameListPair
  _wrap_NameTypeNameListPair sem (Inh_NameTypeNameListPair _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_NameTypeNameListPair _lhsOannotatedTree _lhsOoriginalTree))
  _sem_NameTypeNameListPair_Tuple :: T_Name ->
                                    T_TypeNameList ->
                                    T_NameTypeNameListPair
  _sem_NameTypeNameListPair_Tuple x1_ x2_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _x1Otpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: NameTypeNameListPair
                _lhsOoriginalTree :: NameTypeNameListPair
                _x1Ocat :: Catalog
                _x1Oflags :: TypeCheckFlags
                _x1OimCast :: (Maybe TypeExtra)
                _x2Ocat :: Catalog
                _x2Oflags :: TypeCheckFlags
                _x2OimCast :: (Maybe TypeExtra)
                _x1IannotatedTree :: Name
                _x1IoriginalTree :: Name
                _x2IannotatedTree :: TypeNameList
                _x2IoriginalTree :: TypeNameList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 65, column 34)
                _x1Otpe =
                    ({-# LINE 65 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 7000 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IannotatedTree,_x2IannotatedTree)
                     {-# LINE 7006 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IoriginalTree,_x2IoriginalTree)
                     {-# LINE 7012 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7036 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7042 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7048 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7054 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7060 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _x1IannotatedTree,_x1IoriginalTree) =
                    x1_ _x1Ocat _x1Oflags _x1OimCast _x1Otpe
                ( _x2IannotatedTree,_x2IoriginalTree) =
                    x2_ _x2Ocat _x2Oflags _x2OimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- NameTypeNameListPairList ------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : NameTypeNameListPairList 
           originalTree         : NameTypeNameListPairList 
     alternatives:
        alternative Cons:
           child hd             : NameTypeNameListPair 
           child tl             : NameTypeNameListPairList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type NameTypeNameListPairList = [NameTypeNameListPair]
  -- cata
  _sem_NameTypeNameListPairList :: NameTypeNameListPairList ->
                                  T_NameTypeNameListPairList
  _sem_NameTypeNameListPairList list =
      (Prelude.foldr _sem_NameTypeNameListPairList_Cons _sem_NameTypeNameListPairList_Nil (Prelude.map _sem_NameTypeNameListPair list))
  -- semantic domain
  type T_NameTypeNameListPairList = Catalog ->
                                    TypeCheckFlags ->
                                    (Maybe TypeExtra) ->
                                    ( NameTypeNameListPairList,NameTypeNameListPairList)
  data Inh_NameTypeNameListPairList = Inh_NameTypeNameListPairList {_cat_Inh_NameTypeNameListPairList :: Catalog,_flags_Inh_NameTypeNameListPairList :: TypeCheckFlags,_imCast_Inh_NameTypeNameListPairList :: (Maybe TypeExtra)}
  data Syn_NameTypeNameListPairList = Syn_NameTypeNameListPairList {_annotatedTree_Syn_NameTypeNameListPairList :: NameTypeNameListPairList,_originalTree_Syn_NameTypeNameListPairList :: NameTypeNameListPairList}
  _wrap_NameTypeNameListPairList :: T_NameTypeNameListPairList ->
                                   Inh_NameTypeNameListPairList ->
                                   Syn_NameTypeNameListPairList
  _wrap_NameTypeNameListPairList sem (Inh_NameTypeNameListPairList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_NameTypeNameListPairList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_NameTypeNameListPairList_Cons :: T_NameTypeNameListPair ->
                                       T_NameTypeNameListPairList ->
                                       T_NameTypeNameListPairList
  _sem_NameTypeNameListPairList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: NameTypeNameListPairList
                _lhsOoriginalTree :: NameTypeNameListPairList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: NameTypeNameListPair
                _hdIoriginalTree :: NameTypeNameListPair
                _tlIannotatedTree :: NameTypeNameListPairList
                _tlIoriginalTree :: NameTypeNameListPairList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 7131 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 7137 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7143 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7149 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7155 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7161 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7167 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7173 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7179 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7185 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_NameTypeNameListPairList_Nil :: T_NameTypeNameListPairList
  _sem_NameTypeNameListPairList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: NameTypeNameListPairList
                _lhsOoriginalTree :: NameTypeNameListPairList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 7203 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 7209 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7215 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7221 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- OnExpr ------------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : OnExpr 
           originalTree         : OnExpr 
     alternatives:
        alternative Just:
           child just           : JoinExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nothing:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type OnExpr = Maybe (JoinExpr)
  -- cata
  _sem_OnExpr :: OnExpr ->
                T_OnExpr
  _sem_OnExpr (Prelude.Just x) =
      (_sem_OnExpr_Just (_sem_JoinExpr x))
  _sem_OnExpr Prelude.Nothing =
      _sem_OnExpr_Nothing
  -- semantic domain
  type T_OnExpr = Catalog ->
                  Environment ->
                  TypeCheckFlags ->
                  (Maybe TypeExtra) ->
                  ( OnExpr,OnExpr)
  data Inh_OnExpr = Inh_OnExpr {_cat_Inh_OnExpr :: Catalog,_downEnv_Inh_OnExpr :: Environment,_flags_Inh_OnExpr :: TypeCheckFlags,_imCast_Inh_OnExpr :: (Maybe TypeExtra)}
  data Syn_OnExpr = Syn_OnExpr {_annotatedTree_Syn_OnExpr :: OnExpr,_originalTree_Syn_OnExpr :: OnExpr}
  _wrap_OnExpr :: T_OnExpr ->
                 Inh_OnExpr ->
                 Syn_OnExpr
  _wrap_OnExpr sem (Inh_OnExpr _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast
       in  (Syn_OnExpr _lhsOannotatedTree _lhsOoriginalTree))
  _sem_OnExpr_Just :: T_JoinExpr ->
                     T_OnExpr
  _sem_OnExpr_Just just_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: OnExpr
                _lhsOoriginalTree :: OnExpr
                _justOcat :: Catalog
                _justOdownEnv :: Environment
                _justOflags :: TypeCheckFlags
                _justOimCast :: (Maybe TypeExtra)
                _justIannotatedTree :: JoinExpr
                _justIoriginalTree :: JoinExpr
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIannotatedTree
                     {-# LINE 7287 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Just _justIoriginalTree
                     {-# LINE 7293 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7299 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7305 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7311 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOdownEnv =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 7317 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7323 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _justOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7329 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _justIannotatedTree,_justIoriginalTree) =
                    just_ _justOcat _justOdownEnv _justOflags _justOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_OnExpr_Nothing :: T_OnExpr
  _sem_OnExpr_Nothing =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: OnExpr
                _lhsOoriginalTree :: OnExpr
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 7346 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 7352 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7358 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7364 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ParamDef ----------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ParamDef 
           originalTree         : ParamDef 
     alternatives:
        alternative ParamDef:
           child ann            : Annotation 
           child name           : {NameComponent}
           child typ            : TypeName 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ParamDefTp:
           child ann            : Annotation 
           child typ            : TypeName 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data ParamDef = ParamDef (Annotation) (NameComponent) (TypeName)
                | ParamDefTp (Annotation) (TypeName)
                deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_ParamDef :: ParamDef ->
                  T_ParamDef
  _sem_ParamDef (ParamDef _ann _name _typ) =
      (_sem_ParamDef_ParamDef (_sem_Annotation _ann) _name (_sem_TypeName _typ))
  _sem_ParamDef (ParamDefTp _ann _typ) =
      (_sem_ParamDef_ParamDefTp (_sem_Annotation _ann) (_sem_TypeName _typ))
  -- semantic domain
  type T_ParamDef = Catalog ->
                    TypeCheckFlags ->
                    (Maybe TypeExtra) ->
                    ( ParamDef,ParamDef)
  data Inh_ParamDef = Inh_ParamDef {_cat_Inh_ParamDef :: Catalog,_flags_Inh_ParamDef :: TypeCheckFlags,_imCast_Inh_ParamDef :: (Maybe TypeExtra)}
  data Syn_ParamDef = Syn_ParamDef {_annotatedTree_Syn_ParamDef :: ParamDef,_originalTree_Syn_ParamDef :: ParamDef}
  _wrap_ParamDef :: T_ParamDef ->
                   Inh_ParamDef ->
                   Syn_ParamDef
  _wrap_ParamDef sem (Inh_ParamDef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ParamDef _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ParamDef_ParamDef :: T_Annotation ->
                           NameComponent ->
                           T_TypeName ->
                           T_ParamDef
  _sem_ParamDef_ParamDef ann_ name_ typ_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: ParamDef
                _lhsOoriginalTree :: ParamDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 66, column 25)
                _annOtpe =
                    ({-# LINE 66 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 7441 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ParamDef _annIannotatedTree name_ _typIannotatedTree
                     {-# LINE 7447 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ParamDef _annIoriginalTree name_ _typIoriginalTree
                     {-# LINE 7453 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7459 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7465 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7471 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7477 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7483 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7489 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7495 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7501 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_ParamDef_ParamDefTp :: T_Annotation ->
                             T_TypeName ->
                             T_ParamDef
  _sem_ParamDef_ParamDefTp ann_ typ_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: ParamDef
                _lhsOoriginalTree :: ParamDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 67, column 27)
                _annOtpe =
                    ({-# LINE 67 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 7533 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ParamDefTp _annIannotatedTree _typIannotatedTree
                     {-# LINE 7539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ParamDefTp _annIoriginalTree _typIoriginalTree
                     {-# LINE 7545 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7551 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7563 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7569 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ParamDefList ------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ParamDefList 
           originalTree         : ParamDefList 
     alternatives:
        alternative Cons:
           child hd             : ParamDef 
           child tl             : ParamDefList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ParamDefList = [ParamDef]
  -- cata
  _sem_ParamDefList :: ParamDefList ->
                      T_ParamDefList
  _sem_ParamDefList list =
      (Prelude.foldr _sem_ParamDefList_Cons _sem_ParamDefList_Nil (Prelude.map _sem_ParamDef list))
  -- semantic domain
  type T_ParamDefList = Catalog ->
                        TypeCheckFlags ->
                        (Maybe TypeExtra) ->
                        ( ParamDefList,ParamDefList)
  data Inh_ParamDefList = Inh_ParamDefList {_cat_Inh_ParamDefList :: Catalog,_flags_Inh_ParamDefList :: TypeCheckFlags,_imCast_Inh_ParamDefList :: (Maybe TypeExtra)}
  data Syn_ParamDefList = Syn_ParamDefList {_annotatedTree_Syn_ParamDefList :: ParamDefList,_originalTree_Syn_ParamDefList :: ParamDefList}
  _wrap_ParamDefList :: T_ParamDefList ->
                       Inh_ParamDefList ->
                       Syn_ParamDefList
  _wrap_ParamDefList sem (Inh_ParamDefList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ParamDefList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ParamDefList_Cons :: T_ParamDef ->
                           T_ParamDefList ->
                           T_ParamDefList
  _sem_ParamDefList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ParamDefList
                _lhsOoriginalTree :: ParamDefList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ParamDef
                _hdIoriginalTree :: ParamDef
                _tlIannotatedTree :: ParamDefList
                _tlIoriginalTree :: ParamDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 7664 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 7670 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7676 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7682 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7688 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7694 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7700 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 7706 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 7712 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 7718 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_ParamDefList_Nil :: T_ParamDefList
  _sem_ParamDefList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ParamDefList
                _lhsOoriginalTree :: ParamDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 7736 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 7742 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 7748 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 7754 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- QueryExpr ---------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           expectedType         : Maybe [TypeExtra]
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
           outerDownEnv         : Maybe Environment
        synthesized attributes:
           annotatedTree        : QueryExpr 
           originalTree         : QueryExpr 
           upType               : Maybe [(Text,TypeExtra)]
     alternatives:
        alternative Select:
           child ann            : Annotation 
           child selDistinct    : {Distinct}
           child selSelectList  : SelectList 
           child selTref        : TableRefList 
           child selWhere       : MaybeBoolExpr 
           child selGroupBy     : ScalarExprList 
           child selHaving      : MaybeBoolExpr 
           child selOrderBy     : ScalarExprDirectionPairList 
           child selLimit       : MaybeScalarExpr 
           child selOffset      : MaybeScalarExpr 
           child selOption      : {[QueryHint]}
           visit 0:
              local tpee        : {Either [TypeError] [(Text,TypeExtra)]}
              local tpe         : {Either [TypeError] TypeExtra}
              local selGroupBy  : _
              local annotatedTree : _
              local originalTree : _
        alternative CombineQueryExpr:
           child ann            : Annotation 
           child cqType         : {CombineType}
           child cqQe0          : QueryExpr 
           child cqQe1          : QueryExpr 
           visit 0:
              local tpe         : {Either [TypeError] TypeExtra}
              local tpee        : {Either [TypeError] [(Text,TypeExtra)]}
              local annotatedTree : _
              local originalTree : _
        alternative Values:
           child ann            : Annotation 
           child qeValues       : ScalarExprListList 
           visit 0:
              local tpe         : {Either [TypeError] TypeExtra}
              local tpee        : {Either [TypeError] [(Text,TypeExtra)]}
              local annotatedTree : _
              local originalTree : _
        alternative WithQueryExpr:
           child ann            : Annotation 
           child withs          : WithQueryList 
           child withQe         : QueryExpr 
           visit 0:
              local tpe         : {Either [TypeError] TypeExtra}
              local tpee        : {Either [TypeError] [(Text,TypeExtra)]}
              local annotatedTree : _
              local originalTree : _
  -}
  
  data QueryExpr
      = Select { ann:: (Annotation)
               ,selDistinct :: ( Distinct)
               ,selSelectList :: ( SelectList)
               ,selTref :: ( TableRefList)
               ,selWhere :: ( MaybeBoolExpr)
               ,selGroupBy :: ( ScalarExprList)
               ,selHaving :: ( MaybeBoolExpr)
               ,selOrderBy :: ( ScalarExprDirectionPairList)
               ,selLimit :: ( MaybeScalarExpr)
               ,selOffset :: ( MaybeScalarExpr)
               ,selOption :: ( [QueryHint])
          }
      |  CombineQueryExpr { ann:: (Annotation)
                         ,cqType :: ( CombineType)
                         ,cqQe0 :: ( QueryExpr)
                         ,cqQe1 :: ( QueryExpr)
          }
      |  Values { ann:: (Annotation)
               ,qeValues:: (ScalarExprListList)
          }
      |  WithQueryExpr { ann :: ( Annotation)
                      ,withs :: ( WithQueryList)
                      ,withQe :: ( QueryExpr)
  
  -- todo: represent parens explicitly in queryexpr
  --    | QueryExprParens ex:: QueryExpr
  
  
      } deriving (Eq,Show,Data,Typeable)
  
  -- cata
  _sem_QueryExpr :: QueryExpr ->
                   T_QueryExpr
  _sem_QueryExpr (Select _ann _selDistinct _selSelectList _selTref _selWhere _selGroupBy _selHaving _selOrderBy _selLimit _selOffset _selOption) =
      (_sem_QueryExpr_Select (_sem_Annotation _ann) _selDistinct (_sem_SelectList _selSelectList) (_sem_TableRefList _selTref) (_sem_MaybeBoolExpr _selWhere) (_sem_ScalarExprList _selGroupBy) (_sem_MaybeBoolExpr _selHaving) (_sem_ScalarExprDirectionPairList _selOrderBy) (_sem_MaybeScalarExpr _selLimit) (_sem_MaybeScalarExpr _selOffset) _selOption)
  _sem_QueryExpr (CombineQueryExpr _ann _cqType _cqQe0 _cqQe1) =
      (_sem_QueryExpr_CombineQueryExpr (_sem_Annotation _ann) _cqType (_sem_QueryExpr _cqQe0) (_sem_QueryExpr _cqQe1))
  _sem_QueryExpr (Values _ann _qeValues) =
      (_sem_QueryExpr_Values (_sem_Annotation _ann) (_sem_ScalarExprListList _qeValues))
  _sem_QueryExpr (WithQueryExpr _ann _withs _withQe) =
      (_sem_QueryExpr_WithQueryExpr (_sem_Annotation _ann) (_sem_WithQueryList _withs) (_sem_QueryExpr _withQe))
  -- semantic domain
  type T_QueryExpr = Bool ->
                     Catalog ->
                     (Maybe [TypeExtra]) ->
                     TypeCheckFlags ->
                     (Maybe TypeExtra) ->
                     (Maybe Environment) ->
                     ( QueryExpr,QueryExpr,(Maybe [(Text,TypeExtra)]))
  data Inh_QueryExpr = Inh_QueryExpr {_assignmentCastContext_Inh_QueryExpr :: Bool,_cat_Inh_QueryExpr :: Catalog,_expectedType_Inh_QueryExpr :: (Maybe [TypeExtra]),_flags_Inh_QueryExpr :: TypeCheckFlags,_imCast_Inh_QueryExpr :: (Maybe TypeExtra),_outerDownEnv_Inh_QueryExpr :: (Maybe Environment)}
  data Syn_QueryExpr = Syn_QueryExpr {_annotatedTree_Syn_QueryExpr :: QueryExpr,_originalTree_Syn_QueryExpr :: QueryExpr,_upType_Syn_QueryExpr :: (Maybe [(Text,TypeExtra)])}
  _wrap_QueryExpr :: T_QueryExpr ->
                    Inh_QueryExpr ->
                    Syn_QueryExpr
  _wrap_QueryExpr sem (Inh_QueryExpr _lhsIassignmentCastContext _lhsIcat _lhsIexpectedType _lhsIflags _lhsIimCast _lhsIouterDownEnv) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType) = sem _lhsIassignmentCastContext _lhsIcat _lhsIexpectedType _lhsIflags _lhsIimCast _lhsIouterDownEnv
       in  (Syn_QueryExpr _lhsOannotatedTree _lhsOoriginalTree _lhsOupType))
  _sem_QueryExpr_Select :: T_Annotation ->
                          Distinct ->
                          T_SelectList ->
                          T_TableRefList ->
                          T_MaybeBoolExpr ->
                          T_ScalarExprList ->
                          T_MaybeBoolExpr ->
                          T_ScalarExprDirectionPairList ->
                          T_MaybeScalarExpr ->
                          T_MaybeScalarExpr ->
                          ([QueryHint]) ->
                          T_QueryExpr
  _sem_QueryExpr_Select ann_ selDistinct_ selSelectList_ selTref_ selWhere_ selGroupBy_ selHaving_ selOrderBy_ selLimit_ selOffset_ selOption_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIouterDownEnv ->
           (let _selGroupByOexpectedCast :: Bool
                _selLimitOdownEnv :: Environment
                _selLimitOexpectedCast :: Bool
                _selOffsetOdownEnv :: Environment
                _selOffsetOexpectedCast :: Bool
                _selSelectListOexpectedCast :: Bool
                _selSelectListOdownEnv :: Environment
                _selGroupByOdownEnv :: Environment
                _selHavingOdownEnv :: Environment
                _selOrderByOdownEnv :: Environment
                _tpee :: (Either [TypeError] [(Text,TypeExtra)])
                _selWhereOdownEnv :: Environment
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _lhsOannotatedTree :: QueryExpr
                _selGroupByOexpectedTypes :: ([TypeExtra])
                _selLimitOexpectedType :: (Maybe TypeExtra)
                _selOffsetOexpectedType :: (Maybe TypeExtra)
                _lhsOoriginalTree :: QueryExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _selSelectListOassignmentCastContext :: Bool
                _selSelectListOcat :: Catalog
                _selSelectListOexpectedType :: (Maybe [TypeExtra])
                _selSelectListOflags :: TypeCheckFlags
                _selSelectListOimCast :: (Maybe TypeExtra)
                _selTrefOcat :: Catalog
                _selTrefOflags :: TypeCheckFlags
                _selTrefOimCast :: (Maybe TypeExtra)
                _selWhereOcat :: Catalog
                _selWhereOflags :: TypeCheckFlags
                _selWhereOimCast :: (Maybe TypeExtra)
                _selGroupByOassignmentCastContext :: Bool
                _selGroupByOcat :: Catalog
                _selGroupByOflags :: TypeCheckFlags
                _selGroupByOimCast :: (Maybe TypeExtra)
                _selHavingOcat :: Catalog
                _selHavingOflags :: TypeCheckFlags
                _selHavingOimCast :: (Maybe TypeExtra)
                _selOrderByOcat :: Catalog
                _selOrderByOflags :: TypeCheckFlags
                _selOrderByOimCast :: (Maybe TypeExtra)
                _selLimitOassignmentCastContext :: Bool
                _selLimitOcat :: Catalog
                _selLimitOflags :: TypeCheckFlags
                _selLimitOimCast :: (Maybe TypeExtra)
                _selOffsetOassignmentCastContext :: Bool
                _selOffsetOcat :: Catalog
                _selOffsetOflags :: TypeCheckFlags
                _selOffsetOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selSelectListIannotatedTree :: SelectList
                _selSelectListIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _selSelectListIoriginalTree :: SelectList
                _selSelectListIupEnv :: Environment
                _selSelectListIupType :: (Maybe [(Text,TypeExtra)])
                _selTrefIannotatedTree :: TableRefList
                _selTrefIoriginalTree :: TableRefList
                _selTrefIupEnv :: Environment
                _selWhereIannotatedTree :: MaybeBoolExpr
                _selWhereIoriginalTree :: MaybeBoolExpr
                _selGroupByIannotatedTree :: ScalarExprList
                _selGroupByIoriginalTree :: ScalarExprList
                _selGroupByIupTypes :: ([Maybe TypeExtra])
                _selHavingIannotatedTree :: MaybeBoolExpr
                _selHavingIoriginalTree :: MaybeBoolExpr
                _selOrderByIannotatedTree :: ScalarExprDirectionPairList
                _selOrderByIoriginalTree :: ScalarExprDirectionPairList
                _selLimitIannotatedTree :: MaybeScalarExpr
                _selLimitIoriginalTree :: MaybeScalarExpr
                _selLimitIupType :: (Maybe TypeExtra)
                _selOffsetIannotatedTree :: MaybeScalarExpr
                _selOffsetIoriginalTree :: MaybeScalarExpr
                _selOffsetIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 68, column 24)
                _selGroupByOexpectedCast =
                    ({-# LINE 68 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 7950 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 69, column 24)
                _selLimitOdownEnv =
                    ({-# LINE 69 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 7956 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 70, column 24)
                _selLimitOexpectedCast =
                    ({-# LINE 70 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 7962 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 71, column 24)
                _selOffsetOdownEnv =
                    ({-# LINE 71 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 7968 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 72, column 24)
                _selOffsetOexpectedCast =
                    ({-# LINE 72 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 7974 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 73, column 24)
                _selSelectListOexpectedCast =
                    ({-# LINE 73 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 7980 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 106, column 9)
                _selSelectListOdownEnv =
                    ({-# LINE 106 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _selTrefIupEnv
                     {-# LINE 7986 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 107, column 9)
                _selGroupByOdownEnv =
                    ({-# LINE 107 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _selTrefIupEnv
                     {-# LINE 7992 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 108, column 9)
                _selHavingOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _selTrefIupEnv
                     {-# LINE 7998 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 128, column 9)
                _selOrderByOdownEnv =
                    ({-# LINE 128 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     E.orderByEnvironment _selSelectListIupEnv _selTrefIupEnv
                     {-# LINE 8004 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 129, column 9)
                _tpee =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     maybe (Left []) Right _selSelectListIupType
                     {-# LINE 8010 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 132, column 9)
                _selWhereOdownEnv =
                    ({-# LINE 132 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     maybe _selTrefIupEnv
                      (\e -> E.createCorrelatedSubqueryEnvironment e _selTrefIupEnv)
                      _lhsIouterDownEnv
                     {-# LINE 8018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 142, column 9)
                _tpe =
                    ({-# LINE 142 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM (mkTypeExtra . CompositeType) _tpee
                     {-# LINE 8024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 145, column 9)
                _lhsOupType =
                    ({-# LINE 145 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     either (const Nothing) Just _tpee
                     {-# LINE 8030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 239, column 9)
                _selGroupBy =
                    ({-# LINE 239 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     case _selGroupByIannotatedTree of
                         [App e nm@(Name _ [Nmc "cube"]) es] ->
                           [App e{anType = (Just (mkTypeExtra $ ScalarType "int4"))
                                 ,anErrs = []
                                 } nm es]
                         x -> x
                     {-# LINE 8041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 248, column 9)
                _lhsOannotatedTree =
                    ({-# LINE 248 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Select _annIannotatedTree
                            selDistinct_
                            _selSelectListIannotatedTree
                            _selTrefIannotatedTree
                            _selWhereIannotatedTree
                            _selGroupBy
                            _selHavingIannotatedTree
                            _selOrderByIannotatedTree
                            _selLimitIannotatedTree
                            _selOffsetIannotatedTree
                            selOption_
                     {-# LINE 8057 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 767, column 7)
                _selGroupByOexpectedTypes =
                    ({-# LINE 767 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 8063 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 768, column 7)
                _selLimitOexpectedType =
                    ({-# LINE 768 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 8069 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 769, column 7)
                _selOffsetOexpectedType =
                    ({-# LINE 769 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 8075 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Select _annIannotatedTree selDistinct_ _selSelectListIannotatedTree _selTrefIannotatedTree _selWhereIannotatedTree _selGroupByIannotatedTree _selHavingIannotatedTree _selOrderByIannotatedTree _selLimitIannotatedTree _selOffsetIannotatedTree selOption_
                     {-# LINE 8081 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Select _annIoriginalTree selDistinct_ _selSelectListIoriginalTree _selTrefIoriginalTree _selWhereIoriginalTree _selGroupByIoriginalTree _selHavingIoriginalTree _selOrderByIoriginalTree _selLimitIoriginalTree _selOffsetIoriginalTree selOption_
                     {-# LINE 8087 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 8093 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 8117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selSelectListOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selSelectListOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8129 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selSelectListOexpectedType =
                    ({-# LINE 159 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 8135 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selSelectListOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8141 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selSelectListOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8147 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selTrefOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8153 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selTrefOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8159 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selTrefOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8165 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selWhereOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8171 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selWhereOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8177 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selWhereOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8183 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selGroupByOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8189 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selGroupByOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8195 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selGroupByOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8201 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selGroupByOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8207 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selHavingOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8213 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selHavingOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8219 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selHavingOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8225 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOrderByOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8231 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOrderByOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8237 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOrderByOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8243 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selLimitOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8249 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selLimitOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8255 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selLimitOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8261 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selLimitOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8267 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOffsetOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8273 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOffsetOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8279 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOffsetOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8285 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOffsetOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8291 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selSelectListIannotatedTree,_selSelectListIcolExprs,_selSelectListIoriginalTree,_selSelectListIupEnv,_selSelectListIupType) =
                    selSelectList_ _selSelectListOassignmentCastContext _selSelectListOcat _selSelectListOdownEnv _selSelectListOexpectedCast _selSelectListOexpectedType _selSelectListOflags _selSelectListOimCast
                ( _selTrefIannotatedTree,_selTrefIoriginalTree,_selTrefIupEnv) =
                    selTref_ _selTrefOcat _selTrefOflags _selTrefOimCast
                ( _selWhereIannotatedTree,_selWhereIoriginalTree) =
                    selWhere_ _selWhereOcat _selWhereOdownEnv _selWhereOflags _selWhereOimCast
                ( _selGroupByIannotatedTree,_selGroupByIoriginalTree,_selGroupByIupTypes) =
                    selGroupBy_ _selGroupByOassignmentCastContext _selGroupByOcat _selGroupByOdownEnv _selGroupByOexpectedCast _selGroupByOexpectedTypes _selGroupByOflags _selGroupByOimCast
                ( _selHavingIannotatedTree,_selHavingIoriginalTree) =
                    selHaving_ _selHavingOcat _selHavingOdownEnv _selHavingOflags _selHavingOimCast
                ( _selOrderByIannotatedTree,_selOrderByIoriginalTree) =
                    selOrderBy_ _selOrderByOcat _selOrderByOdownEnv _selOrderByOflags _selOrderByOimCast
                ( _selLimitIannotatedTree,_selLimitIoriginalTree,_selLimitIupType) =
                    selLimit_ _selLimitOassignmentCastContext _selLimitOcat _selLimitOdownEnv _selLimitOexpectedCast _selLimitOexpectedType _selLimitOflags _selLimitOimCast
                ( _selOffsetIannotatedTree,_selOffsetIoriginalTree,_selOffsetIupType) =
                    selOffset_ _selOffsetOassignmentCastContext _selOffsetOcat _selOffsetOdownEnv _selOffsetOexpectedCast _selOffsetOexpectedType _selOffsetOflags _selOffsetOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  _sem_QueryExpr_CombineQueryExpr :: T_Annotation ->
                                    CombineType ->
                                    T_QueryExpr ->
                                    T_QueryExpr ->
                                    T_QueryExpr
  _sem_QueryExpr_CombineQueryExpr ann_ cqType_ cqQe0_ cqQe1_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIouterDownEnv ->
           (let _tpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _tpee :: (Either [TypeError] [(Text,TypeExtra)])
                _lhsOannotatedTree :: QueryExpr
                _lhsOoriginalTree :: QueryExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _cqQe0OassignmentCastContext :: Bool
                _cqQe0Ocat :: Catalog
                _cqQe0OexpectedType :: (Maybe [TypeExtra])
                _cqQe0Oflags :: TypeCheckFlags
                _cqQe0OimCast :: (Maybe TypeExtra)
                _cqQe0OouterDownEnv :: (Maybe Environment)
                _cqQe1OassignmentCastContext :: Bool
                _cqQe1Ocat :: Catalog
                _cqQe1OexpectedType :: (Maybe [TypeExtra])
                _cqQe1Oflags :: TypeCheckFlags
                _cqQe1OimCast :: (Maybe TypeExtra)
                _cqQe1OouterDownEnv :: (Maybe Environment)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _cqQe0IannotatedTree :: QueryExpr
                _cqQe0IoriginalTree :: QueryExpr
                _cqQe0IupType :: (Maybe [(Text,TypeExtra)])
                _cqQe1IannotatedTree :: QueryExpr
                _cqQe1IoriginalTree :: QueryExpr
                _cqQe1IupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 142, column 9)
                _tpe =
                    ({-# LINE 142 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM (mkTypeExtra . CompositeType) _tpee
                     {-# LINE 8357 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 145, column 9)
                _lhsOupType =
                    ({-# LINE 145 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     either (const Nothing) Just _tpee
                     {-# LINE 8363 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 156, column 9)
                _tpee =
                    ({-# LINE 156 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     do
                     a <- maybe (Left []) Right _cqQe0IupType
                     b <- maybe (Left []) Right _cqQe1IupType
                     unless (length a == length b) $ Left [IncompatibleUnionTypes (CompositeType a) (CompositeType b)]
                     let uts = zipWithM (\(_,te1) (_,te2) -> resolveResultSetTypeExtra _lhsIcat [te1,te2])
                                   a b
                     case uts of
                       Left{} -> Left [IncompatibleUnionTypes (CompositeType a) (CompositeType b)]
                       Right uts' -> return $ zipWith (\(n,_) te -> (n,te)) a uts'
                     {-# LINE 8377 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CombineQueryExpr _annIannotatedTree cqType_ _cqQe0IannotatedTree _cqQe1IannotatedTree
                     {-# LINE 8383 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CombineQueryExpr _annIoriginalTree cqType_ _cqQe0IoriginalTree _cqQe1IoriginalTree
                     {-# LINE 8389 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 8395 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 8401 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8407 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8413 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8419 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 8425 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe0OassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8431 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe0Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8437 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe0OexpectedType =
                    ({-# LINE 18 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 8443 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe0Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8449 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe0OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8455 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe0OouterDownEnv =
                    ({-# LINE 89 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIouterDownEnv
                     {-# LINE 8461 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe1OassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8467 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8473 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe1OexpectedType =
                    ({-# LINE 18 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 8479 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8485 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8491 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _cqQe1OouterDownEnv =
                    ({-# LINE 89 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIouterDownEnv
                     {-# LINE 8497 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _cqQe0IannotatedTree,_cqQe0IoriginalTree,_cqQe0IupType) =
                    cqQe0_ _cqQe0OassignmentCastContext _cqQe0Ocat _cqQe0OexpectedType _cqQe0Oflags _cqQe0OimCast _cqQe0OouterDownEnv
                ( _cqQe1IannotatedTree,_cqQe1IoriginalTree,_cqQe1IupType) =
                    cqQe1_ _cqQe1OassignmentCastContext _cqQe1Ocat _cqQe1OexpectedType _cqQe1Oflags _cqQe1OimCast _cqQe1OouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  _sem_QueryExpr_Values :: T_Annotation ->
                          T_ScalarExprListList ->
                          T_QueryExpr
  _sem_QueryExpr_Values ann_ qeValues_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIouterDownEnv ->
           (let _qeValuesOdownEnv :: Environment
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _tpee :: (Either [TypeError] [(Text,TypeExtra)])
                _qeValuesOexpectedCast :: Bool
                _lhsOannotatedTree :: QueryExpr
                _lhsOoriginalTree :: QueryExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _qeValuesOassignmentCastContext :: Bool
                _qeValuesOcat :: Catalog
                _qeValuesOexpectedType :: (Maybe [TypeExtra])
                _qeValuesOflags :: TypeCheckFlags
                _qeValuesOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _qeValuesIannotatedTree :: ScalarExprListList
                _qeValuesIoriginalTree :: ScalarExprListList
                _qeValuesIupType :: (Either [TypeError] [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 74, column 24)
                _qeValuesOdownEnv =
                    ({-# LINE 74 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 8541 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 142, column 9)
                _tpe =
                    ({-# LINE 142 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM (mkTypeExtra . CompositeType) _tpee
                     {-# LINE 8547 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 145, column 9)
                _lhsOupType =
                    ({-# LINE 145 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     either (const Nothing) Just _tpee
                     {-# LINE 8553 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 153, column 9)
                _tpee =
                    ({-# LINE 153 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _qeValuesIupType
                     {-# LINE 8559 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 154, column 9)
                _qeValuesOexpectedCast =
                    ({-# LINE 154 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     True
                     {-# LINE 8565 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Values _annIannotatedTree _qeValuesIannotatedTree
                     {-# LINE 8571 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Values _annIoriginalTree _qeValuesIoriginalTree
                     {-# LINE 8577 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 8583 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 8589 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8595 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8601 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8607 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 8613 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _qeValuesOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8619 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _qeValuesOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8625 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _qeValuesOexpectedType =
                    ({-# LINE 186 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 8631 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _qeValuesOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8637 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _qeValuesOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8643 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _qeValuesIannotatedTree,_qeValuesIoriginalTree,_qeValuesIupType) =
                    qeValues_ _qeValuesOassignmentCastContext _qeValuesOcat _qeValuesOdownEnv _qeValuesOexpectedCast _qeValuesOexpectedType _qeValuesOflags _qeValuesOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  _sem_QueryExpr_WithQueryExpr :: T_Annotation ->
                                 T_WithQueryList ->
                                 T_QueryExpr ->
                                 T_QueryExpr
  _sem_QueryExpr_WithQueryExpr ann_ withs_ withQe_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIouterDownEnv ->
           (let _withQeOcat :: Catalog
                _withsOcatExtIncomp :: (Either [TypeError] Catalog)
                _lhsOannotatedTree :: QueryExpr
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _tpee :: (Either [TypeError] [(Text,TypeExtra)])
                _lhsOoriginalTree :: QueryExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _withsOcat :: Catalog
                _withsOflags :: TypeCheckFlags
                _withsOimCast :: (Maybe TypeExtra)
                _withQeOassignmentCastContext :: Bool
                _withQeOexpectedType :: (Maybe [TypeExtra])
                _withQeOflags :: TypeCheckFlags
                _withQeOimCast :: (Maybe TypeExtra)
                _withQeOouterDownEnv :: (Maybe Environment)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _withsIannotatedTree :: WithQueryList
                _withsIcatExtComp :: (Either [TypeError] Catalog)
                _withsIoriginalTree :: WithQueryList
                _withQeIannotatedTree :: QueryExpr
                _withQeIoriginalTree :: QueryExpr
                _withQeIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 70, column 8)
                _withQeOcat =
                    ({-# LINE 70 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     case _withsIcatExtComp of
                       Right catExtComp -> catExtComp
                       Left _ -> _lhsIcat
                     {-# LINE 8694 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 74, column 8)
                _withsOcatExtIncomp =
                    ({-# LINE 74 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     return _lhsIcat
                     {-# LINE 8700 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 76, column 8)
                _lhsOannotatedTree =
                    ({-# LINE 76 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     case _withsIcatExtComp of
                       Right _ -> WithQueryExpr (_annIannotatedTree) (_withsIannotatedTree) (_withQeIannotatedTree)
                       Left tyErrs -> WithQueryExpr (emptyAnnotation { anType = Nothing, anErrs = tyErrs })
                         (_withsIannotatedTree) (_withQeIannotatedTree)
                     {-# LINE 8709 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 142, column 9)
                _tpe =
                    ({-# LINE 142 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM (mkTypeExtra . CompositeType) _tpee
                     {-# LINE 8715 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 145, column 9)
                _lhsOupType =
                    ({-# LINE 145 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     either (const Nothing) Just _tpee
                     {-# LINE 8721 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 151, column 9)
                _tpee =
                    ({-# LINE 151 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     maybe (Left []) Right _withQeIupType
                     {-# LINE 8727 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WithQueryExpr _annIannotatedTree _withsIannotatedTree _withQeIannotatedTree
                     {-# LINE 8733 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WithQueryExpr _annIoriginalTree _withsIoriginalTree _withQeIoriginalTree
                     {-# LINE 8739 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 8745 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8751 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8757 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8763 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _tpe
                     {-# LINE 8769 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8775 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8781 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8787 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withQeOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 8793 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withQeOexpectedType =
                    ({-# LINE 18 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 8799 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withQeOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8805 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withQeOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 8811 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _withQeOouterDownEnv =
                    ({-# LINE 89 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIouterDownEnv
                     {-# LINE 8817 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _withsIannotatedTree,_withsIcatExtComp,_withsIoriginalTree) =
                    withs_ _withsOcat _withsOcatExtIncomp _withsOflags _withsOimCast
                ( _withQeIannotatedTree,_withQeIoriginalTree,_withQeIupType) =
                    withQe_ _withQeOassignmentCastContext _withQeOcat _withQeOexpectedType _withQeOflags _withQeOimCast _withQeOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  -- Root --------------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
        synthesized attributes:
           annotatedTree        : Root 
           originalTree         : Root 
     alternatives:
        alternative Root:
           child statements     : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data Root = Root (StatementList)
            deriving ( Show)
  -- cata
  _sem_Root :: Root ->
              T_Root
  _sem_Root (Root _statements) =
      (_sem_Root_Root (_sem_StatementList _statements))
  -- semantic domain
  type T_Root = Catalog ->
                TypeCheckFlags ->
                ( Root,Root)
  data Inh_Root = Inh_Root {_cat_Inh_Root :: Catalog,_flags_Inh_Root :: TypeCheckFlags}
  data Syn_Root = Syn_Root {_annotatedTree_Syn_Root :: Root,_originalTree_Syn_Root :: Root}
  _wrap_Root :: T_Root ->
               Inh_Root ->
               Syn_Root
  _wrap_Root sem (Inh_Root _lhsIcat _lhsIflags) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags
       in  (Syn_Root _lhsOannotatedTree _lhsOoriginalTree))
  _sem_Root_Root :: T_StatementList ->
                   T_Root
  _sem_Root_Root statements_ =
      (\ _lhsIcat
         _lhsIflags ->
           (let _statementsOimCast :: (Maybe TypeExtra)
                _lhsOannotatedTree :: Root
                _lhsOoriginalTree :: Root
                _statementsOcat :: Catalog
                _statementsOflags :: TypeCheckFlags
                _statementsIannotatedTree :: StatementList
                _statementsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag"(line 133, column 8)
                _statementsOimCast =
                    ({-# LINE 133 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 8877 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Root _statementsIannotatedTree
                     {-# LINE 8883 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Root _statementsIoriginalTree
                     {-# LINE 8889 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 8895 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 8901 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _statementsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 8907 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _statementsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 8913 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _statementsIannotatedTree,_statementsIoriginalTree) =
                    statements_ _statementsOcat _statementsOflags _statementsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- RowConstraint -----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : RowConstraint 
           originalTree         : RowConstraint 
     alternatives:
        alternative DefaultConstraint:
           child ann            : Annotation 
           child name           : {String}
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative NullConstraint:
           child ann            : Annotation 
           child name           : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative NotNullConstraint:
           child ann            : Annotation 
           child name           : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative IdentityConstraint:
           child ann            : Annotation 
           child name           : {String}
           child seedAndInc     : {(Maybe (Integer,Integer))}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative RowCheckConstraint:
           child ann            : Annotation 
           child name           : {String}
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative RowUniqueConstraint:
           child ann            : Annotation 
           child name           : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative RowPrimaryKeyConstraint:
           child ann            : Annotation 
           child name           : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative RowReferenceConstraint:
           child ann            : Annotation 
           child name           : {String}
           child table          : Name 
           child att            : {Maybe NameComponent}
           child onUpdate       : {Cascade}
           child onDelete       : {Cascade}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data RowConstraint = DefaultConstraint (Annotation) (String) (ScalarExpr)
                     | NullConstraint (Annotation) (String)
                     | NotNullConstraint (Annotation) (String)
                     | IdentityConstraint (Annotation) (String) (((Maybe (Integer,Integer))))
                     | RowCheckConstraint (Annotation) (String) (ScalarExpr)
                     | RowUniqueConstraint (Annotation) (String)
                     | RowPrimaryKeyConstraint (Annotation) (String)
                     | RowReferenceConstraint (Annotation) (String) (Name) ((Maybe NameComponent)) (Cascade) (Cascade)
                     deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_RowConstraint :: RowConstraint ->
                       T_RowConstraint
  _sem_RowConstraint (DefaultConstraint _ann _name _expr) =
      (_sem_RowConstraint_DefaultConstraint (_sem_Annotation _ann) _name (_sem_ScalarExpr _expr))
  _sem_RowConstraint (NullConstraint _ann _name) =
      (_sem_RowConstraint_NullConstraint (_sem_Annotation _ann) _name)
  _sem_RowConstraint (NotNullConstraint _ann _name) =
      (_sem_RowConstraint_NotNullConstraint (_sem_Annotation _ann) _name)
  _sem_RowConstraint (IdentityConstraint _ann _name _seedAndInc) =
      (_sem_RowConstraint_IdentityConstraint (_sem_Annotation _ann) _name _seedAndInc)
  _sem_RowConstraint (RowCheckConstraint _ann _name _expr) =
      (_sem_RowConstraint_RowCheckConstraint (_sem_Annotation _ann) _name (_sem_ScalarExpr _expr))
  _sem_RowConstraint (RowUniqueConstraint _ann _name) =
      (_sem_RowConstraint_RowUniqueConstraint (_sem_Annotation _ann) _name)
  _sem_RowConstraint (RowPrimaryKeyConstraint _ann _name) =
      (_sem_RowConstraint_RowPrimaryKeyConstraint (_sem_Annotation _ann) _name)
  _sem_RowConstraint (RowReferenceConstraint _ann _name _table _att _onUpdate _onDelete) =
      (_sem_RowConstraint_RowReferenceConstraint (_sem_Annotation _ann) _name (_sem_Name _table) _att _onUpdate _onDelete)
  -- semantic domain
  type T_RowConstraint = Catalog ->
                         TypeCheckFlags ->
                         (Maybe TypeExtra) ->
                         ( RowConstraint,RowConstraint)
  data Inh_RowConstraint = Inh_RowConstraint {_cat_Inh_RowConstraint :: Catalog,_flags_Inh_RowConstraint :: TypeCheckFlags,_imCast_Inh_RowConstraint :: (Maybe TypeExtra)}
  data Syn_RowConstraint = Syn_RowConstraint {_annotatedTree_Syn_RowConstraint :: RowConstraint,_originalTree_Syn_RowConstraint :: RowConstraint}
  _wrap_RowConstraint :: T_RowConstraint ->
                        Inh_RowConstraint ->
                        Syn_RowConstraint
  _wrap_RowConstraint sem (Inh_RowConstraint _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_RowConstraint _lhsOannotatedTree _lhsOoriginalTree))
  _sem_RowConstraint_DefaultConstraint :: T_Annotation ->
                                         String ->
                                         T_ScalarExpr ->
                                         T_RowConstraint
  _sem_RowConstraint_DefaultConstraint ann_ name_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 78, column 39)
                _annOtpe =
                    ({-# LINE 78 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9058 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 79, column 39)
                _exprOdownEnv =
                    ({-# LINE 79 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 9064 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 80, column 39)
                _exprOexpectedCast =
                    ({-# LINE 80 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 9070 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 81, column 39)
                _exprOexpectedType =
                    ({-# LINE 81 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 9076 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 149, column 25)
                _exprOodbcFunction =
                    ({-# LINE 149 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 9082 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 816, column 39)
                _exprOassignmentCastContext =
                    ({-# LINE 816 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 9088 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DefaultConstraint _annIannotatedTree name_ _exprIannotatedTree
                     {-# LINE 9094 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DefaultConstraint _annIoriginalTree name_ _exprIoriginalTree
                     {-# LINE 9100 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9106 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9112 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9118 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9124 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9130 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9136 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9142 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9148 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_NullConstraint :: T_Annotation ->
                                      String ->
                                      T_RowConstraint
  _sem_RowConstraint_NullConstraint ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 77, column 36)
                _annOtpe =
                    ({-# LINE 77 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9174 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NullConstraint _annIannotatedTree name_
                     {-# LINE 9180 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NullConstraint _annIoriginalTree name_
                     {-# LINE 9186 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9192 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9198 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9204 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9210 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9216 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_NotNullConstraint :: T_Annotation ->
                                         String ->
                                         T_RowConstraint
  _sem_RowConstraint_NotNullConstraint ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 76, column 39)
                _annOtpe =
                    ({-# LINE 76 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9240 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NotNullConstraint _annIannotatedTree name_
                     {-# LINE 9246 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NotNullConstraint _annIoriginalTree name_
                     {-# LINE 9252 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9258 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9264 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9270 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9276 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9282 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_IdentityConstraint :: T_Annotation ->
                                          String ->
                                          ((Maybe (Integer,Integer))) ->
                                          T_RowConstraint
  _sem_RowConstraint_IdentityConstraint ann_ name_ seedAndInc_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 75, column 40)
                _annOtpe =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9307 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     IdentityConstraint _annIannotatedTree name_ seedAndInc_
                     {-# LINE 9313 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     IdentityConstraint _annIoriginalTree name_ seedAndInc_
                     {-# LINE 9319 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9325 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9331 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9337 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9343 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9349 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_RowCheckConstraint :: T_Annotation ->
                                          String ->
                                          T_ScalarExpr ->
                                          T_RowConstraint
  _sem_RowConstraint_RowCheckConstraint ann_ name_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 82, column 40)
                _annOtpe =
                    ({-# LINE 82 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9386 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 83, column 40)
                _exprOdownEnv =
                    ({-# LINE 83 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 9392 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 84, column 40)
                _exprOexpectedCast =
                    ({-# LINE 84 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 9398 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 85, column 40)
                _exprOexpectedType =
                    ({-# LINE 85 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 9404 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 150, column 26)
                _exprOodbcFunction =
                    ({-# LINE 150 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 9410 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 817, column 40)
                _exprOassignmentCastContext =
                    ({-# LINE 817 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 9416 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowCheckConstraint _annIannotatedTree name_ _exprIannotatedTree
                     {-# LINE 9422 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowCheckConstraint _annIoriginalTree name_ _exprIoriginalTree
                     {-# LINE 9428 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9434 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9440 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9446 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9452 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9458 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9464 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9470 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9476 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_RowUniqueConstraint :: T_Annotation ->
                                           String ->
                                           T_RowConstraint
  _sem_RowConstraint_RowUniqueConstraint ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 89, column 41)
                _annOtpe =
                    ({-# LINE 89 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9502 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowUniqueConstraint _annIannotatedTree name_
                     {-# LINE 9508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowUniqueConstraint _annIoriginalTree name_
                     {-# LINE 9514 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9520 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9526 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9532 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9538 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9544 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_RowPrimaryKeyConstraint :: T_Annotation ->
                                               String ->
                                               T_RowConstraint
  _sem_RowConstraint_RowPrimaryKeyConstraint ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 86, column 45)
                _annOtpe =
                    ({-# LINE 86 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9568 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowPrimaryKeyConstraint _annIannotatedTree name_
                     {-# LINE 9574 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowPrimaryKeyConstraint _annIoriginalTree name_
                     {-# LINE 9580 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9586 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9592 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9598 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9604 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9610 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraint_RowReferenceConstraint :: T_Annotation ->
                                              String ->
                                              T_Name ->
                                              (Maybe NameComponent) ->
                                              Cascade ->
                                              Cascade ->
                                              T_RowConstraint
  _sem_RowConstraint_RowReferenceConstraint ann_ name_ table_ att_ onUpdate_ onDelete_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _tableOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: RowConstraint
                _lhsOoriginalTree :: RowConstraint
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tableOcat :: Catalog
                _tableOflags :: TypeCheckFlags
                _tableOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tableIannotatedTree :: Name
                _tableIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 87, column 44)
                _annOtpe =
                    ({-# LINE 87 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9644 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 88, column 44)
                _tableOtpe =
                    ({-# LINE 88 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 9650 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowReferenceConstraint _annIannotatedTree name_ _tableIannotatedTree att_ onUpdate_ onDelete_
                     {-# LINE 9656 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     RowReferenceConstraint _annIoriginalTree name_ _tableIoriginalTree att_ onUpdate_ onDelete_
                     {-# LINE 9662 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9674 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9680 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9686 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9692 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9698 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9704 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9710 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tableIannotatedTree,_tableIoriginalTree) =
                    table_ _tableOcat _tableOflags _tableOimCast _tableOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- RowConstraintList -------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : RowConstraintList 
           originalTree         : RowConstraintList 
     alternatives:
        alternative Cons:
           child hd             : RowConstraint 
           child tl             : RowConstraintList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type RowConstraintList = [RowConstraint]
  -- cata
  _sem_RowConstraintList :: RowConstraintList ->
                           T_RowConstraintList
  _sem_RowConstraintList list =
      (Prelude.foldr _sem_RowConstraintList_Cons _sem_RowConstraintList_Nil (Prelude.map _sem_RowConstraint list))
  -- semantic domain
  type T_RowConstraintList = Catalog ->
                             TypeCheckFlags ->
                             (Maybe TypeExtra) ->
                             ( RowConstraintList,RowConstraintList)
  data Inh_RowConstraintList = Inh_RowConstraintList {_cat_Inh_RowConstraintList :: Catalog,_flags_Inh_RowConstraintList :: TypeCheckFlags,_imCast_Inh_RowConstraintList :: (Maybe TypeExtra)}
  data Syn_RowConstraintList = Syn_RowConstraintList {_annotatedTree_Syn_RowConstraintList :: RowConstraintList,_originalTree_Syn_RowConstraintList :: RowConstraintList}
  _wrap_RowConstraintList :: T_RowConstraintList ->
                            Inh_RowConstraintList ->
                            Syn_RowConstraintList
  _wrap_RowConstraintList sem (Inh_RowConstraintList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_RowConstraintList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_RowConstraintList_Cons :: T_RowConstraint ->
                                T_RowConstraintList ->
                                T_RowConstraintList
  _sem_RowConstraintList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: RowConstraintList
                _lhsOoriginalTree :: RowConstraintList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: RowConstraint
                _hdIoriginalTree :: RowConstraint
                _tlIannotatedTree :: RowConstraintList
                _tlIoriginalTree :: RowConstraintList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 9781 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 9787 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9793 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9799 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9805 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9811 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9817 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 9823 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 9829 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 9835 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_RowConstraintList_Nil :: T_RowConstraintList
  _sem_RowConstraintList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: RowConstraintList
                _lhsOoriginalTree :: RowConstraintList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 9853 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 9859 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 9865 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 9871 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExpr --------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe TypeExtra
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
           odbcFunction         : Bool
        synthesized attributes:
           annotatedTree        : ScalarExpr 
           colExprs             : [(NameComponent,Maybe TypeExtra,ScalarExpr)]
           originalTree         : ScalarExpr 
           upType               : Maybe TypeExtra
     alternatives:
        alternative NumberLit:
           child ann            : Annotation 
           child d              : {String}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local digChars    : _
              local annotatedTree : _
              local originalTree : _
        alternative StringLit:
           child ann            : Annotation 
           child value          : {String}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative NullLit:
           child ann            : Annotation 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative BooleanLit:
           child ann            : Annotation 
           child b              : {Bool}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative TypedStringLit:
           child ann            : Annotation 
           child tn             : TypeName 
           child value          : {String}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Interval:
           child ann            : Annotation 
           child value          : {String}
           child field          : {IntervalField}
           child prec           : {Maybe Int}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Identifier:
           child ann            : Annotation 
           child i              : Name 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local elkp        : _
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Star:
           child ann            : Annotation 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local starCS      : _
              local annotatedTree : _
              local originalTree : _
        alternative QStar:
           child ann            : Annotation 
           child q              : {NameComponent}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local starCS      : _
              local annotatedTree : _
              local originalTree : _
        alternative PositionalArg:
           child ann            : Annotation 
           child p              : {Integer}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Placeholder:
           child ann            : Annotation 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative PrefixOp:
           child ann            : Annotation 
           child opName         : Name 
           child arg            : ScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local ttpe        : {Either [TypeError] ([TypeExtra],TypeExtra)}
              local annotatedTree : _
              local originalTree : _
        alternative PostfixOp:
           child ann            : Annotation 
           child opName         : Name 
           child arg            : ScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local ttpe        : {Either [TypeError] ([TypeExtra],TypeExtra)}
              local annotatedTree : _
              local originalTree : _
        alternative BinaryOp:
           child ann            : Annotation 
           child opName         : Name 
           child arg0           : ScalarExpr 
           child arg1           : ScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local ttpe        : {Either [TypeError] ([TypeExtra],TypeExtra)}
              local annotatedTree : _
              local originalTree : _
        alternative SpecialOp:
           child ann            : Annotation 
           child opName         : Name 
           child args           : ScalarExprList 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local ttpe        : {Either [TypeError] ([TypeExtra],TypeExtra)}
              local annotatedTree : _
              local originalTree : _
        alternative Extract:
           child ann            : Annotation 
           child field          : {ExtractField}
           child e              : ScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative App:
           child ann            : Annotation 
           child funName        : Name 
           child args           : ScalarExprList 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : {Either [TypeError] TypeExtra}
              local funName     : _
              local ttpe        : {Either [TypeError] ([TypeExtra],TypeExtra)}
              local annotatedTree : _
              local originalTree : _
        alternative AggregateApp:
           child ann            : Annotation 
           child aggDistinct    : {Distinct}
           child fn             : ScalarExpr 
           child orderBy        : ScalarExprDirectionPairList 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative WindowApp:
           child ann            : Annotation 
           child fn             : ScalarExpr 
           child partitionBy    : ScalarExprList 
           child orderBy        : ScalarExprDirectionPairList 
           child frm            : {Maybe FrameClause}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Cast:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           child tn             : TypeName 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative ImplicitCast:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           child te             : {TypeExtra}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Case:
           child ann            : Annotation 
           child cases          : CaseScalarExprListScalarExprPairList 
           child els            : MaybeScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local whenTypes   : _
              local thenTypes   : _
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative CaseSimple:
           child ann            : Annotation 
           child value          : ScalarExpr 
           child cases          : CaseScalarExprListScalarExprPairList 
           child els            : MaybeScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local whenTypes   : _
              local thenTypes   : _
              local whent       : _
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Parens:
           child ann            : Annotation 
           child ex             : ScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative InPredicate:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           child i              : {Bool}
           child list           : InList 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local rt          : {Either [TypeError] TypeExtra}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative Exists:
           child ann            : Annotation 
           child sel            : QueryExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative ScalarSubQuery:
           child ann            : Annotation 
           child sel            : QueryExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative LiftApp:
           child ann            : Annotation 
           child oper           : Name 
           child flav           : {LiftFlavour}
           child args           : ScalarExprList 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative OdbcLiteral:
           child ann            : Annotation 
           child olt            : {OdbcLiteralType}
           child val            : {String}
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative OdbcFunc:
           child ann            : Annotation 
           child ex             : ScalarExpr 
           visit 0:
              local upType      : _
              local dialectTypeName : {Text -> Either [TypeError] Text}
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
        alternative AntiScalarExpr:
           child string         : {String}
           visit 0:
              local tpe         : _
              local annotatedTree : _
              local originalTree : _
  -}
  data ScalarExpr = NumberLit (Annotation) (String)
                  | StringLit (Annotation) (String)
                  | NullLit (Annotation)
                  | BooleanLit (Annotation) (Bool)
                  | TypedStringLit (Annotation) (TypeName) (String)
                  | Interval (Annotation) (String) (IntervalField) ((Maybe Int))
                  | Identifier (Annotation) (Name)
                  | Star (Annotation)
                  | QStar (Annotation) (NameComponent)
                  | PositionalArg (Annotation) (Integer)
                  | Placeholder (Annotation)
                  | PrefixOp (Annotation) (Name) (ScalarExpr)
                  | PostfixOp (Annotation) (Name) (ScalarExpr)
                  | BinaryOp (Annotation) (Name) (ScalarExpr) (ScalarExpr)
                  | SpecialOp (Annotation) (Name) (ScalarExprList)
                  | Extract (Annotation) (ExtractField) (ScalarExpr)
                  | App (Annotation) (Name) (ScalarExprList)
                  | AggregateApp (Annotation) (Distinct) (ScalarExpr) (ScalarExprDirectionPairList)
                  | WindowApp (Annotation) (ScalarExpr) (ScalarExprList) (ScalarExprDirectionPairList) ((Maybe FrameClause))
                  | Cast (Annotation) (ScalarExpr) (TypeName)
                  | ImplicitCast (Annotation) (ScalarExpr) (TypeExtra)
                  | Case (Annotation) (CaseScalarExprListScalarExprPairList) (MaybeScalarExpr)
                  | CaseSimple (Annotation) (ScalarExpr) (CaseScalarExprListScalarExprPairList) (MaybeScalarExpr)
                  | Parens (Annotation) (ScalarExpr)
                  | InPredicate (Annotation) (ScalarExpr) (Bool) (InList)
                  | Exists (Annotation) (QueryExpr)
                  | ScalarSubQuery (Annotation) (QueryExpr)
                  | LiftApp (Annotation) (Name) (LiftFlavour) (ScalarExprList)
                  | OdbcLiteral (Annotation) (OdbcLiteralType) (String)
                  | OdbcFunc (Annotation) (ScalarExpr)
                  | AntiScalarExpr (String)
                  deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_ScalarExpr :: ScalarExpr ->
                    T_ScalarExpr
  _sem_ScalarExpr (NumberLit _ann _d) =
      (_sem_ScalarExpr_NumberLit (_sem_Annotation _ann) _d)
  _sem_ScalarExpr (StringLit _ann _value) =
      (_sem_ScalarExpr_StringLit (_sem_Annotation _ann) _value)
  _sem_ScalarExpr (NullLit _ann) =
      (_sem_ScalarExpr_NullLit (_sem_Annotation _ann))
  _sem_ScalarExpr (BooleanLit _ann _b) =
      (_sem_ScalarExpr_BooleanLit (_sem_Annotation _ann) _b)
  _sem_ScalarExpr (TypedStringLit _ann _tn _value) =
      (_sem_ScalarExpr_TypedStringLit (_sem_Annotation _ann) (_sem_TypeName _tn) _value)
  _sem_ScalarExpr (Interval _ann _value _field _prec) =
      (_sem_ScalarExpr_Interval (_sem_Annotation _ann) _value _field _prec)
  _sem_ScalarExpr (Identifier _ann _i) =
      (_sem_ScalarExpr_Identifier (_sem_Annotation _ann) (_sem_Name _i))
  _sem_ScalarExpr (Star _ann) =
      (_sem_ScalarExpr_Star (_sem_Annotation _ann))
  _sem_ScalarExpr (QStar _ann _q) =
      (_sem_ScalarExpr_QStar (_sem_Annotation _ann) _q)
  _sem_ScalarExpr (PositionalArg _ann _p) =
      (_sem_ScalarExpr_PositionalArg (_sem_Annotation _ann) _p)
  _sem_ScalarExpr (Placeholder _ann) =
      (_sem_ScalarExpr_Placeholder (_sem_Annotation _ann))
  _sem_ScalarExpr (PrefixOp _ann _opName _arg) =
      (_sem_ScalarExpr_PrefixOp (_sem_Annotation _ann) (_sem_Name _opName) (_sem_ScalarExpr _arg))
  _sem_ScalarExpr (PostfixOp _ann _opName _arg) =
      (_sem_ScalarExpr_PostfixOp (_sem_Annotation _ann) (_sem_Name _opName) (_sem_ScalarExpr _arg))
  _sem_ScalarExpr (BinaryOp _ann _opName _arg0 _arg1) =
      (_sem_ScalarExpr_BinaryOp (_sem_Annotation _ann) (_sem_Name _opName) (_sem_ScalarExpr _arg0) (_sem_ScalarExpr _arg1))
  _sem_ScalarExpr (SpecialOp _ann _opName _args) =
      (_sem_ScalarExpr_SpecialOp (_sem_Annotation _ann) (_sem_Name _opName) (_sem_ScalarExprList _args))
  _sem_ScalarExpr (Extract _ann _field _e) =
      (_sem_ScalarExpr_Extract (_sem_Annotation _ann) _field (_sem_ScalarExpr _e))
  _sem_ScalarExpr (App _ann _funName _args) =
      (_sem_ScalarExpr_App (_sem_Annotation _ann) (_sem_Name _funName) (_sem_ScalarExprList _args))
  _sem_ScalarExpr (AggregateApp _ann _aggDistinct _fn _orderBy) =
      (_sem_ScalarExpr_AggregateApp (_sem_Annotation _ann) _aggDistinct (_sem_ScalarExpr _fn) (_sem_ScalarExprDirectionPairList _orderBy))
  _sem_ScalarExpr (WindowApp _ann _fn _partitionBy _orderBy _frm) =
      (_sem_ScalarExpr_WindowApp (_sem_Annotation _ann) (_sem_ScalarExpr _fn) (_sem_ScalarExprList _partitionBy) (_sem_ScalarExprDirectionPairList _orderBy) _frm)
  _sem_ScalarExpr (Cast _ann _expr _tn) =
      (_sem_ScalarExpr_Cast (_sem_Annotation _ann) (_sem_ScalarExpr _expr) (_sem_TypeName _tn))
  _sem_ScalarExpr (ImplicitCast _ann _expr _te) =
      (_sem_ScalarExpr_ImplicitCast (_sem_Annotation _ann) (_sem_ScalarExpr _expr) _te)
  _sem_ScalarExpr (Case _ann _cases _els) =
      (_sem_ScalarExpr_Case (_sem_Annotation _ann) (_sem_CaseScalarExprListScalarExprPairList _cases) (_sem_MaybeScalarExpr _els))
  _sem_ScalarExpr (CaseSimple _ann _value _cases _els) =
      (_sem_ScalarExpr_CaseSimple (_sem_Annotation _ann) (_sem_ScalarExpr _value) (_sem_CaseScalarExprListScalarExprPairList _cases) (_sem_MaybeScalarExpr _els))
  _sem_ScalarExpr (Parens _ann _ex) =
      (_sem_ScalarExpr_Parens (_sem_Annotation _ann) (_sem_ScalarExpr _ex))
  _sem_ScalarExpr (InPredicate _ann _expr _i _list) =
      (_sem_ScalarExpr_InPredicate (_sem_Annotation _ann) (_sem_ScalarExpr _expr) _i (_sem_InList _list))
  _sem_ScalarExpr (Exists _ann _sel) =
      (_sem_ScalarExpr_Exists (_sem_Annotation _ann) (_sem_QueryExpr _sel))
  _sem_ScalarExpr (ScalarSubQuery _ann _sel) =
      (_sem_ScalarExpr_ScalarSubQuery (_sem_Annotation _ann) (_sem_QueryExpr _sel))
  _sem_ScalarExpr (LiftApp _ann _oper _flav _args) =
      (_sem_ScalarExpr_LiftApp (_sem_Annotation _ann) (_sem_Name _oper) _flav (_sem_ScalarExprList _args))
  _sem_ScalarExpr (OdbcLiteral _ann _olt _val) =
      (_sem_ScalarExpr_OdbcLiteral (_sem_Annotation _ann) _olt _val)
  _sem_ScalarExpr (OdbcFunc _ann _ex) =
      (_sem_ScalarExpr_OdbcFunc (_sem_Annotation _ann) (_sem_ScalarExpr _ex))
  _sem_ScalarExpr (AntiScalarExpr _string) =
      (_sem_ScalarExpr_AntiScalarExpr _string)
  -- semantic domain
  type T_ScalarExpr = Bool ->
                      Catalog ->
                      Environment ->
                      Bool ->
                      (Maybe TypeExtra) ->
                      TypeCheckFlags ->
                      (Maybe TypeExtra) ->
                      Bool ->
                      ( ScalarExpr,([(NameComponent,Maybe TypeExtra,ScalarExpr)]),ScalarExpr,(Maybe TypeExtra))
  data Inh_ScalarExpr = Inh_ScalarExpr {_assignmentCastContext_Inh_ScalarExpr :: Bool,_cat_Inh_ScalarExpr :: Catalog,_downEnv_Inh_ScalarExpr :: Environment,_expectedCast_Inh_ScalarExpr :: Bool,_expectedType_Inh_ScalarExpr :: (Maybe TypeExtra),_flags_Inh_ScalarExpr :: TypeCheckFlags,_imCast_Inh_ScalarExpr :: (Maybe TypeExtra),_odbcFunction_Inh_ScalarExpr :: Bool}
  data Syn_ScalarExpr = Syn_ScalarExpr {_annotatedTree_Syn_ScalarExpr :: ScalarExpr,_colExprs_Syn_ScalarExpr :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)]),_originalTree_Syn_ScalarExpr :: ScalarExpr,_upType_Syn_ScalarExpr :: (Maybe TypeExtra)}
  _wrap_ScalarExpr :: T_ScalarExpr ->
                     Inh_ScalarExpr ->
                     Syn_ScalarExpr
  _wrap_ScalarExpr sem (Inh_ScalarExpr _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast _lhsIodbcFunction) =
      (let ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast _lhsIodbcFunction
       in  (Syn_ScalarExpr _lhsOannotatedTree _lhsOcolExprs _lhsOoriginalTree _lhsOupType))
  _sem_ScalarExpr_NumberLit :: T_Annotation ->
                              String ->
                              T_ScalarExpr
  _sem_ScalarExpr_NumberLit ann_ d_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 10364 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 10370 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 10376 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 10382 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 10393 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 10399 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 250, column 9)
                _tpe =
                    ({-# LINE 250 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     if all (`elem` _digChars    ) d_
                     then (mkTypeExtraNN . ScalarType) <$> classifyInteger (tcfDialect _lhsIflags) d_
                     else (mkTypeExtraNN . ScalarType) <$> (_dialectTypeName     "numeric")
                     {-# LINE 10407 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 254, column 9)
                _digChars =
                    ({-# LINE 254 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     concatMap show [(0::Int)..9]
                     {-# LINE 10413 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NumberLit _annIannotatedTree d_
                     {-# LINE 10419 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NumberLit _annIoriginalTree d_
                     {-# LINE 10425 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 10431 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 10437 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 10443 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 10449 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_StringLit :: T_Annotation ->
                              String ->
                              T_ScalarExpr
  _sem_ScalarExpr_StringLit ann_ value_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 10496 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 10502 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 10508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 10514 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 10525 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 10531 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 258, column 9)
                _tpe =
                    ({-# LINE 258 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right $ (mkTypeExtraNN UnknownType) {tePrecision = Just $ length value_}
                     {-# LINE 10537 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     StringLit _annIannotatedTree value_
                     {-# LINE 10543 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     StringLit _annIoriginalTree value_
                     {-# LINE 10549 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 10555 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 10561 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 10567 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 10573 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_NullLit :: T_Annotation ->
                            T_ScalarExpr
  _sem_ScalarExpr_NullLit ann_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 10619 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 10625 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 10631 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 10637 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 10648 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 10654 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 261, column 10)
                _tpe =
                    ({-# LINE 261 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right $ mkTypeExtra UnknownType
                     {-# LINE 10660 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NullLit _annIannotatedTree
                     {-# LINE 10666 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NullLit _annIoriginalTree
                     {-# LINE 10672 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 10678 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 10684 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 10690 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 10696 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_BooleanLit :: T_Annotation ->
                               Bool ->
                               T_ScalarExpr
  _sem_ScalarExpr_BooleanLit ann_ b_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 10743 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 10749 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 10755 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 10761 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 10772 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 10778 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 241, column 9)
                _tpe =
                    ({-# LINE 241 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap (mkTypeExtraNN . ScalarType) $ _dialectTypeName     "boolean"
                     {-# LINE 10784 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     BooleanLit _annIannotatedTree b_
                     {-# LINE 10790 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     BooleanLit _annIoriginalTree b_
                     {-# LINE 10796 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 10802 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 10808 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 10814 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 10820 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_TypedStringLit :: T_Annotation ->
                                   T_TypeName ->
                                   String ->
                                   T_ScalarExpr
  _sem_ScalarExpr_TypedStringLit ann_ tn_ value_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _tnOcat :: Catalog
                _tnOflags :: TypeCheckFlags
                _tnOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tnIannotatedTree :: TypeName
                _tnInamedType :: (Maybe TypeExtra)
                _tnIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 10874 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 10880 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 10886 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 10892 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 10903 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 10909 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 271, column 10)
                _tpe =
                    ({-# LINE 271 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right _tnInamedType
                     {-# LINE 10915 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TypedStringLit _annIannotatedTree _tnIannotatedTree value_
                     {-# LINE 10921 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TypedStringLit _annIoriginalTree _tnIoriginalTree value_
                     {-# LINE 10927 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 10933 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 10939 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 10945 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 10951 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 10957 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 10963 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 10969 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tnIannotatedTree,_tnInamedType,_tnIoriginalTree) =
                    tn_ _tnOcat _tnOflags _tnOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Interval :: T_Annotation ->
                             String ->
                             IntervalField ->
                             (Maybe Int) ->
                             T_ScalarExpr
  _sem_ScalarExpr_Interval ann_ value_ field_ prec_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11020 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11026 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11032 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11038 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11049 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11055 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 283, column 9)
                _tpe =
                    ({-# LINE 283 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right $ mkTypeExtraNN $ ScalarType "interval"
                     {-# LINE 11061 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Interval _annIannotatedTree value_ field_ prec_
                     {-# LINE 11067 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Interval _annIoriginalTree value_ field_ prec_
                     {-# LINE 11073 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 11079 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11085 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11091 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11097 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Identifier :: T_Annotation ->
                               T_Name ->
                               T_ScalarExpr
  _sem_ScalarExpr_Identifier ann_ i_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _iOtpe :: (Either [TypeError] TypeExtra)
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _iOcat :: Catalog
                _iOflags :: TypeCheckFlags
                _iOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _iIannotatedTree :: Name
                _iIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11150 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11156 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11162 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11168 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11179 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11185 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 326, column 10)
                _elkp =
                    ({-# LINE 326 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     E.envLookupIdentifier (nameComponents _iIoriginalTree) _lhsIdownEnv
                     {-# LINE 11191 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 327, column 10)
                _tpe =
                    ({-# LINE 327 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap snd _elkp
                     {-# LINE 11197 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 329, column 10)
                _lhsOannotatedTree =
                    ({-# LINE 329 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _annotatedTree
                     {-# LINE 11203 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 330, column 10)
                _annotatedTree =
                    ({-# LINE 330 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     let t = Identifier _annIannotatedTree _iIannotatedTree
                     in fromMaybe t $ do
                         case tcfAddQualifiers _lhsIflags of
                           False -> Nothing
                           True -> do
                                  ((q,i),_) <- either (const Nothing) Just _elkp
                                  if q /= ""
                                    then
                                         return $ Identifier _annIannotatedTree
                                                    (Name emptyAnnotation [Nmc $ T.unpack q, Nmc $ T.unpack i])
                                    else return t
                     {-# LINE 11219 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 350, column 10)
                _iOtpe =
                    ({-# LINE 350 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 11225 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Identifier _annIoriginalTree _iIoriginalTree
                     {-# LINE 11231 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11237 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11243 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11249 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _iOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11255 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _iOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11261 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _iOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 11267 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _iIannotatedTree,_iIoriginalTree) =
                    i_ _iOcat _iOflags _iOimCast _iOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Star :: T_Annotation ->
                         T_ScalarExpr
  _sem_ScalarExpr_Star ann_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11316 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11322 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11328 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11334 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11345 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11351 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 714, column 9)
                _tpe =
                    ({-# LINE 714 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _originalTree of
                       Star _ ->
                         E.envExpandStar Nothing _lhsIdownEnv
                         >>= _starCS
                       QStar _ q -> do
                         E.envExpandStar (Just q) _lhsIdownEnv
                         >>= _starCS
                       _ -> Left [InternalError "wrong ctor in sem rule for star, qstar in scalarexprs.ag"]
                     {-# LINE 11364 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 723, column 9)
                _starCS =
                    ({-# LINE 723 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right . mkTypeExtraNN . CompositeType . map (\((_q,n),t) -> (n,t))
                     {-# LINE 11370 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Star _annIannotatedTree
                     {-# LINE 11376 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Star _annIoriginalTree
                     {-# LINE 11382 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 11388 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11394 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11400 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11406 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_QStar :: T_Annotation ->
                          NameComponent ->
                          T_ScalarExpr
  _sem_ScalarExpr_QStar ann_ q_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11454 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11460 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11466 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11472 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11483 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11489 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 714, column 9)
                _tpe =
                    ({-# LINE 714 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _originalTree of
                       Star _ ->
                         E.envExpandStar Nothing _lhsIdownEnv
                         >>= _starCS
                       QStar _ q -> do
                         E.envExpandStar (Just q) _lhsIdownEnv
                         >>= _starCS
                       _ -> Left [InternalError "wrong ctor in sem rule for star, qstar in scalarexprs.ag"]
                     {-# LINE 11502 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 723, column 9)
                _starCS =
                    ({-# LINE 723 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right . mkTypeExtraNN . CompositeType . map (\((_q,n),t) -> (n,t))
                     {-# LINE 11508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     QStar _annIannotatedTree q_
                     {-# LINE 11514 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     QStar _annIoriginalTree q_
                     {-# LINE 11520 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 11526 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11532 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11538 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11544 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_PositionalArg :: T_Annotation ->
                                  Integer ->
                                  T_ScalarExpr
  _sem_ScalarExpr_PositionalArg ann_ p_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11591 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11597 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11603 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11609 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11620 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11626 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 735, column 9)
                _tpe =
                    ({-# LINE 735 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 11632 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PositionalArg _annIannotatedTree p_
                     {-# LINE 11638 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PositionalArg _annIoriginalTree p_
                     {-# LINE 11644 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 11650 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11656 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11662 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Placeholder :: T_Annotation ->
                                T_ScalarExpr
  _sem_ScalarExpr_Placeholder ann_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11714 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11720 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11726 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11732 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11743 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11749 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 301, column 10)
                _tpe =
                    ({-# LINE 301 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right $ mkTypeExtraNN UnknownType
                     {-# LINE 11755 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Placeholder _annIannotatedTree
                     {-# LINE 11761 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Placeholder _annIoriginalTree
                     {-# LINE 11767 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 11773 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11779 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11785 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11791 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_PrefixOp :: T_Annotation ->
                             T_Name ->
                             T_ScalarExpr ->
                             T_ScalarExpr
  _sem_ScalarExpr_PrefixOp ann_ opName_ arg_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _argOodbcFunction :: Bool
                _opNameOtpe :: (Either [TypeError] TypeExtra)
                _tpe :: (Either [TypeError] TypeExtra)
                _ttpe :: (Either [TypeError] ([TypeExtra],TypeExtra))
                _argOexpectedType :: (Maybe TypeExtra)
                _argOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _opNameOcat :: Catalog
                _opNameOflags :: TypeCheckFlags
                _opNameOimCast :: (Maybe TypeExtra)
                _argOassignmentCastContext :: Bool
                _argOcat :: Catalog
                _argOdownEnv :: Environment
                _argOflags :: TypeCheckFlags
                _argOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _opNameIannotatedTree :: Name
                _opNameIoriginalTree :: Name
                _argIannotatedTree :: ScalarExpr
                _argIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _argIoriginalTree :: ScalarExpr
                _argIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 11859 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 11865 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 11871 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 11877 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 11888 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 11894 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 176, column 26)
                _argOodbcFunction =
                    ({-# LINE 176 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 11900 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 211, column 9)
                _opNameOtpe =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 11906 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 365, column 10)
                _tpe =
                    ({-# LINE 365 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap snd _ttpe
                     {-# LINE 11912 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 434, column 10)
                _ttpe =
                    ({-# LINE 434 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     tcAppLike (tcfDialect _lhsIflags) _lhsIcat (nameComponents _opNameIoriginalTree) (getMaybeIntsFromLiterals [_argIoriginalTree]) [_argIupType]
                     {-# LINE 11918 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 435, column 10)
                _argOexpectedType =
                    ({-# LINE 435 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _ttpe     of
                       Right ([t],_) -> Just t
                       _ -> Nothing
                     {-# LINE 11926 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 457, column 9)
                _argOexpectedCast =
                    ({-# LINE 457 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 11932 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PrefixOp _annIannotatedTree _opNameIannotatedTree _argIannotatedTree
                     {-# LINE 11938 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PrefixOp _annIoriginalTree _opNameIoriginalTree _argIoriginalTree
                     {-# LINE 11944 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 11950 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 11956 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11962 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11968 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11974 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 11980 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 11986 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 11992 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 11998 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 12004 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12010 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12016 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _opNameIannotatedTree,_opNameIoriginalTree) =
                    opName_ _opNameOcat _opNameOflags _opNameOimCast _opNameOtpe
                ( _argIannotatedTree,_argIcolExprs,_argIoriginalTree,_argIupType) =
                    arg_ _argOassignmentCastContext _argOcat _argOdownEnv _argOexpectedCast _argOexpectedType _argOflags _argOimCast _argOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_PostfixOp :: T_Annotation ->
                              T_Name ->
                              T_ScalarExpr ->
                              T_ScalarExpr
  _sem_ScalarExpr_PostfixOp ann_ opName_ arg_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _argOodbcFunction :: Bool
                _opNameOtpe :: (Either [TypeError] TypeExtra)
                _tpe :: (Either [TypeError] TypeExtra)
                _ttpe :: (Either [TypeError] ([TypeExtra],TypeExtra))
                _argOexpectedType :: (Maybe TypeExtra)
                _argOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _opNameOcat :: Catalog
                _opNameOflags :: TypeCheckFlags
                _opNameOimCast :: (Maybe TypeExtra)
                _argOassignmentCastContext :: Bool
                _argOcat :: Catalog
                _argOdownEnv :: Environment
                _argOflags :: TypeCheckFlags
                _argOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _opNameIannotatedTree :: Name
                _opNameIoriginalTree :: Name
                _argIannotatedTree :: ScalarExpr
                _argIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _argIoriginalTree :: ScalarExpr
                _argIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 12088 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 12094 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 12100 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 12106 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 12117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 12123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 176, column 26)
                _argOodbcFunction =
                    ({-# LINE 176 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12129 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 211, column 9)
                _opNameOtpe =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 12135 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 365, column 10)
                _tpe =
                    ({-# LINE 365 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap snd _ttpe
                     {-# LINE 12141 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 434, column 10)
                _ttpe =
                    ({-# LINE 434 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     tcAppLike (tcfDialect _lhsIflags) _lhsIcat (nameComponents _opNameIoriginalTree) (getMaybeIntsFromLiterals [_argIoriginalTree]) [_argIupType]
                     {-# LINE 12147 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 435, column 10)
                _argOexpectedType =
                    ({-# LINE 435 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _ttpe     of
                       Right ([t],_) -> Just t
                       _ -> Nothing
                     {-# LINE 12155 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 457, column 9)
                _argOexpectedCast =
                    ({-# LINE 457 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12161 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PostfixOp _annIannotatedTree _opNameIannotatedTree _argIannotatedTree
                     {-# LINE 12167 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PostfixOp _annIoriginalTree _opNameIoriginalTree _argIoriginalTree
                     {-# LINE 12173 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 12179 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 12185 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12191 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12197 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12203 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12209 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12215 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 12221 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12227 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 12233 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12239 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12245 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _opNameIannotatedTree,_opNameIoriginalTree) =
                    opName_ _opNameOcat _opNameOflags _opNameOimCast _opNameOtpe
                ( _argIannotatedTree,_argIcolExprs,_argIoriginalTree,_argIupType) =
                    arg_ _argOassignmentCastContext _argOcat _argOdownEnv _argOexpectedCast _argOexpectedType _argOflags _argOimCast _argOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_BinaryOp :: T_Annotation ->
                             T_Name ->
                             T_ScalarExpr ->
                             T_ScalarExpr ->
                             T_ScalarExpr
  _sem_ScalarExpr_BinaryOp ann_ opName_ arg0_ arg1_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _arg0OodbcFunction :: Bool
                _arg1OodbcFunction :: Bool
                _opNameOtpe :: (Either [TypeError] TypeExtra)
                _tpe :: (Either [TypeError] TypeExtra)
                _ttpe :: (Either [TypeError] ([TypeExtra],TypeExtra))
                _arg0OexpectedType :: (Maybe TypeExtra)
                _arg1OexpectedType :: (Maybe TypeExtra)
                _arg0OexpectedCast :: Bool
                _arg1OexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _opNameOcat :: Catalog
                _opNameOflags :: TypeCheckFlags
                _opNameOimCast :: (Maybe TypeExtra)
                _arg0OassignmentCastContext :: Bool
                _arg0Ocat :: Catalog
                _arg0OdownEnv :: Environment
                _arg0Oflags :: TypeCheckFlags
                _arg0OimCast :: (Maybe TypeExtra)
                _arg1OassignmentCastContext :: Bool
                _arg1Ocat :: Catalog
                _arg1OdownEnv :: Environment
                _arg1Oflags :: TypeCheckFlags
                _arg1OimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _opNameIannotatedTree :: Name
                _opNameIoriginalTree :: Name
                _arg0IannotatedTree :: ScalarExpr
                _arg0IcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _arg0IoriginalTree :: ScalarExpr
                _arg0IupType :: (Maybe TypeExtra)
                _arg1IannotatedTree :: ScalarExpr
                _arg1IcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _arg1IoriginalTree :: ScalarExpr
                _arg1IupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 12330 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 12336 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 12342 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 12348 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 12359 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 12365 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 177, column 16)
                _arg0OodbcFunction =
                    ({-# LINE 177 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12371 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 178, column 16)
                _arg1OodbcFunction =
                    ({-# LINE 178 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12377 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 211, column 9)
                _opNameOtpe =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 12383 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 365, column 10)
                _tpe =
                    ({-# LINE 365 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap snd _ttpe
                     {-# LINE 12389 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 426, column 10)
                _ttpe =
                    ({-# LINE 426 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     tcAppLike (tcfDialect _lhsIflags)
                               _lhsIcat (nameComponents _opNameIoriginalTree) (getMaybeIntsFromLiterals [_arg0IoriginalTree,_arg1IoriginalTree])
                               [_arg0IupType,_arg1IupType]
                     {-# LINE 12397 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 429, column 10)
                (_arg0OexpectedType,_arg1OexpectedType) =
                    ({-# LINE 429 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _ttpe     of
                       Right ([t0,t1],_) -> (Just t0,Just t1)
                       _ -> (Nothing,Nothing)
                     {-# LINE 12405 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 459, column 9)
                _arg0OexpectedCast =
                    ({-# LINE 459 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12411 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 460, column 9)
                _arg1OexpectedCast =
                    ({-# LINE 460 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12417 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     BinaryOp _annIannotatedTree _opNameIannotatedTree _arg0IannotatedTree _arg1IannotatedTree
                     {-# LINE 12423 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     BinaryOp _annIoriginalTree _opNameIoriginalTree _arg0IoriginalTree _arg1IoriginalTree
                     {-# LINE 12429 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 12435 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 12441 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12447 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12453 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12459 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12465 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12471 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg0OassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 12477 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg0Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12483 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg0OdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 12489 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg0Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12495 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg0OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12501 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg1OassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 12507 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12513 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg1OdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 12519 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12525 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _arg1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12531 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _opNameIannotatedTree,_opNameIoriginalTree) =
                    opName_ _opNameOcat _opNameOflags _opNameOimCast _opNameOtpe
                ( _arg0IannotatedTree,_arg0IcolExprs,_arg0IoriginalTree,_arg0IupType) =
                    arg0_ _arg0OassignmentCastContext _arg0Ocat _arg0OdownEnv _arg0OexpectedCast _arg0OexpectedType _arg0Oflags _arg0OimCast _arg0OodbcFunction
                ( _arg1IannotatedTree,_arg1IcolExprs,_arg1IoriginalTree,_arg1IupType) =
                    arg1_ _arg1OassignmentCastContext _arg1Ocat _arg1OdownEnv _arg1OexpectedCast _arg1OexpectedType _arg1Oflags _arg1OimCast _arg1OodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_SpecialOp :: T_Annotation ->
                              T_Name ->
                              T_ScalarExprList ->
                              T_ScalarExpr
  _sem_ScalarExpr_SpecialOp ann_ opName_ args_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _opNameOtpe :: (Either [TypeError] TypeExtra)
                _tpe :: (Either [TypeError] TypeExtra)
                _ttpe :: (Either [TypeError] ([TypeExtra],TypeExtra))
                _argsOexpectedTypes :: ([TypeExtra])
                _argsOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _opNameOcat :: Catalog
                _opNameOflags :: TypeCheckFlags
                _opNameOimCast :: (Maybe TypeExtra)
                _argsOassignmentCastContext :: Bool
                _argsOcat :: Catalog
                _argsOdownEnv :: Environment
                _argsOflags :: TypeCheckFlags
                _argsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _opNameIannotatedTree :: Name
                _opNameIoriginalTree :: Name
                _argsIannotatedTree :: ScalarExprList
                _argsIoriginalTree :: ScalarExprList
                _argsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 12603 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 12609 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 12615 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 12621 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 12632 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 12638 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 211, column 9)
                _opNameOtpe =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 12644 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 365, column 10)
                _tpe =
                    ({-# LINE 365 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap snd _ttpe
                     {-# LINE 12650 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 440, column 10)
                _ttpe =
                    ({-# LINE 440 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     tcAppLike (tcfDialect _lhsIflags) _lhsIcat (nameComponents _opNameIoriginalTree) (getMaybeIntsFromLiterals _argsIoriginalTree) _argsIupTypes
                     {-# LINE 12656 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 441, column 10)
                _argsOexpectedTypes =
                    ({-# LINE 441 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const []) id $ fmap fst _ttpe
                     {-# LINE 12662 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 455, column 9)
                _argsOexpectedCast =
                    ({-# LINE 455 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SpecialOp _annIannotatedTree _opNameIannotatedTree _argsIannotatedTree
                     {-# LINE 12674 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SpecialOp _annIoriginalTree _opNameIoriginalTree _argsIoriginalTree
                     {-# LINE 12680 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 12686 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 12692 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12698 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12704 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12710 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12716 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _opNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12722 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 12728 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12734 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 12740 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12746 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12752 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _opNameIannotatedTree,_opNameIoriginalTree) =
                    opName_ _opNameOcat _opNameOflags _opNameOimCast _opNameOtpe
                ( _argsIannotatedTree,_argsIoriginalTree,_argsIupTypes) =
                    args_ _argsOassignmentCastContext _argsOcat _argsOdownEnv _argsOexpectedCast _argsOexpectedTypes _argsOflags _argsOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Extract :: T_Annotation ->
                            ExtractField ->
                            T_ScalarExpr ->
                            T_ScalarExpr
  _sem_ScalarExpr_Extract ann_ field_ e_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _eOodbcFunction :: Bool
                _eOexpectedType :: (Maybe TypeExtra)
                _eOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _eOassignmentCastContext :: Bool
                _eOcat :: Catalog
                _eOdownEnv :: Environment
                _eOflags :: TypeCheckFlags
                _eOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _eIannotatedTree :: ScalarExpr
                _eIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _eIoriginalTree :: ScalarExpr
                _eIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 12816 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 12822 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 12828 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 12834 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 12845 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 12851 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 172, column 15)
                _eOodbcFunction =
                    ({-# LINE 172 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12857 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 285, column 9)
                _tpe =
                    ({-# LINE 285 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     x <- maybe (Left []) Right _eIupType
                     if (teType x) `elem` (map ScalarType $ diDatetimeTypes $ tcfDialect _lhsIflags)
                       then do
                            i <- ScalarType <$> _dialectTypeName     "int"
                            return $ TypeExtra i Nothing Nothing $ teNullable x
                       else Left [NoMatchingOperator "extract" [teType x]]
                     {-# LINE 12869 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 293, column 9)
                _eOexpectedType =
                    ({-# LINE 293 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     x <- _eIupType
                     either (const Nothing)
                            (Just . TypeExtra (teType x) Nothing Nothing . teNullable)
                            _tpe
                     {-# LINE 12879 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 299, column 9)
                _eOexpectedCast =
                    ({-# LINE 299 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 12885 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Extract _annIannotatedTree field_ _eIannotatedTree
                     {-# LINE 12891 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Extract _annIoriginalTree field_ _eIoriginalTree
                     {-# LINE 12897 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 12903 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 12909 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12915 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12921 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _eOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 12927 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _eOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 12933 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _eOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 12939 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _eOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 12945 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _eOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 12951 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _eIannotatedTree,_eIcolExprs,_eIoriginalTree,_eIupType) =
                    e_ _eOassignmentCastContext _eOcat _eOdownEnv _eOexpectedCast _eOexpectedType _eOflags _eOimCast _eOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_App :: T_Annotation ->
                        T_Name ->
                        T_ScalarExprList ->
                        T_ScalarExpr
  _sem_ScalarExpr_App ann_ funName_ args_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _funNameOtpe :: (Either [TypeError] TypeExtra)
                _tpe :: (Either [TypeError] TypeExtra)
                _argsOexpectedTypes :: ([TypeExtra])
                _ttpe :: (Either [TypeError] ([TypeExtra],TypeExtra))
                _argsOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _funNameOcat :: Catalog
                _funNameOflags :: TypeCheckFlags
                _funNameOimCast :: (Maybe TypeExtra)
                _argsOassignmentCastContext :: Bool
                _argsOcat :: Catalog
                _argsOdownEnv :: Environment
                _argsOflags :: TypeCheckFlags
                _argsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _funNameIannotatedTree :: Name
                _funNameIoriginalTree :: Name
                _argsIannotatedTree :: ScalarExprList
                _argsIoriginalTree :: ScalarExprList
                _argsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 13019 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 13025 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 13031 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 13037 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 13048 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 13054 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 209, column 9)
                _funNameOtpe =
                    ({-# LINE 209 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 13060 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 365, column 10)
                _tpe =
                    ({-# LINE 365 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     fmap snd _ttpe
                     {-# LINE 13066 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 367, column 10)
                _argsOexpectedTypes =
                    ({-# LINE 367 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const []) id $ fmap fst _ttpe
                     {-# LINE 13072 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 381, column 10)
                _funName =
                    ({-# LINE 381 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     let y = if _lhsIodbcFunction
                             then let f [] = []
                                      f [Nmc x] = [Nmc $ "!odbc-" ++ x]
                                      f [QNmc x] = [QNmc $ "!odbc-" ++ x]
                                      f [x] = [x]
                                      f (x:xs) = x:f xs
                                  in (\(Name a nms) -> Name a (f nms)) _funNameIoriginalTree
                             else _funNameIoriginalTree
                     in                    y
                     {-# LINE 13086 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 404, column 10)
                _ttpe =
                    ({-# LINE 404 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _originalTree of
                       (App _ (Name _ [Nmc "count"]) [Star _]) ->
                           tcAppLike (tcfDialect _lhsIflags)
                                     _lhsIcat (nameComponents _funName    )
                                     (getMaybeIntsFromLiterals _argsIoriginalTree)
                                     [Just $ mkTypeExtraNN UnknownType]
                       (App _ (Name _ [Nmc n]) [_,Identifier _ (Name _ [Nmc tyi])])
                           | _lhsIodbcFunction && map toLower n == "convert" -> do
                           (ts,_r) <- do
                                     t <- _dialectTypeName     "int"
                                     tcAppLike (tcfDialect _lhsIflags)
                                       _lhsIcat (nameComponents _funName    ) (getMaybeIntsFromLiterals _argsIoriginalTree)
                                       [Just $ mkTypeExtraNN UnknownType, Just $ mkTypeExtraNN $ ScalarType t]
                           r' <- maybe (Left [UnrecognisedIdentifier $ T.pack tyi]) (Right . mkTypeExtra)
                                    $ lookup (map toLower tyi) odbcConvertTypes
                           Right (ts, r')
                       _ -> tcAppLike (tcfDialect _lhsIflags)
                                      _lhsIcat (nameComponents _funName    ) (getMaybeIntsFromLiterals _argsIoriginalTree) _argsIupTypes
                     {-# LINE 13109 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 455, column 9)
                _argsOexpectedCast =
                    ({-# LINE 455 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13115 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     App _annIannotatedTree _funNameIannotatedTree _argsIannotatedTree
                     {-# LINE 13121 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     App _annIoriginalTree _funNameIoriginalTree _argsIoriginalTree
                     {-# LINE 13127 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 13133 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 13139 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13145 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13151 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _funNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13157 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _funNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13163 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _funNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 13175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13181 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13187 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13193 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13199 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _funNameIannotatedTree,_funNameIoriginalTree) =
                    funName_ _funNameOcat _funNameOflags _funNameOimCast _funNameOtpe
                ( _argsIannotatedTree,_argsIoriginalTree,_argsIupTypes) =
                    args_ _argsOassignmentCastContext _argsOcat _argsOdownEnv _argsOexpectedCast _argsOexpectedTypes _argsOflags _argsOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_AggregateApp :: T_Annotation ->
                                 Distinct ->
                                 T_ScalarExpr ->
                                 T_ScalarExprDirectionPairList ->
                                 T_ScalarExpr
  _sem_ScalarExpr_AggregateApp ann_ aggDistinct_ fn_ orderBy_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _fnOodbcFunction :: Bool
                _fnOexpectedCast :: Bool
                _fnOexpectedType :: (Maybe TypeExtra)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _fnOassignmentCastContext :: Bool
                _fnOcat :: Catalog
                _fnOdownEnv :: Environment
                _fnOflags :: TypeCheckFlags
                _fnOimCast :: (Maybe TypeExtra)
                _orderByOcat :: Catalog
                _orderByOdownEnv :: Environment
                _orderByOflags :: TypeCheckFlags
                _orderByOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _fnIannotatedTree :: ScalarExpr
                _fnIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _fnIoriginalTree :: ScalarExpr
                _fnIupType :: (Maybe TypeExtra)
                _orderByIannotatedTree :: ScalarExprDirectionPairList
                _orderByIoriginalTree :: ScalarExprDirectionPairList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 13270 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 13276 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 13282 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 13288 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 13299 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 13305 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 179, column 20)
                _fnOodbcFunction =
                    ({-# LINE 179 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13311 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 443, column 10)
                _tpe =
                    ({-# LINE 443 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _fnIoriginalTree of
                       (App _ fnm@(Name _ [Nmc "count"]) [Star _]) ->
                            fmap snd $ tcAppLike (tcfDialect _lhsIflags) _lhsIcat (nameComponents fnm) [] [Just $ mkTypeExtraNN UnknownType]
                       _ -> maybe (Left []) Right _fnIupType
                     {-# LINE 13320 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 462, column 9)
                _fnOexpectedCast =
                    ({-# LINE 462 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13326 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 753, column 28)
                _fnOexpectedType =
                    ({-# LINE 753 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 13332 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AggregateApp _annIannotatedTree aggDistinct_ _fnIannotatedTree _orderByIannotatedTree
                     {-# LINE 13338 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AggregateApp _annIoriginalTree aggDistinct_ _fnIoriginalTree _orderByIoriginalTree
                     {-# LINE 13344 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 13350 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 13356 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13362 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13368 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 13374 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13380 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13386 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13392 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13398 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13404 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOdownEnv =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13410 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13416 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13422 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _fnIannotatedTree,_fnIcolExprs,_fnIoriginalTree,_fnIupType) =
                    fn_ _fnOassignmentCastContext _fnOcat _fnOdownEnv _fnOexpectedCast _fnOexpectedType _fnOflags _fnOimCast _fnOodbcFunction
                ( _orderByIannotatedTree,_orderByIoriginalTree) =
                    orderBy_ _orderByOcat _orderByOdownEnv _orderByOflags _orderByOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_WindowApp :: T_Annotation ->
                              T_ScalarExpr ->
                              T_ScalarExprList ->
                              T_ScalarExprDirectionPairList ->
                              (Maybe FrameClause) ->
                              T_ScalarExpr
  _sem_ScalarExpr_WindowApp ann_ fn_ partitionBy_ orderBy_ frm_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _fnOodbcFunction :: Bool
                _fnOexpectedCast :: Bool
                _partitionByOexpectedCast :: Bool
                _fnOexpectedType :: (Maybe TypeExtra)
                _partitionByOexpectedTypes :: ([TypeExtra])
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _fnOassignmentCastContext :: Bool
                _fnOcat :: Catalog
                _fnOdownEnv :: Environment
                _fnOflags :: TypeCheckFlags
                _fnOimCast :: (Maybe TypeExtra)
                _partitionByOassignmentCastContext :: Bool
                _partitionByOcat :: Catalog
                _partitionByOdownEnv :: Environment
                _partitionByOflags :: TypeCheckFlags
                _partitionByOimCast :: (Maybe TypeExtra)
                _orderByOcat :: Catalog
                _orderByOdownEnv :: Environment
                _orderByOflags :: TypeCheckFlags
                _orderByOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _fnIannotatedTree :: ScalarExpr
                _fnIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _fnIoriginalTree :: ScalarExpr
                _fnIupType :: (Maybe TypeExtra)
                _partitionByIannotatedTree :: ScalarExprList
                _partitionByIoriginalTree :: ScalarExprList
                _partitionByIupTypes :: ([Maybe TypeExtra])
                _orderByIannotatedTree :: ScalarExprDirectionPairList
                _orderByIoriginalTree :: ScalarExprDirectionPairList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 13504 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 13510 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 13516 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 13522 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 13533 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 13539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 180, column 17)
                _fnOodbcFunction =
                    ({-# LINE 180 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13545 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 449, column 10)
                _tpe =
                    ({-# LINE 449 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right _fnIupType
                     {-# LINE 13551 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 462, column 9)
                _fnOexpectedCast =
                    ({-# LINE 462 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 465, column 9)
                _partitionByOexpectedCast =
                    ({-# LINE 465 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13563 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 753, column 28)
                _fnOexpectedType =
                    ({-# LINE 753 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 13569 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 775, column 15)
                _partitionByOexpectedTypes =
                    ({-# LINE 775 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 13575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WindowApp _annIannotatedTree _fnIannotatedTree _partitionByIannotatedTree _orderByIannotatedTree frm_
                     {-# LINE 13581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WindowApp _annIoriginalTree _fnIoriginalTree _partitionByIoriginalTree _orderByIoriginalTree frm_
                     {-# LINE 13587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 13593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 13599 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13605 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13611 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 13617 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13623 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13629 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13635 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13641 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionByOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 13647 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionByOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13653 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionByOdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13659 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionByOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13665 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionByOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13671 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13677 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOdownEnv =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13683 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13689 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _orderByOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13695 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _fnIannotatedTree,_fnIcolExprs,_fnIoriginalTree,_fnIupType) =
                    fn_ _fnOassignmentCastContext _fnOcat _fnOdownEnv _fnOexpectedCast _fnOexpectedType _fnOflags _fnOimCast _fnOodbcFunction
                ( _partitionByIannotatedTree,_partitionByIoriginalTree,_partitionByIupTypes) =
                    partitionBy_ _partitionByOassignmentCastContext _partitionByOcat _partitionByOdownEnv _partitionByOexpectedCast _partitionByOexpectedTypes _partitionByOflags _partitionByOimCast
                ( _orderByIannotatedTree,_orderByIoriginalTree) =
                    orderBy_ _orderByOcat _orderByOdownEnv _orderByOflags _orderByOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Cast :: T_Annotation ->
                         T_ScalarExpr ->
                         T_TypeName ->
                         T_ScalarExpr
  _sem_ScalarExpr_Cast ann_ expr_ tn_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _exprOodbcFunction :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _exprOassignmentCastContext :: Bool
                _exprOcat :: Catalog
                _exprOdownEnv :: Environment
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _tnOcat :: Catalog
                _tnOflags :: TypeCheckFlags
                _tnOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                _tnIannotatedTree :: TypeName
                _tnInamedType :: (Maybe TypeExtra)
                _tnIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 13767 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 13773 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 13779 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 13785 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 13796 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 13802 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 173, column 12)
                _exprOodbcFunction =
                    ({-# LINE 173 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13808 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 273, column 10)
                _tpe =
                    ({-# LINE 273 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     let nullability = fromMaybe False $ teNullable <$> _exprIupType
                         setNullability te = te{teNullable = nullability}
                     in maybe (Left []) (Right . setNullability) _tnInamedType
                     {-# LINE 13816 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 277, column 10)
                _exprOexpectedType =
                    ({-# LINE 277 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 13822 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 278, column 10)
                _exprOexpectedCast =
                    ({-# LINE 278 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 13828 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Cast _annIannotatedTree _exprIannotatedTree _tnIannotatedTree
                     {-# LINE 13834 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Cast _annIoriginalTree _exprIoriginalTree _tnIoriginalTree
                     {-# LINE 13840 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 13846 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 13852 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13858 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13864 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 13870 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13876 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 13882 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13888 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13894 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 13900 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 13906 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 13912 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
                ( _tnIannotatedTree,_tnInamedType,_tnIoriginalTree) =
                    tn_ _tnOcat _tnOflags _tnOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_ImplicitCast :: T_Annotation ->
                                 T_ScalarExpr ->
                                 TypeExtra ->
                                 T_ScalarExpr
  _sem_ScalarExpr_ImplicitCast ann_ expr_ te_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _exprOodbcFunction :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _exprOassignmentCastContext :: Bool
                _exprOcat :: Catalog
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 13976 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 13982 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 13988 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 13994 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 14005 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 14011 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 174, column 20)
                _exprOodbcFunction =
                    ({-# LINE 174 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 14017 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 280, column 9)
                _tpe =
                    ({-# LINE 280 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Right te_
                     {-# LINE 14023 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 281, column 9)
                _exprOexpectedType =
                    ({-# LINE 281 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 14029 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ImplicitCast _annIannotatedTree _exprIannotatedTree te_
                     {-# LINE 14035 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ImplicitCast _annIoriginalTree _exprIoriginalTree te_
                     {-# LINE 14041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 14047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 14053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 14071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOexpectedCast =
                    ({-# LINE 111 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 14089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14095 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14101 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Case :: T_Annotation ->
                         T_CaseScalarExprListScalarExprPairList ->
                         T_MaybeScalarExpr ->
                         T_ScalarExpr
  _sem_ScalarExpr_Case ann_ cases_ els_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _casesOwhenExpectedType :: (Maybe TypeExtra)
                _casesOthenExpectedType :: (Maybe TypeExtra)
                _elsOexpectedType :: (Maybe TypeExtra)
                _elsOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _casesOcat :: Catalog
                _casesOdownEnv :: Environment
                _casesOflags :: TypeCheckFlags
                _casesOimCast :: (Maybe TypeExtra)
                _elsOassignmentCastContext :: Bool
                _elsOcat :: Catalog
                _elsOdownEnv :: Environment
                _elsOflags :: TypeCheckFlags
                _elsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _casesIannotatedTree :: CaseScalarExprListScalarExprPairList
                _casesIoriginalTree :: CaseScalarExprListScalarExprPairList
                _casesIthenTypes :: ([Maybe TypeExtra])
                _casesIupTypes :: ([Maybe TypeExtra])
                _casesIwhenTypes :: ([[Maybe TypeExtra]])
                _elsIannotatedTree :: MaybeScalarExpr
                _elsIoriginalTree :: MaybeScalarExpr
                _elsIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 14172 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 14178 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14184 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 14190 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 14201 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 14207 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 559, column 9)
                _whenTypes =
                    ({-# LINE 559 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _casesIwhenTypes
                     {-# LINE 14213 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 560, column 9)
                _thenTypes =
                    ({-# LINE 560 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _casesIthenTypes ++ maybe [] ((:[]) . Just) _elsIupType
                     {-# LINE 14219 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 562, column 9)
                _tpe =
                    ({-# LINE 562 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     wt <- mapM (maybe (Left []) Right) $ concat _whenTypes
                     bt <- ScalarType <$> _dialectTypeName     "boolean"
                     when (any ((/= bt) . teType) wt)
                         $ Left [WrongTypes bt $ map teType wt]
                     tt <- mapM (maybe (Left []) Right) _thenTypes
                     tse <- resolveResultSetTypeExtra _lhsIcat tt
                     return $ if isNothing _elsIoriginalTree
                              then tse{teNullable=True}
                              else tse
                     {-# LINE 14234 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 574, column 9)
                _casesOwhenExpectedType =
                    ({-# LINE 574 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     ws <- sequence $ concat _whenTypes
                     w <- either (const Nothing) Just $ resolveResultSetTypeExtra _lhsIcat ws
                     bt <- ScalarType <$> either (const Nothing) Just (_dialectTypeName     "boolean")
                     Just $ TypeExtra bt Nothing Nothing $ teNullable w
                     {-# LINE 14244 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 580, column 9)
                _casesOthenExpectedType =
                    ({-# LINE 580 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14250 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 581, column 9)
                _elsOexpectedType =
                    ({-# LINE 581 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14256 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 582, column 9)
                _elsOexpectedCast =
                    ({-# LINE 582 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     True
                     {-# LINE 14262 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Case _annIannotatedTree _casesIannotatedTree _elsIannotatedTree
                     {-# LINE 14268 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Case _annIoriginalTree _casesIoriginalTree _elsIoriginalTree
                     {-# LINE 14274 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 14280 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 14286 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14292 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14298 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14304 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOdownEnv =
                    ({-# LINE 554 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14310 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14316 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14322 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 14328 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14334 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14340 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14346 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14352 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _casesIannotatedTree,_casesIoriginalTree,_casesIthenTypes,_casesIupTypes,_casesIwhenTypes) =
                    cases_ _casesOcat _casesOdownEnv _casesOflags _casesOimCast _casesOthenExpectedType _casesOwhenExpectedType
                ( _elsIannotatedTree,_elsIoriginalTree,_elsIupType) =
                    els_ _elsOassignmentCastContext _elsOcat _elsOdownEnv _elsOexpectedCast _elsOexpectedType _elsOflags _elsOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_CaseSimple :: T_Annotation ->
                               T_ScalarExpr ->
                               T_CaseScalarExprListScalarExprPairList ->
                               T_MaybeScalarExpr ->
                               T_ScalarExpr
  _sem_ScalarExpr_CaseSimple ann_ value_ cases_ els_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _valueOodbcFunction :: Bool
                _casesOwhenExpectedType :: (Maybe TypeExtra)
                _valueOexpectedType :: (Maybe TypeExtra)
                _valueOexpectedCast :: Bool
                _casesOthenExpectedType :: (Maybe TypeExtra)
                _elsOexpectedType :: (Maybe TypeExtra)
                _elsOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _valueOassignmentCastContext :: Bool
                _valueOcat :: Catalog
                _valueOdownEnv :: Environment
                _valueOflags :: TypeCheckFlags
                _valueOimCast :: (Maybe TypeExtra)
                _casesOcat :: Catalog
                _casesOdownEnv :: Environment
                _casesOflags :: TypeCheckFlags
                _casesOimCast :: (Maybe TypeExtra)
                _elsOassignmentCastContext :: Bool
                _elsOcat :: Catalog
                _elsOdownEnv :: Environment
                _elsOflags :: TypeCheckFlags
                _elsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _valueIannotatedTree :: ScalarExpr
                _valueIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _valueIoriginalTree :: ScalarExpr
                _valueIupType :: (Maybe TypeExtra)
                _casesIannotatedTree :: CaseScalarExprListScalarExprPairList
                _casesIoriginalTree :: CaseScalarExprListScalarExprPairList
                _casesIthenTypes :: ([Maybe TypeExtra])
                _casesIupTypes :: ([Maybe TypeExtra])
                _casesIwhenTypes :: ([[Maybe TypeExtra]])
                _elsIannotatedTree :: MaybeScalarExpr
                _elsIoriginalTree :: MaybeScalarExpr
                _elsIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 14438 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 14444 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14450 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 14456 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 14467 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 14473 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 175, column 18)
                _valueOodbcFunction =
                    ({-# LINE 175 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 14479 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 559, column 9)
                _whenTypes =
                    ({-# LINE 559 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _casesIwhenTypes
                     {-# LINE 14485 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 560, column 9)
                _thenTypes =
                    ({-# LINE 560 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _casesIthenTypes ++ maybe [] ((:[]) . Just) _elsIupType
                     {-# LINE 14491 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 584, column 9)
                _whent =
                    ({-# LINE 584 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     wt <- mapM (maybe (Left []) Right) $ concat _whenTypes
                     vt <- maybe (Left []) Right _valueIupType
                     resolveResultSetTypeExtra _lhsIcat (vt : wt)
                     {-# LINE 14500 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 589, column 9)
                _tpe =
                    ({-# LINE 589 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     _ <- _whent
                     tt <- mapM (maybe (Left []) Right) _thenTypes
                     resolveResultSetTypeExtra _lhsIcat tt
                     {-# LINE 14509 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 594, column 9)
                _casesOwhenExpectedType =
                    ({-# LINE 594 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _whent
                     {-# LINE 14515 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 595, column 9)
                _valueOexpectedType =
                    ({-# LINE 595 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _whent
                     {-# LINE 14521 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 596, column 9)
                _valueOexpectedCast =
                    ({-# LINE 596 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 14527 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 597, column 9)
                _casesOthenExpectedType =
                    ({-# LINE 597 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14533 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 598, column 9)
                _elsOexpectedType =
                    ({-# LINE 598 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 599, column 9)
                _elsOexpectedCast =
                    ({-# LINE 599 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     True
                     {-# LINE 14545 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CaseSimple _annIannotatedTree _valueIannotatedTree _casesIannotatedTree _elsIannotatedTree
                     {-# LINE 14551 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CaseSimple _annIoriginalTree _valueIoriginalTree _casesIoriginalTree _elsIoriginalTree
                     {-# LINE 14557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 14563 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 14569 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 14587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14599 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14605 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14611 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14617 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOdownEnv =
                    ({-# LINE 554 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14623 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14629 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14635 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 14641 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14647 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14653 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14659 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14665 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _valueIannotatedTree,_valueIcolExprs,_valueIoriginalTree,_valueIupType) =
                    value_ _valueOassignmentCastContext _valueOcat _valueOdownEnv _valueOexpectedCast _valueOexpectedType _valueOflags _valueOimCast _valueOodbcFunction
                ( _casesIannotatedTree,_casesIoriginalTree,_casesIthenTypes,_casesIupTypes,_casesIwhenTypes) =
                    cases_ _casesOcat _casesOdownEnv _casesOflags _casesOimCast _casesOthenExpectedType _casesOwhenExpectedType
                ( _elsIannotatedTree,_elsIoriginalTree,_elsIupType) =
                    els_ _elsOassignmentCastContext _elsOcat _elsOdownEnv _elsOexpectedCast _elsOexpectedType _elsOflags _elsOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Parens :: T_Annotation ->
                           T_ScalarExpr ->
                           T_ScalarExpr
  _sem_ScalarExpr_Parens ann_ ex_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _exOodbcFunction :: Bool
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _exOassignmentCastContext :: Bool
                _exOcat :: Catalog
                _exOdownEnv :: Environment
                _exOexpectedCast :: Bool
                _exOexpectedType :: (Maybe TypeExtra)
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: ScalarExpr
                _exIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exIoriginalTree :: ScalarExpr
                _exIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 14730 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 14736 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14742 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 14748 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 14759 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 14765 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 182, column 14)
                _exOodbcFunction =
                    ({-# LINE 182 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 14771 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 615, column 5)
                _tpe =
                    ({-# LINE 615 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right _exIupType
                     {-# LINE 14777 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Parens _annIannotatedTree _exIannotatedTree
                     {-# LINE 14783 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Parens _annIoriginalTree _exIoriginalTree
                     {-# LINE 14789 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 14795 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 14801 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14807 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14813 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 14819 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 14825 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 14831 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOexpectedCast =
                    ({-# LINE 111 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 14837 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOexpectedType =
                    ({-# LINE 110 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 14843 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 14849 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 14855 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIcolExprs,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOdownEnv _exOexpectedCast _exOexpectedType _exOflags _exOimCast _exOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_InPredicate :: T_Annotation ->
                                T_ScalarExpr ->
                                Bool ->
                                T_InList ->
                                T_ScalarExpr
  _sem_ScalarExpr_InPredicate ann_ expr_ i_ list_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _exprOodbcFunction :: Bool
                _rt :: (Either [TypeError] TypeExtra)
                _listOexpectedType :: (Maybe TypeExtra)
                _exprOexpectedType :: (Maybe TypeExtra)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _exprOassignmentCastContext :: Bool
                _exprOcat :: Catalog
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _listOcat :: Catalog
                _listOdownEnv :: Environment
                _listOexpectedCast :: Bool
                _listOflags :: TypeCheckFlags
                _listOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                _listIannotatedTree :: InList
                _listIlistType :: (Either [TypeError] TypeExtra)
                _listIoriginalTree :: InList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 14928 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 14934 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 14940 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 14946 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 14957 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 14963 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 181, column 19)
                _exprOodbcFunction =
                    ({-# LINE 181 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 14969 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 669, column 9)
                _rt =
                    ({-# LINE 669 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     lt <- _listIlistType
                     expt <- maybe (Left []) Right _exprIupType
                     resolveResultSetTypeExtra _lhsIcat [expt, lt]
                     {-# LINE 14978 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 673, column 9)
                _tpe =
                    ({-# LINE 673 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     r <- _rt
                     bt <- ScalarType <$> _dialectTypeName     "boolean"
                     return $ TypeExtra bt Nothing Nothing $ teNullable r
                     {-# LINE 14987 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 677, column 9)
                _listOexpectedType =
                    ({-# LINE 677 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _rt
                     {-# LINE 14993 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 678, column 9)
                _exprOexpectedType =
                    ({-# LINE 678 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _rt
                     {-# LINE 14999 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     InPredicate _annIannotatedTree _exprIannotatedTree i_ _listIannotatedTree
                     {-# LINE 15005 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     InPredicate _annIoriginalTree _exprIoriginalTree i_ _listIoriginalTree
                     {-# LINE 15011 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 15017 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 15023 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15029 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15035 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 15041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 15053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOexpectedCast =
                    ({-# LINE 111 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 15059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _listOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _listOdownEnv =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 15083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _listOexpectedCast =
                    ({-# LINE 662 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 15089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _listOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15095 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _listOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15101 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
                ( _listIannotatedTree,_listIlistType,_listIoriginalTree) =
                    list_ _listOcat _listOdownEnv _listOexpectedCast _listOexpectedType _listOflags _listOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_Exists :: T_Annotation ->
                           T_QueryExpr ->
                           T_ScalarExpr
  _sem_ScalarExpr_Exists ann_ sel_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _selOouterDownEnv :: (Maybe Environment)
                _selOexpectedType :: (Maybe [TypeExtra])
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _selOassignmentCastContext :: Bool
                _selOcat :: Catalog
                _selOflags :: TypeCheckFlags
                _selOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selIannotatedTree :: QueryExpr
                _selIoriginalTree :: QueryExpr
                _selIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 15161 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 15167 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 15173 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 15179 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 15190 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 15196 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 628, column 9)
                _tpe =
                    ({-# LINE 628 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     (mkTypeExtraNN . ScalarType) <$> (_dialectTypeName     "boolean")
                     {-# LINE 15202 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 650, column 9)
                _selOouterDownEnv =
                    ({-# LINE 650 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Just _lhsIdownEnv
                     {-# LINE 15208 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 652, column 9)
                _selOexpectedType =
                    ({-# LINE 652 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     liftM (map snd) _selIupType
                     {-# LINE 15214 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Exists _annIannotatedTree _selIannotatedTree
                     {-# LINE 15220 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Exists _annIoriginalTree _selIoriginalTree
                     {-# LINE 15226 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 15232 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 15238 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15244 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15250 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 15256 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15262 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15268 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15274 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selIannotatedTree,_selIoriginalTree,_selIupType) =
                    sel_ _selOassignmentCastContext _selOcat _selOexpectedType _selOflags _selOimCast _selOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_ScalarSubQuery :: T_Annotation ->
                                   T_QueryExpr ->
                                   T_ScalarExpr
  _sem_ScalarExpr_ScalarSubQuery ann_ sel_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _selOouterDownEnv :: (Maybe Environment)
                _selOexpectedType :: (Maybe [TypeExtra])
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _selOassignmentCastContext :: Bool
                _selOcat :: Catalog
                _selOflags :: TypeCheckFlags
                _selOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selIannotatedTree :: QueryExpr
                _selIoriginalTree :: QueryExpr
                _selIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 15332 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 15338 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 15344 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 15350 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 15361 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 15367 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 638, column 9)
                _tpe =
                    ({-# LINE 638 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     do
                     selType <- maybe (Left []) Right _selIupType
                     case length selType of
                       0 -> Left [InternalError "no columns in scalar subquery?"]
                       1 -> Right $ snd $ head selType
                       _ -> Right $ mkTypeExtra $ AnonymousCompositeType
                               $ map (teType . snd) selType
                     {-# LINE 15379 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 648, column 9)
                _selOouterDownEnv =
                    ({-# LINE 648 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Just _lhsIdownEnv
                     {-# LINE 15385 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 652, column 9)
                _selOexpectedType =
                    ({-# LINE 652 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     liftM (map snd) _selIupType
                     {-# LINE 15391 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ScalarSubQuery _annIannotatedTree _selIannotatedTree
                     {-# LINE 15397 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ScalarSubQuery _annIoriginalTree _selIoriginalTree
                     {-# LINE 15403 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 15409 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 15415 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15421 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15427 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 15433 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15439 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15445 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15451 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selIannotatedTree,_selIoriginalTree,_selIupType) =
                    sel_ _selOassignmentCastContext _selOcat _selOexpectedType _selOflags _selOimCast _selOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_LiftApp :: T_Annotation ->
                            T_Name ->
                            LiftFlavour ->
                            T_ScalarExprList ->
                            T_ScalarExpr
  _sem_ScalarExpr_LiftApp ann_ oper_ flav_ args_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _argsOexpectedCast :: Bool
                _argsOexpectedTypes :: ([TypeExtra])
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _operOcat :: Catalog
                _operOflags :: TypeCheckFlags
                _operOimCast :: (Maybe TypeExtra)
                _operOtpe :: (Either [TypeError] TypeExtra)
                _argsOassignmentCastContext :: Bool
                _argsOcat :: Catalog
                _argsOdownEnv :: Environment
                _argsOflags :: TypeCheckFlags
                _argsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _operIannotatedTree :: Name
                _operIoriginalTree :: Name
                _argsIannotatedTree :: ScalarExprList
                _argsIoriginalTree :: ScalarExprList
                _argsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 15518 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 15524 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 15530 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 15536 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 15547 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 15553 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 455, column 9)
                _argsOexpectedCast =
                    ({-# LINE 455 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 15559 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 735, column 9)
                _tpe =
                    ({-# LINE 735 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 15565 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 772, column 13)
                _argsOexpectedTypes =
                    ({-# LINE 772 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 15571 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     LiftApp _annIannotatedTree _operIannotatedTree flav_ _argsIannotatedTree
                     {-# LINE 15577 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     LiftApp _annIoriginalTree _operIoriginalTree flav_ _argsIoriginalTree
                     {-# LINE 15583 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 15589 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 15595 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15601 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15607 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15613 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15619 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15625 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (from local)
                _operOtpe =
                    ({-# LINE 46 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     _tpe
                     {-# LINE 15631 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 15637 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15643 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 15649 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15655 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15661 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _operIannotatedTree,_operIoriginalTree) =
                    oper_ _operOcat _operOflags _operOimCast _operOtpe
                ( _argsIannotatedTree,_argsIoriginalTree,_argsIupTypes) =
                    args_ _argsOassignmentCastContext _argsOcat _argsOdownEnv _argsOexpectedCast _argsOexpectedTypes _argsOflags _argsOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_OdbcLiteral :: T_Annotation ->
                                OdbcLiteralType ->
                                String ->
                                T_ScalarExpr
  _sem_ScalarExpr_OdbcLiteral ann_ olt_ val_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 15713 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 15719 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 15725 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 15731 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 15742 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 15748 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 307, column 10)
                _tpe =
                    ({-# LINE 307 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case olt_ of
                       OLDate -> (mkTypeExtra . ScalarType) <$> _dialectTypeName     "date"
                       OLTime -> (mkTypeExtra . ScalarType) <$> _dialectTypeName     "time"
                       OLTimestamp -> (mkTypeExtra . ScalarType) <$> _dialectTypeName     "timestamp"
                     {-# LINE 15757 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     OdbcLiteral _annIannotatedTree olt_ val_
                     {-# LINE 15763 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     OdbcLiteral _annIoriginalTree olt_ val_
                     {-# LINE 15769 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 15775 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 15781 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15787 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15793 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_OdbcFunc :: T_Annotation ->
                             T_ScalarExpr ->
                             T_ScalarExpr
  _sem_ScalarExpr_OdbcFunc ann_ ex_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe TypeExtra)
                _annOimCast :: (Maybe TypeExtra)
                _dialectTypeName :: (Text -> Either [TypeError] Text)
                _exOodbcFunction :: Bool
                _exOcat :: Catalog
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _exOassignmentCastContext :: Bool
                _exOdownEnv :: Environment
                _exOexpectedCast :: Bool
                _exOexpectedType :: (Maybe TypeExtra)
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: ScalarExpr
                _exIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exIoriginalTree :: ScalarExpr
                _exIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 42, column 7)
                _lhsOcolExprs =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     let a = _annIoriginalTree
                         doStar is =
                           map (\((q,n),t) ->
                             let a' = a {anType = Just t}
                             in (Nmc $ T.unpack n, Just t,
                                 Identifier a' $ Name a'
                                               $ [Nmc q' | let q' = T.unpack q, not $ null q']
                                                 ++ [Nmc $ T.unpack n])
                             ) is
                     in case _originalTree of
                         Star _ | Right is <- E.envExpandStar Nothing _lhsIdownEnv ->
                            doStar is
                         QStar _ q | Right is <- E.envExpandStar (Just q) _lhsIdownEnv ->
                            doStar is
                         _ ->
                                [(columnName _originalTree,_upType,_annotatedTree)]
                     {-# LINE 15852 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 35, column 9)
                _annOtpe =
                    ({-# LINE 35 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _tpe
                     {-# LINE 15858 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 36, column 9)
                _upType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 15864 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 37, column 9)
                _lhsOupType =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _upType
                     {-# LINE 15870 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 38, column 9)
                _annOimCast =
                    ({-# LINE 38 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _upType     of
                        Nothing -> _lhsIexpectedType
                        Just upType -> do
                            expType <- _lhsIexpectedType
                            guard $ needsImplicitCast _lhsIexpectedCast upType expType
                            return $ implicitCastType _lhsIexpectedCast upType expType
                     {-# LINE 15881 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 45, column 9)
                _dialectTypeName =
                    ({-# LINE 45 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     maybe (Left []) Right . ansiTypeNameToDialect (tcfDialect _lhsIflags)
                     {-# LINE 15887 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 183, column 16)
                _exOodbcFunction =
                    ({-# LINE 183 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     True
                     {-# LINE 15893 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 313, column 10)
                _exOcat =
                    ({-# LINE 313 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     id _lhsIcat
                     {-# LINE 15899 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 314, column 10)
                _tpe =
                    ({-# LINE 314 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _exIoriginalTree of
                       Extract {} -> maybe (Left []) Right _exIupType
                       App {} -> maybe (Left []) Right _exIupType
                       _ -> Left [OdbcFuncBadContent]
                     {-# LINE 15908 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     OdbcFunc _annIannotatedTree _exIannotatedTree
                     {-# LINE 15914 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     OdbcFunc _annIoriginalTree _exIoriginalTree
                     {-# LINE 15920 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 15926 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 15932 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 15938 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15944 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 15950 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 15956 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOexpectedCast =
                    ({-# LINE 111 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 15962 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOexpectedType =
                    ({-# LINE 110 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 15968 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 15974 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 15980 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIcolExprs,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOdownEnv _exOexpectedCast _exOexpectedType _exOflags _exOimCast _exOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExpr_AntiScalarExpr :: String ->
                                   T_ScalarExpr
  _sem_ScalarExpr_AntiScalarExpr string_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast
         _lhsIodbcFunction ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _lhsOupType :: (Maybe TypeExtra)
                _lhsOannotatedTree :: ScalarExpr
                _lhsOoriginalTree :: ScalarExpr
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 238, column 21)
                _lhsOcolExprs =
                    ({-# LINE 238 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     [(Nmc "?anti?",Nothing,_originalTree)]
                     {-# LINE 16006 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 102, column 9)
                _lhsOupType =
                    ({-# LINE 102 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 16012 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 735, column 9)
                _tpe =
                    ({-# LINE 735 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Left []
                     {-# LINE 16018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AntiScalarExpr string_
                     {-# LINE 16024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AntiScalarExpr string_
                     {-# LINE 16030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16036 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16042 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupType)))
  -- ScalarExprDirectionPair -------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprDirectionPair 
           originalTree         : ScalarExprDirectionPair 
     alternatives:
        alternative Tuple:
           child x1             : ScalarExpr 
           child x2             : {Direction}
           child x3             : {NullsOrder}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprDirectionPair = ( ScalarExpr,(Direction),(NullsOrder))
  -- cata
  _sem_ScalarExprDirectionPair :: ScalarExprDirectionPair ->
                                 T_ScalarExprDirectionPair
  _sem_ScalarExprDirectionPair ( x1,x2,x3) =
      (_sem_ScalarExprDirectionPair_Tuple (_sem_ScalarExpr x1) x2 x3)
  -- semantic domain
  type T_ScalarExprDirectionPair = Catalog ->
                                   Environment ->
                                   TypeCheckFlags ->
                                   (Maybe TypeExtra) ->
                                   ( ScalarExprDirectionPair,ScalarExprDirectionPair)
  data Inh_ScalarExprDirectionPair = Inh_ScalarExprDirectionPair {_cat_Inh_ScalarExprDirectionPair :: Catalog,_downEnv_Inh_ScalarExprDirectionPair :: Environment,_flags_Inh_ScalarExprDirectionPair :: TypeCheckFlags,_imCast_Inh_ScalarExprDirectionPair :: (Maybe TypeExtra)}
  data Syn_ScalarExprDirectionPair = Syn_ScalarExprDirectionPair {_annotatedTree_Syn_ScalarExprDirectionPair :: ScalarExprDirectionPair,_originalTree_Syn_ScalarExprDirectionPair :: ScalarExprDirectionPair}
  _wrap_ScalarExprDirectionPair :: T_ScalarExprDirectionPair ->
                                  Inh_ScalarExprDirectionPair ->
                                  Syn_ScalarExprDirectionPair
  _wrap_ScalarExprDirectionPair sem (Inh_ScalarExprDirectionPair _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprDirectionPair _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprDirectionPair_Tuple :: T_ScalarExpr ->
                                       Direction ->
                                       NullsOrder ->
                                       T_ScalarExprDirectionPair
  _sem_ScalarExprDirectionPair_Tuple x1_ x2_ x3_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _x1OexpectedCast :: Bool
                _x1OodbcFunction :: Bool
                _x1OexpectedType :: (Maybe TypeExtra)
                _x1OassignmentCastContext :: Bool
                _lhsOannotatedTree :: ScalarExprDirectionPair
                _lhsOoriginalTree :: ScalarExprDirectionPair
                _x1Ocat :: Catalog
                _x1OdownEnv :: Environment
                _x1Oflags :: TypeCheckFlags
                _x1OimCast :: (Maybe TypeExtra)
                _x1IannotatedTree :: ScalarExpr
                _x1IcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _x1IoriginalTree :: ScalarExpr
                _x1IupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 90, column 37)
                _x1OexpectedCast =
                    ({-# LINE 90 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 16112 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 153, column 13)
                _x1OodbcFunction =
                    ({-# LINE 153 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 16118 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 758, column 11)
                _x1OexpectedType =
                    ({-# LINE 758 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 16124 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 818, column 37)
                _x1OassignmentCastContext =
                    ({-# LINE 818 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 16130 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IannotatedTree,x2_,x3_)
                     {-# LINE 16136 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IoriginalTree,x2_,x3_)
                     {-# LINE 16142 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16148 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16154 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16160 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 16166 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16172 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16178 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _x1IannotatedTree,_x1IcolExprs,_x1IoriginalTree,_x1IupType) =
                    x1_ _x1OassignmentCastContext _x1Ocat _x1OdownEnv _x1OexpectedCast _x1OexpectedType _x1Oflags _x1OimCast _x1OodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprDirectionPairList ---------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprDirectionPairList 
           originalTree         : ScalarExprDirectionPairList 
     alternatives:
        alternative Cons:
           child hd             : ScalarExprDirectionPair 
           child tl             : ScalarExprDirectionPairList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprDirectionPairList = [ScalarExprDirectionPair]
  -- cata
  _sem_ScalarExprDirectionPairList :: ScalarExprDirectionPairList ->
                                     T_ScalarExprDirectionPairList
  _sem_ScalarExprDirectionPairList list =
      (Prelude.foldr _sem_ScalarExprDirectionPairList_Cons _sem_ScalarExprDirectionPairList_Nil (Prelude.map _sem_ScalarExprDirectionPair list))
  -- semantic domain
  type T_ScalarExprDirectionPairList = Catalog ->
                                       Environment ->
                                       TypeCheckFlags ->
                                       (Maybe TypeExtra) ->
                                       ( ScalarExprDirectionPairList,ScalarExprDirectionPairList)
  data Inh_ScalarExprDirectionPairList = Inh_ScalarExprDirectionPairList {_cat_Inh_ScalarExprDirectionPairList :: Catalog,_downEnv_Inh_ScalarExprDirectionPairList :: Environment,_flags_Inh_ScalarExprDirectionPairList :: TypeCheckFlags,_imCast_Inh_ScalarExprDirectionPairList :: (Maybe TypeExtra)}
  data Syn_ScalarExprDirectionPairList = Syn_ScalarExprDirectionPairList {_annotatedTree_Syn_ScalarExprDirectionPairList :: ScalarExprDirectionPairList,_originalTree_Syn_ScalarExprDirectionPairList :: ScalarExprDirectionPairList}
  _wrap_ScalarExprDirectionPairList :: T_ScalarExprDirectionPairList ->
                                      Inh_ScalarExprDirectionPairList ->
                                      Syn_ScalarExprDirectionPairList
  _wrap_ScalarExprDirectionPairList sem (Inh_ScalarExprDirectionPairList _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprDirectionPairList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprDirectionPairList_Cons :: T_ScalarExprDirectionPair ->
                                          T_ScalarExprDirectionPairList ->
                                          T_ScalarExprDirectionPairList
  _sem_ScalarExprDirectionPairList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ScalarExprDirectionPairList
                _lhsOoriginalTree :: ScalarExprDirectionPairList
                _hdOcat :: Catalog
                _hdOdownEnv :: Environment
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOdownEnv :: Environment
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ScalarExprDirectionPair
                _hdIoriginalTree :: ScalarExprDirectionPair
                _tlIannotatedTree :: ScalarExprDirectionPairList
                _tlIoriginalTree :: ScalarExprDirectionPairList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 16252 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 16258 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16264 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16270 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16276 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOdownEnv =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 16282 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16288 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16294 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16300 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOdownEnv =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 16306 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16312 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16318 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOdownEnv _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOdownEnv _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_ScalarExprDirectionPairList_Nil :: T_ScalarExprDirectionPairList
  _sem_ScalarExprDirectionPairList_Nil =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ScalarExprDirectionPairList
                _lhsOoriginalTree :: ScalarExprDirectionPairList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 16337 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 16343 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16349 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16355 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprList ----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedTypes        : [TypeExtra]
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprList 
           originalTree         : ScalarExprList 
           upTypes              : [Maybe TypeExtra]
     alternatives:
        alternative Cons:
           child hd             : ScalarExpr 
           child tl             : ScalarExprList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprList = [ScalarExpr]
  -- cata
  _sem_ScalarExprList :: ScalarExprList ->
                        T_ScalarExprList
  _sem_ScalarExprList list =
      (Prelude.foldr _sem_ScalarExprList_Cons _sem_ScalarExprList_Nil (Prelude.map _sem_ScalarExpr list))
  -- semantic domain
  type T_ScalarExprList = Bool ->
                          Catalog ->
                          Environment ->
                          Bool ->
                          ([TypeExtra]) ->
                          TypeCheckFlags ->
                          (Maybe TypeExtra) ->
                          ( ScalarExprList,ScalarExprList,([Maybe TypeExtra]))
  data Inh_ScalarExprList = Inh_ScalarExprList {_assignmentCastContext_Inh_ScalarExprList :: Bool,_cat_Inh_ScalarExprList :: Catalog,_downEnv_Inh_ScalarExprList :: Environment,_expectedCast_Inh_ScalarExprList :: Bool,_expectedTypes_Inh_ScalarExprList :: ([TypeExtra]),_flags_Inh_ScalarExprList :: TypeCheckFlags,_imCast_Inh_ScalarExprList :: (Maybe TypeExtra)}
  data Syn_ScalarExprList = Syn_ScalarExprList {_annotatedTree_Syn_ScalarExprList :: ScalarExprList,_originalTree_Syn_ScalarExprList :: ScalarExprList,_upTypes_Syn_ScalarExprList :: ([Maybe TypeExtra])}
  _wrap_ScalarExprList :: T_ScalarExprList ->
                         Inh_ScalarExprList ->
                         Syn_ScalarExprList
  _wrap_ScalarExprList sem (Inh_ScalarExprList _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedTypes _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupTypes) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedTypes _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprList _lhsOannotatedTree _lhsOoriginalTree _lhsOupTypes))
  _sem_ScalarExprList_Cons :: T_ScalarExpr ->
                             T_ScalarExprList ->
                             T_ScalarExprList
  _sem_ScalarExprList_Cons hd_ tl_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedTypes
         _lhsIflags
         _lhsIimCast ->
           (let _hdOodbcFunction :: Bool
                _lhsOupTypes :: ([Maybe TypeExtra])
                _hdOexpectedType :: (Maybe TypeExtra)
                _tlOexpectedTypes :: ([TypeExtra])
                _hdOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExprList
                _lhsOoriginalTree :: ScalarExprList
                _hdOassignmentCastContext :: Bool
                _hdOcat :: Catalog
                _hdOdownEnv :: Environment
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOassignmentCastContext :: Bool
                _tlOcat :: Catalog
                _tlOdownEnv :: Environment
                _tlOexpectedCast :: Bool
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ScalarExpr
                _hdIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _hdIoriginalTree :: ScalarExpr
                _hdIupType :: (Maybe TypeExtra)
                _tlIannotatedTree :: ScalarExprList
                _tlIoriginalTree :: ScalarExprList
                _tlIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 156, column 12)
                _hdOodbcFunction =
                    ({-# LINE 156 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 16448 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 197, column 9)
                _lhsOupTypes =
                    ({-# LINE 197 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _hdIupType : _tlIupTypes
                     {-# LINE 16454 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 198, column 9)
                (_hdOexpectedType,_tlOexpectedTypes) =
                    ({-# LINE 198 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     case _lhsIexpectedTypes of
                         (x:xs) -> (Just x,xs)
                         [] -> (Nothing,[])
                     {-# LINE 16462 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 202, column 9)
                _hdOexpectedCast =
                    ({-# LINE 202 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 16468 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 16474 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 16480 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16486 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16492 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 16498 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16504 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 16510 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16516 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16522 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 16528 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16534 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOdownEnv =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 16540 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOexpectedCast =
                    ({-# LINE 193 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 16546 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16552 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16558 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIcolExprs,_hdIoriginalTree,_hdIupType) =
                    hd_ _hdOassignmentCastContext _hdOcat _hdOdownEnv _hdOexpectedCast _hdOexpectedType _hdOflags _hdOimCast _hdOodbcFunction
                ( _tlIannotatedTree,_tlIoriginalTree,_tlIupTypes) =
                    tl_ _tlOassignmentCastContext _tlOcat _tlOdownEnv _tlOexpectedCast _tlOexpectedTypes _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupTypes)))
  _sem_ScalarExprList_Nil :: T_ScalarExprList
  _sem_ScalarExprList_Nil =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedTypes
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupTypes :: ([Maybe TypeExtra])
                _lhsOannotatedTree :: ScalarExprList
                _lhsOoriginalTree :: ScalarExprList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 203, column 11)
                _lhsOupTypes =
                    ({-# LINE 203 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     []
                     {-# LINE 16581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 16587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 16593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16599 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16605 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupTypes)))
  -- ScalarExprListList ------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe [TypeExtra]
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprListList 
           originalTree         : ScalarExprListList 
           upType               : Either [TypeError] [(Text,TypeExtra)]
     alternatives:
        alternative Cons:
           child hd             : ScalarExprTransposedList 
           child tl             : ScalarExprListList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprListList = [ScalarExprTransposedList]
  -- cata
  _sem_ScalarExprListList :: ScalarExprListList ->
                            T_ScalarExprListList
  _sem_ScalarExprListList list =
      (Prelude.foldr _sem_ScalarExprListList_Cons _sem_ScalarExprListList_Nil (Prelude.map _sem_ScalarExprTransposedList list))
  -- semantic domain
  type T_ScalarExprListList = Bool ->
                              Catalog ->
                              Environment ->
                              Bool ->
                              (Maybe [TypeExtra]) ->
                              TypeCheckFlags ->
                              (Maybe TypeExtra) ->
                              ( ScalarExprListList,ScalarExprListList,(Either [TypeError] [(Text,TypeExtra)]))
  data Inh_ScalarExprListList = Inh_ScalarExprListList {_assignmentCastContext_Inh_ScalarExprListList :: Bool,_cat_Inh_ScalarExprListList :: Catalog,_downEnv_Inh_ScalarExprListList :: Environment,_expectedCast_Inh_ScalarExprListList :: Bool,_expectedType_Inh_ScalarExprListList :: (Maybe [TypeExtra]),_flags_Inh_ScalarExprListList :: TypeCheckFlags,_imCast_Inh_ScalarExprListList :: (Maybe TypeExtra)}
  data Syn_ScalarExprListList = Syn_ScalarExprListList {_annotatedTree_Syn_ScalarExprListList :: ScalarExprListList,_originalTree_Syn_ScalarExprListList :: ScalarExprListList,_upType_Syn_ScalarExprListList :: (Either [TypeError] [(Text,TypeExtra)])}
  _wrap_ScalarExprListList :: T_ScalarExprListList ->
                             Inh_ScalarExprListList ->
                             Syn_ScalarExprListList
  _wrap_ScalarExprListList sem (Inh_ScalarExprListList _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprListList _lhsOannotatedTree _lhsOoriginalTree _lhsOupType))
  _sem_ScalarExprListList_Cons :: T_ScalarExprTransposedList ->
                                 T_ScalarExprListList ->
                                 T_ScalarExprListList
  _sem_ScalarExprListList_Cons hd_ tl_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupType :: (Either [TypeError] [(Text,TypeExtra)])
                _hdOexpectedCast :: Bool
                _tlOexpectedCast :: Bool
                _lhsOannotatedTree :: ScalarExprListList
                _lhsOoriginalTree :: ScalarExprListList
                _hdOcat :: Catalog
                _hdOexpectedType :: (Maybe [TypeExtra])
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOassignmentCastContext :: Bool
                _tlOcat :: Catalog
                _tlOdownEnv :: Environment
                _tlOexpectedType :: (Maybe [TypeExtra])
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ScalarExprTransposedList
                _hdIoriginalTree :: ScalarExprTransposedList
                _hdIupType :: (Maybe [TypeExtra])
                _tlIannotatedTree :: ScalarExprListList
                _tlIoriginalTree :: ScalarExprListList
                _tlIupType :: (Either [TypeError] [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 191, column 9)
                _lhsOupType =
                    ({-# LINE 191 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     do
                     a <- maybe (Left [InternalError "type error in VALUES clause"]) Right _hdIupType
                     b <- _tlIupType
                     unless (not $ null a) $ Left [InternalError "empty row in VALUES clause"]
                     let a' = map ("",) a
                         itError = Left [IncompatibleUnionTypes (CompositeType a') (CompositeType b)]
                     unless (null b || length a == length b) itError
                     if null b
                       then return $ zip [T.pack ("values%" ++ show k) | k <- [(0::Int)..]] a
                       else
                         do
                         let uts = zipWithM (\te1 (_,te2) -> resolveResultSetTypeExtra _lhsIcat [te1,te2])
                                       a b
                         case uts of
                           Left{} -> itError
                           Right uts' -> return $ zipWith (\(n,_) te -> (n,te)) b uts'
                     {-# LINE 16709 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 209, column 9)
                _hdOexpectedCast =
                    ({-# LINE 209 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 16715 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 210, column 9)
                _tlOexpectedCast =
                    ({-# LINE 210 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 16721 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 16727 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 16733 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16739 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16745 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16751 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOexpectedType =
                    ({-# LINE 169 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 16757 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16763 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16769 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 16775 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16781 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOdownEnv =
                    ({-# LINE 183 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 16787 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOexpectedType =
                    ({-# LINE 186 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 16793 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16799 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16805 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree,_hdIupType) =
                    hd_ _hdOcat _hdOexpectedCast _hdOexpectedType _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree,_tlIupType) =
                    tl_ _tlOassignmentCastContext _tlOcat _tlOdownEnv _tlOexpectedCast _tlOexpectedType _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExprListList_Nil :: T_ScalarExprListList
  _sem_ScalarExprListList_Nil =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupType :: (Either [TypeError] [(Text,TypeExtra)])
                _lhsOannotatedTree :: ScalarExprListList
                _lhsOoriginalTree :: ScalarExprListList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 211, column 11)
                _lhsOupType =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Right []
                     {-# LINE 16828 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 16834 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 16840 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16846 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16852 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  -- ScalarExprListStatementListTriple ---------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprListStatementListTriple 
           originalTree         : ScalarExprListStatementListTriple 
     alternatives:
        alternative Tuple:
           child x1             : ScalarExprList 
           child x2             : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprListStatementListTriple = ( ScalarExprList,StatementList)
  -- cata
  _sem_ScalarExprListStatementListTriple :: ScalarExprListStatementListTriple ->
                                           T_ScalarExprListStatementListTriple
  _sem_ScalarExprListStatementListTriple ( x1,x2) =
      (_sem_ScalarExprListStatementListTriple_Tuple (_sem_ScalarExprList x1) (_sem_StatementList x2))
  -- semantic domain
  type T_ScalarExprListStatementListTriple = Catalog ->
                                             TypeCheckFlags ->
                                             (Maybe TypeExtra) ->
                                             ( ScalarExprListStatementListTriple,ScalarExprListStatementListTriple)
  data Inh_ScalarExprListStatementListTriple = Inh_ScalarExprListStatementListTriple {_cat_Inh_ScalarExprListStatementListTriple :: Catalog,_flags_Inh_ScalarExprListStatementListTriple :: TypeCheckFlags,_imCast_Inh_ScalarExprListStatementListTriple :: (Maybe TypeExtra)}
  data Syn_ScalarExprListStatementListTriple = Syn_ScalarExprListStatementListTriple {_annotatedTree_Syn_ScalarExprListStatementListTriple :: ScalarExprListStatementListTriple,_originalTree_Syn_ScalarExprListStatementListTriple :: ScalarExprListStatementListTriple}
  _wrap_ScalarExprListStatementListTriple :: T_ScalarExprListStatementListTriple ->
                                            Inh_ScalarExprListStatementListTriple ->
                                            Syn_ScalarExprListStatementListTriple
  _wrap_ScalarExprListStatementListTriple sem (Inh_ScalarExprListStatementListTriple _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprListStatementListTriple _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprListStatementListTriple_Tuple :: T_ScalarExprList ->
                                                 T_StatementList ->
                                                 T_ScalarExprListStatementListTriple
  _sem_ScalarExprListStatementListTriple_Tuple x1_ x2_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _x1OdownEnv :: Environment
                _x1OexpectedCast :: Bool
                _x1OexpectedTypes :: ([TypeExtra])
                _x1OassignmentCastContext :: Bool
                _lhsOannotatedTree :: ScalarExprListStatementListTriple
                _lhsOoriginalTree :: ScalarExprListStatementListTriple
                _x1Ocat :: Catalog
                _x1Oflags :: TypeCheckFlags
                _x1OimCast :: (Maybe TypeExtra)
                _x2Ocat :: Catalog
                _x2Oflags :: TypeCheckFlags
                _x2OimCast :: (Maybe TypeExtra)
                _x1IannotatedTree :: ScalarExprList
                _x1IoriginalTree :: ScalarExprList
                _x1IupTypes :: ([Maybe TypeExtra])
                _x2IannotatedTree :: StatementList
                _x2IoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 91, column 47)
                _x1OdownEnv =
                    ({-# LINE 91 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 16920 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 92, column 47)
                _x1OexpectedCast =
                    ({-# LINE 92 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 16926 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 93, column 47)
                _x1OexpectedTypes =
                    ({-# LINE 93 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     []
                     {-# LINE 16932 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 819, column 47)
                _x1OassignmentCastContext =
                    ({-# LINE 819 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 16938 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IannotatedTree,_x2IannotatedTree)
                     {-# LINE 16944 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IoriginalTree,_x2IoriginalTree)
                     {-# LINE 16950 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 16956 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 16962 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16968 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16974 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16980 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 16986 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 16992 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 16998 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _x1IannotatedTree,_x1IoriginalTree,_x1IupTypes) =
                    x1_ _x1OassignmentCastContext _x1Ocat _x1OdownEnv _x1OexpectedCast _x1OexpectedTypes _x1Oflags _x1OimCast
                ( _x2IannotatedTree,_x2IoriginalTree) =
                    x2_ _x2Ocat _x2Oflags _x2OimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprListStatementListTripleList -----------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprListStatementListTripleList 
           originalTree         : ScalarExprListStatementListTripleList 
     alternatives:
        alternative Cons:
           child hd             : ScalarExprListStatementListTriple 
           child tl             : ScalarExprListStatementListTripleList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprListStatementListTripleList = [ScalarExprListStatementListTriple]
  -- cata
  _sem_ScalarExprListStatementListTripleList :: ScalarExprListStatementListTripleList ->
                                               T_ScalarExprListStatementListTripleList
  _sem_ScalarExprListStatementListTripleList list =
      (Prelude.foldr _sem_ScalarExprListStatementListTripleList_Cons _sem_ScalarExprListStatementListTripleList_Nil (Prelude.map _sem_ScalarExprListStatementListTriple list))
  -- semantic domain
  type T_ScalarExprListStatementListTripleList = Catalog ->
                                                 TypeCheckFlags ->
                                                 (Maybe TypeExtra) ->
                                                 ( ScalarExprListStatementListTripleList,ScalarExprListStatementListTripleList)
  data Inh_ScalarExprListStatementListTripleList = Inh_ScalarExprListStatementListTripleList {_cat_Inh_ScalarExprListStatementListTripleList :: Catalog,_flags_Inh_ScalarExprListStatementListTripleList :: TypeCheckFlags,_imCast_Inh_ScalarExprListStatementListTripleList :: (Maybe TypeExtra)}
  data Syn_ScalarExprListStatementListTripleList = Syn_ScalarExprListStatementListTripleList {_annotatedTree_Syn_ScalarExprListStatementListTripleList :: ScalarExprListStatementListTripleList,_originalTree_Syn_ScalarExprListStatementListTripleList :: ScalarExprListStatementListTripleList}
  _wrap_ScalarExprListStatementListTripleList :: T_ScalarExprListStatementListTripleList ->
                                                Inh_ScalarExprListStatementListTripleList ->
                                                Syn_ScalarExprListStatementListTripleList
  _wrap_ScalarExprListStatementListTripleList sem (Inh_ScalarExprListStatementListTripleList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprListStatementListTripleList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprListStatementListTripleList_Cons :: T_ScalarExprListStatementListTriple ->
                                                    T_ScalarExprListStatementListTripleList ->
                                                    T_ScalarExprListStatementListTripleList
  _sem_ScalarExprListStatementListTripleList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ScalarExprListStatementListTripleList
                _lhsOoriginalTree :: ScalarExprListStatementListTripleList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ScalarExprListStatementListTriple
                _hdIoriginalTree :: ScalarExprListStatementListTriple
                _tlIannotatedTree :: ScalarExprListStatementListTripleList
                _tlIoriginalTree :: ScalarExprListStatementListTripleList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 17069 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 17075 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17081 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17087 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17093 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_ScalarExprListStatementListTripleList_Nil :: T_ScalarExprListStatementListTripleList
  _sem_ScalarExprListStatementListTripleList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ScalarExprListStatementListTripleList
                _lhsOoriginalTree :: ScalarExprListStatementListTripleList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 17141 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 17147 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17153 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17159 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprRoot ----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           downEnv              : Environment
           flags                : TypeCheckFlags
        synthesized attributes:
           annotatedTree        : ScalarExprRoot 
           originalTree         : ScalarExprRoot 
     alternatives:
        alternative ScalarExprRoot:
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data ScalarExprRoot = ScalarExprRoot (ScalarExpr)
                      deriving ( Show)
  -- cata
  _sem_ScalarExprRoot :: ScalarExprRoot ->
                        T_ScalarExprRoot
  _sem_ScalarExprRoot (ScalarExprRoot _expr) =
      (_sem_ScalarExprRoot_ScalarExprRoot (_sem_ScalarExpr _expr))
  -- semantic domain
  type T_ScalarExprRoot = Catalog ->
                          Environment ->
                          TypeCheckFlags ->
                          ( ScalarExprRoot,ScalarExprRoot)
  data Inh_ScalarExprRoot = Inh_ScalarExprRoot {_cat_Inh_ScalarExprRoot :: Catalog,_downEnv_Inh_ScalarExprRoot :: Environment,_flags_Inh_ScalarExprRoot :: TypeCheckFlags}
  data Syn_ScalarExprRoot = Syn_ScalarExprRoot {_annotatedTree_Syn_ScalarExprRoot :: ScalarExprRoot,_originalTree_Syn_ScalarExprRoot :: ScalarExprRoot}
  _wrap_ScalarExprRoot :: T_ScalarExprRoot ->
                         Inh_ScalarExprRoot ->
                         Syn_ScalarExprRoot
  _wrap_ScalarExprRoot sem (Inh_ScalarExprRoot _lhsIcat _lhsIdownEnv _lhsIflags) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIdownEnv _lhsIflags
       in  (Syn_ScalarExprRoot _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprRoot_ScalarExprRoot :: T_ScalarExpr ->
                                       T_ScalarExprRoot
  _sem_ScalarExprRoot_ScalarExprRoot expr_ =
      (\ _lhsIcat
         _lhsIdownEnv
         _lhsIflags ->
           (let _exprOexpectedCast :: Bool
                _exprOodbcFunction :: Bool
                _exprOdownEnv :: Environment
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOassignmentCastContext :: Bool
                _exprOimCast :: (Maybe TypeExtra)
                _lhsOannotatedTree :: ScalarExprRoot
                _lhsOoriginalTree :: ScalarExprRoot
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 94, column 37)
                _exprOexpectedCast =
                    ({-# LINE 94 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 17223 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 159, column 22)
                _exprOodbcFunction =
                    ({-# LINE 159 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 17229 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 237, column 9)
                _exprOdownEnv =
                    ({-# LINE 237 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 17235 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 741, column 20)
                _exprOexpectedType =
                    ({-# LINE 741 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     Nothing
                     {-# LINE 17241 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 820, column 37)
                _exprOassignmentCastContext =
                    ({-# LINE 820 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 17247 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag"(line 136, column 8)
                _exprOimCast =
                    ({-# LINE 136 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Nothing
                     {-# LINE 17253 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ScalarExprRoot _exprIannotatedTree
                     {-# LINE 17259 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ScalarExprRoot _exprIoriginalTree
                     {-# LINE 17265 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17271 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17277 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17283 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17289 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprStatementListPair ---------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprStatementListPair 
           originalTree         : ScalarExprStatementListPair 
     alternatives:
        alternative Tuple:
           child x1             : ScalarExpr 
           child x2             : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprStatementListPair = ( ScalarExpr,StatementList)
  -- cata
  _sem_ScalarExprStatementListPair :: ScalarExprStatementListPair ->
                                     T_ScalarExprStatementListPair
  _sem_ScalarExprStatementListPair ( x1,x2) =
      (_sem_ScalarExprStatementListPair_Tuple (_sem_ScalarExpr x1) (_sem_StatementList x2))
  -- semantic domain
  type T_ScalarExprStatementListPair = Catalog ->
                                       TypeCheckFlags ->
                                       (Maybe TypeExtra) ->
                                       ( ScalarExprStatementListPair,ScalarExprStatementListPair)
  data Inh_ScalarExprStatementListPair = Inh_ScalarExprStatementListPair {_cat_Inh_ScalarExprStatementListPair :: Catalog,_flags_Inh_ScalarExprStatementListPair :: TypeCheckFlags,_imCast_Inh_ScalarExprStatementListPair :: (Maybe TypeExtra)}
  data Syn_ScalarExprStatementListPair = Syn_ScalarExprStatementListPair {_annotatedTree_Syn_ScalarExprStatementListPair :: ScalarExprStatementListPair,_originalTree_Syn_ScalarExprStatementListPair :: ScalarExprStatementListPair}
  _wrap_ScalarExprStatementListPair :: T_ScalarExprStatementListPair ->
                                      Inh_ScalarExprStatementListPair ->
                                      Syn_ScalarExprStatementListPair
  _wrap_ScalarExprStatementListPair sem (Inh_ScalarExprStatementListPair _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprStatementListPair _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprStatementListPair_Tuple :: T_ScalarExpr ->
                                           T_StatementList ->
                                           T_ScalarExprStatementListPair
  _sem_ScalarExprStatementListPair_Tuple x1_ x2_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _x1OdownEnv :: Environment
                _x1OexpectedCast :: Bool
                _x1OexpectedType :: (Maybe TypeExtra)
                _x1OodbcFunction :: Bool
                _x1OassignmentCastContext :: Bool
                _lhsOannotatedTree :: ScalarExprStatementListPair
                _lhsOoriginalTree :: ScalarExprStatementListPair
                _x1Ocat :: Catalog
                _x1Oflags :: TypeCheckFlags
                _x1OimCast :: (Maybe TypeExtra)
                _x2Ocat :: Catalog
                _x2Oflags :: TypeCheckFlags
                _x2OimCast :: (Maybe TypeExtra)
                _x1IannotatedTree :: ScalarExpr
                _x1IcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _x1IoriginalTree :: ScalarExpr
                _x1IupType :: (Maybe TypeExtra)
                _x2IannotatedTree :: StatementList
                _x2IoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 95, column 41)
                _x1OdownEnv =
                    ({-# LINE 95 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 17361 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 96, column 41)
                _x1OexpectedCast =
                    ({-# LINE 96 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 17367 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 97, column 41)
                _x1OexpectedType =
                    ({-# LINE 97 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 17373 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 98, column 41)
                _x1OodbcFunction =
                    ({-# LINE 98 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 17379 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 821, column 41)
                _x1OassignmentCastContext =
                    ({-# LINE 821 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 17385 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IannotatedTree,_x2IannotatedTree)
                     {-# LINE 17391 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (_x1IoriginalTree,_x2IoriginalTree)
                     {-# LINE 17397 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17403 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17409 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17415 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17421 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17427 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17433 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17439 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _x2OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17445 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _x1IannotatedTree,_x1IcolExprs,_x1IoriginalTree,_x1IupType) =
                    x1_ _x1OassignmentCastContext _x1Ocat _x1OdownEnv _x1OexpectedCast _x1OexpectedType _x1Oflags _x1OimCast _x1OodbcFunction
                ( _x2IannotatedTree,_x2IoriginalTree) =
                    x2_ _x2Ocat _x2Oflags _x2OimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprStatementListPairList -----------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprStatementListPairList 
           originalTree         : ScalarExprStatementListPairList 
     alternatives:
        alternative Cons:
           child hd             : ScalarExprStatementListPair 
           child tl             : ScalarExprStatementListPairList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprStatementListPairList = [ScalarExprStatementListPair]
  -- cata
  _sem_ScalarExprStatementListPairList :: ScalarExprStatementListPairList ->
                                         T_ScalarExprStatementListPairList
  _sem_ScalarExprStatementListPairList list =
      (Prelude.foldr _sem_ScalarExprStatementListPairList_Cons _sem_ScalarExprStatementListPairList_Nil (Prelude.map _sem_ScalarExprStatementListPair list))
  -- semantic domain
  type T_ScalarExprStatementListPairList = Catalog ->
                                           TypeCheckFlags ->
                                           (Maybe TypeExtra) ->
                                           ( ScalarExprStatementListPairList,ScalarExprStatementListPairList)
  data Inh_ScalarExprStatementListPairList = Inh_ScalarExprStatementListPairList {_cat_Inh_ScalarExprStatementListPairList :: Catalog,_flags_Inh_ScalarExprStatementListPairList :: TypeCheckFlags,_imCast_Inh_ScalarExprStatementListPairList :: (Maybe TypeExtra)}
  data Syn_ScalarExprStatementListPairList = Syn_ScalarExprStatementListPairList {_annotatedTree_Syn_ScalarExprStatementListPairList :: ScalarExprStatementListPairList,_originalTree_Syn_ScalarExprStatementListPairList :: ScalarExprStatementListPairList}
  _wrap_ScalarExprStatementListPairList :: T_ScalarExprStatementListPairList ->
                                          Inh_ScalarExprStatementListPairList ->
                                          Syn_ScalarExprStatementListPairList
  _wrap_ScalarExprStatementListPairList sem (Inh_ScalarExprStatementListPairList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprStatementListPairList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_ScalarExprStatementListPairList_Cons :: T_ScalarExprStatementListPair ->
                                              T_ScalarExprStatementListPairList ->
                                              T_ScalarExprStatementListPairList
  _sem_ScalarExprStatementListPairList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ScalarExprStatementListPairList
                _lhsOoriginalTree :: ScalarExprStatementListPairList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ScalarExprStatementListPair
                _hdIoriginalTree :: ScalarExprStatementListPair
                _tlIannotatedTree :: ScalarExprStatementListPairList
                _tlIoriginalTree :: ScalarExprStatementListPairList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 17516 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 17522 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17528 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17534 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17540 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17546 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17552 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17558 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17564 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17570 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_ScalarExprStatementListPairList_Nil :: T_ScalarExprStatementListPairList
  _sem_ScalarExprStatementListPairList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: ScalarExprStatementListPairList
                _lhsOoriginalTree :: ScalarExprStatementListPairList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 17588 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 17594 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17600 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17606 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- ScalarExprTransposedList ------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           expectedCast         : Bool
           expectedType         : Maybe [TypeExtra]
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : ScalarExprTransposedList 
           originalTree         : ScalarExprTransposedList 
           upType               : Maybe [TypeExtra]
     alternatives:
        alternative Cons:
           child hd             : ScalarExpr 
           child tl             : ScalarExprTransposedList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type ScalarExprTransposedList = [ScalarExpr]
  -- cata
  _sem_ScalarExprTransposedList :: ScalarExprTransposedList ->
                                  T_ScalarExprTransposedList
  _sem_ScalarExprTransposedList list =
      (Prelude.foldr _sem_ScalarExprTransposedList_Cons _sem_ScalarExprTransposedList_Nil (Prelude.map _sem_ScalarExpr list))
  -- semantic domain
  type T_ScalarExprTransposedList = Catalog ->
                                    Bool ->
                                    (Maybe [TypeExtra]) ->
                                    TypeCheckFlags ->
                                    (Maybe TypeExtra) ->
                                    ( ScalarExprTransposedList,ScalarExprTransposedList,(Maybe [TypeExtra]))
  data Inh_ScalarExprTransposedList = Inh_ScalarExprTransposedList {_cat_Inh_ScalarExprTransposedList :: Catalog,_expectedCast_Inh_ScalarExprTransposedList :: Bool,_expectedType_Inh_ScalarExprTransposedList :: (Maybe [TypeExtra]),_flags_Inh_ScalarExprTransposedList :: TypeCheckFlags,_imCast_Inh_ScalarExprTransposedList :: (Maybe TypeExtra)}
  data Syn_ScalarExprTransposedList = Syn_ScalarExprTransposedList {_annotatedTree_Syn_ScalarExprTransposedList :: ScalarExprTransposedList,_originalTree_Syn_ScalarExprTransposedList :: ScalarExprTransposedList,_upType_Syn_ScalarExprTransposedList :: (Maybe [TypeExtra])}
  _wrap_ScalarExprTransposedList :: T_ScalarExprTransposedList ->
                                   Inh_ScalarExprTransposedList ->
                                   Syn_ScalarExprTransposedList
  _wrap_ScalarExprTransposedList sem (Inh_ScalarExprTransposedList _lhsIcat _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType) = sem _lhsIcat _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_ScalarExprTransposedList _lhsOannotatedTree _lhsOoriginalTree _lhsOupType))
  _sem_ScalarExprTransposedList_Cons :: T_ScalarExpr ->
                                       T_ScalarExprTransposedList ->
                                       T_ScalarExprTransposedList
  _sem_ScalarExprTransposedList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _hdOdownEnv :: Environment
                _lhsOupType :: (Maybe [TypeExtra])
                _hdOexpectedType :: (Maybe TypeExtra)
                _tlOexpectedType :: (Maybe [TypeExtra])
                _hdOexpectedCast :: Bool
                _tlOexpectedCast :: Bool
                _hdOodbcFunction :: Bool
                _hdOassignmentCastContext :: Bool
                _lhsOannotatedTree :: ScalarExprTransposedList
                _lhsOoriginalTree :: ScalarExprTransposedList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: ScalarExpr
                _hdIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _hdIoriginalTree :: ScalarExpr
                _hdIupType :: (Maybe TypeExtra)
                _tlIannotatedTree :: ScalarExprTransposedList
                _tlIoriginalTree :: ScalarExprTransposedList
                _tlIupType :: (Maybe [TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 99, column 37)
                _hdOdownEnv =
                    ({-# LINE 99 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 17691 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 174, column 9)
                _lhsOupType =
                    ({-# LINE 174 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM2 (:) _hdIupType _tlIupType
                     {-# LINE 17697 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 175, column 9)
                _hdOexpectedType =
                    ({-# LINE 175 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM fst $ splitTypeExtraList _lhsIexpectedType
                     {-# LINE 17703 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 176, column 9)
                _tlOexpectedType =
                    ({-# LINE 176 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM snd $ splitTypeExtraList _lhsIexpectedType
                     {-# LINE 17709 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 177, column 9)
                _hdOexpectedCast =
                    ({-# LINE 177 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 17715 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 178, column 9)
                _tlOexpectedCast =
                    ({-# LINE 178 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 17721 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 163, column 12)
                _hdOodbcFunction =
                    ({-# LINE 163 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 17727 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 822, column 37)
                _hdOassignmentCastContext =
                    ({-# LINE 822 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 17733 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 17739 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 17745 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17751 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17757 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17763 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17769 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17775 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17781 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17787 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 17793 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIcolExprs,_hdIoriginalTree,_hdIupType) =
                    hd_ _hdOassignmentCastContext _hdOcat _hdOdownEnv _hdOexpectedCast _hdOexpectedType _hdOflags _hdOimCast _hdOodbcFunction
                ( _tlIannotatedTree,_tlIoriginalTree,_tlIupType) =
                    tl_ _tlOcat _tlOexpectedCast _tlOexpectedType _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  _sem_ScalarExprTransposedList_Nil :: T_ScalarExprTransposedList
  _sem_ScalarExprTransposedList_Nil =
      (\ _lhsIcat
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupType :: (Maybe [TypeExtra])
                _lhsOannotatedTree :: ScalarExprTransposedList
                _lhsOoriginalTree :: ScalarExprTransposedList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 180, column 9)
                _lhsOupType =
                    ({-# LINE 180 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Just []
                     {-# LINE 17814 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 17820 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 17826 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 17832 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17838 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupType)))
  -- SelectItem --------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe TypeExtra
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : SelectItem 
           colExprs             : [(NameComponent,Maybe TypeExtra,ScalarExpr)]
           originalTree         : SelectItem 
     alternatives:
        alternative SelExp:
           child ann            : Annotation 
           child ex             : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative SelectItem:
           child ann            : Annotation 
           child ex             : ScalarExpr 
           child name           : {NameComponent}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data SelectItem = SelExp (Annotation) (ScalarExpr)
                  | SelectItem (Annotation) (ScalarExpr) (NameComponent)
                  deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_SelectItem :: SelectItem ->
                    T_SelectItem
  _sem_SelectItem (SelExp _ann _ex) =
      (_sem_SelectItem_SelExp (_sem_Annotation _ann) (_sem_ScalarExpr _ex))
  _sem_SelectItem (SelectItem _ann _ex _name) =
      (_sem_SelectItem_SelectItem (_sem_Annotation _ann) (_sem_ScalarExpr _ex) _name)
  -- semantic domain
  type T_SelectItem = Bool ->
                      Catalog ->
                      Environment ->
                      Bool ->
                      (Maybe TypeExtra) ->
                      TypeCheckFlags ->
                      (Maybe TypeExtra) ->
                      ( SelectItem,([(NameComponent,Maybe TypeExtra,ScalarExpr)]),SelectItem)
  data Inh_SelectItem = Inh_SelectItem {_assignmentCastContext_Inh_SelectItem :: Bool,_cat_Inh_SelectItem :: Catalog,_downEnv_Inh_SelectItem :: Environment,_expectedCast_Inh_SelectItem :: Bool,_expectedType_Inh_SelectItem :: (Maybe TypeExtra),_flags_Inh_SelectItem :: TypeCheckFlags,_imCast_Inh_SelectItem :: (Maybe TypeExtra)}
  data Syn_SelectItem = Syn_SelectItem {_annotatedTree_Syn_SelectItem :: SelectItem,_colExprs_Syn_SelectItem :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)]),_originalTree_Syn_SelectItem :: SelectItem}
  _wrap_SelectItem :: T_SelectItem ->
                     Inh_SelectItem ->
                     Syn_SelectItem
  _wrap_SelectItem sem (Inh_SelectItem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_SelectItem _lhsOannotatedTree _lhsOcolExprs _lhsOoriginalTree))
  _sem_SelectItem_SelExp :: T_Annotation ->
                           T_ScalarExpr ->
                           T_SelectItem
  _sem_SelectItem_SelExp ann_ ex_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: SelectItem
                _annOtpe :: (Either [TypeError] TypeExtra)
                _exOexpectedType :: (Maybe TypeExtra)
                _exOexpectedCast :: Bool
                _exOodbcFunction :: Bool
                _lhsOoriginalTree :: SelectItem
                _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exOassignmentCastContext :: Bool
                _exOcat :: Catalog
                _exOdownEnv :: Environment
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: ScalarExpr
                _exIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exIoriginalTree :: ScalarExpr
                _exIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 117, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     if tcfAddSelectItemAliases _lhsIflags
                     then case _exIcolExprs of
                            [(n,_,_)] -> SelectItem _annIannotatedTree _exIannotatedTree n
                            _ ->
                                 _annotatedTree
                     else _annotatedTree
                     {-# LINE 17939 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 214, column 7)
                _annOtpe =
                    ({-# LINE 214 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     Left []
                     {-# LINE 17945 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 215, column 7)
                _exOexpectedType =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 17951 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 216, column 7)
                _exOexpectedCast =
                    ({-# LINE 216 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 17957 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 166, column 25)
                _exOodbcFunction =
                    ({-# LINE 166 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 17963 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SelExp _annIannotatedTree _exIannotatedTree
                     {-# LINE 17969 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SelExp _annIoriginalTree _exIoriginalTree
                     {-# LINE 17975 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 17981 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOcolExprs =
                    ({-# LINE 150 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _exIcolExprs
                     {-# LINE 17987 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 17993 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 17999 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18005 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 18011 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18017 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 18023 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18029 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18035 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIcolExprs,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOdownEnv _exOexpectedCast _exOexpectedType _exOflags _exOimCast _exOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree)))
  _sem_SelectItem_SelectItem :: T_Annotation ->
                               T_ScalarExpr ->
                               NameComponent ->
                               T_SelectItem
  _sem_SelectItem_SelectItem ann_ ex_ name_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _annOtpe :: (Either [TypeError] TypeExtra)
                _exOexpectedType :: (Maybe TypeExtra)
                _exOexpectedCast :: Bool
                _exOodbcFunction :: Bool
                _lhsOannotatedTree :: SelectItem
                _lhsOoriginalTree :: SelectItem
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exOassignmentCastContext :: Bool
                _exOcat :: Catalog
                _exOdownEnv :: Environment
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: ScalarExpr
                _exIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exIoriginalTree :: ScalarExpr
                _exIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 112, column 7)
                _lhsOcolExprs =
                    ({-# LINE 112 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     case _exIcolExprs of
                       [(_,t,e)] -> [(name_, t,e)]
                       x -> x
                     {-# LINE 18081 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 214, column 7)
                _annOtpe =
                    ({-# LINE 214 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     Left []
                     {-# LINE 18087 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 215, column 7)
                _exOexpectedType =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 18093 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 216, column 7)
                _exOexpectedCast =
                    ({-# LINE 216 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 18099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 166, column 25)
                _exOodbcFunction =
                    ({-# LINE 166 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 18105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SelectItem _annIannotatedTree _exIannotatedTree name_
                     {-# LINE 18111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SelectItem _annIoriginalTree _exIoriginalTree name_
                     {-# LINE 18117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 18123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 18129 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18135 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18141 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18147 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 18153 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18159 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOdownEnv =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 18165 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18171 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18177 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIcolExprs,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOdownEnv _exOexpectedCast _exOexpectedType _exOflags _exOimCast _exOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree)))
  -- SelectItemList ----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe [TypeExtra]
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : SelectItemList 
           colExprs             : [(NameComponent,Maybe TypeExtra,ScalarExpr)]
           originalTree         : SelectItemList 
           upEnv                : Environment
           upType               : Maybe [(Text,TypeExtra)]
     alternatives:
        alternative Cons:
           child hd             : SelectItem 
           child tl             : SelectItemList 
           visit 0:
              local colExprs    : _
              local upType      : _
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local upType      : _
              local annotatedTree : _
              local originalTree : _
  -}
  type SelectItemList = [SelectItem]
  -- cata
  _sem_SelectItemList :: SelectItemList ->
                        T_SelectItemList
  _sem_SelectItemList list =
      (Prelude.foldr _sem_SelectItemList_Cons _sem_SelectItemList_Nil (Prelude.map _sem_SelectItem list))
  -- semantic domain
  type T_SelectItemList = Bool ->
                          Catalog ->
                          Environment ->
                          Bool ->
                          (Maybe [TypeExtra]) ->
                          TypeCheckFlags ->
                          (Maybe TypeExtra) ->
                          ( SelectItemList,([(NameComponent,Maybe TypeExtra,ScalarExpr)]),SelectItemList,Environment,(Maybe [(Text,TypeExtra)]))
  data Inh_SelectItemList = Inh_SelectItemList {_assignmentCastContext_Inh_SelectItemList :: Bool,_cat_Inh_SelectItemList :: Catalog,_downEnv_Inh_SelectItemList :: Environment,_expectedCast_Inh_SelectItemList :: Bool,_expectedType_Inh_SelectItemList :: (Maybe [TypeExtra]),_flags_Inh_SelectItemList :: TypeCheckFlags,_imCast_Inh_SelectItemList :: (Maybe TypeExtra)}
  data Syn_SelectItemList = Syn_SelectItemList {_annotatedTree_Syn_SelectItemList :: SelectItemList,_colExprs_Syn_SelectItemList :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)]),_originalTree_Syn_SelectItemList :: SelectItemList,_upEnv_Syn_SelectItemList :: Environment,_upType_Syn_SelectItemList :: (Maybe [(Text,TypeExtra)])}
  _wrap_SelectItemList :: T_SelectItemList ->
                         Inh_SelectItemList ->
                         Syn_SelectItemList
  _wrap_SelectItemList sem (Inh_SelectItemList _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupEnv,_lhsOupType) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_SelectItemList _lhsOannotatedTree _lhsOcolExprs _lhsOoriginalTree _lhsOupEnv _lhsOupType))
  _sem_SelectItemList_Cons :: T_SelectItem ->
                             T_SelectItemList ->
                             T_SelectItemList
  _sem_SelectItemList_Cons hd_ tl_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: SelectItemList
                _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _hdOexpectedType :: (Maybe TypeExtra)
                _tlOexpectedType :: (Maybe [TypeExtra])
                _hdOexpectedCast :: Bool
                _tlOexpectedCast :: Bool
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _lhsOupEnv :: Environment
                _lhsOoriginalTree :: SelectItemList
                _hdOassignmentCastContext :: Bool
                _hdOcat :: Catalog
                _hdOdownEnv :: Environment
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOassignmentCastContext :: Bool
                _tlOcat :: Catalog
                _tlOdownEnv :: Environment
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: SelectItem
                _hdIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _hdIoriginalTree :: SelectItem
                _tlIannotatedTree :: SelectItemList
                _tlIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _tlIoriginalTree :: SelectItemList
                _tlIupEnv :: Environment
                _tlIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 132, column 10)
                _lhsOannotatedTree =
                    ({-# LINE 132 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     if tcfExpandStars _lhsIflags
                     then flip map _colExprs $ \(n,_t,e) ->
                           if ncStr n == ncStr (columnName e) && not (tcfAddSelectItemAliases _lhsIflags)
                           then SelExp emptyAnnotation e
                           else SelectItem emptyAnnotation e n
                     else _annotatedTree
                     {-# LINE 18286 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 183, column 9)
                _colExprs =
                    ({-# LINE 183 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _hdIcolExprs ++ _tlIcolExprs
                     {-# LINE 18292 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 184, column 9)
                _lhsOcolExprs =
                    ({-# LINE 184 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _colExprs
                     {-# LINE 18298 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 185, column 9)
                _upType =
                    ({-# LINE 185 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     sequence $ flip map _colExprs
                     $ \(n,t,_) -> fmap (ncStrT n,) t
                     {-# LINE 18305 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 187, column 9)
                _hdOexpectedType =
                    ({-# LINE 187 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     liftM fst $ splitTypeExtraList _lhsIexpectedType
                     {-# LINE 18311 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 188, column 9)
                _tlOexpectedType =
                    ({-# LINE 188 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     liftM snd $ splitTypeExtraList _lhsIexpectedType
                     {-# LINE 18317 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 189, column 9)
                _hdOexpectedCast =
                    ({-# LINE 189 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 18323 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 190, column 9)
                _tlOexpectedCast =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedCast
                     {-# LINE 18329 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 192, column 7)
                _lhsOupType =
                    ({-# LINE 192 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _upType
                     {-# LINE 18335 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 193, column 7)
                _lhsOupEnv =
                    ({-# LINE 193 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     case fmap E.envSelectListEnvironment _upType     of
                       (Just (Right e)) -> e
                       _ -> E.brokeEnvironment
                     {-# LINE 18343 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 18349 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 18355 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 18361 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 18367 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18373 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOdownEnv =
                    ({-# LINE 151 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 18379 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18385 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18391 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 18397 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18403 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOdownEnv =
                    ({-# LINE 156 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 18409 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18415 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18421 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIcolExprs,_hdIoriginalTree) =
                    hd_ _hdOassignmentCastContext _hdOcat _hdOdownEnv _hdOexpectedCast _hdOexpectedType _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIcolExprs,_tlIoriginalTree,_tlIupEnv,_tlIupType) =
                    tl_ _tlOassignmentCastContext _tlOcat _tlOdownEnv _tlOexpectedCast _tlOexpectedType _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupEnv,_lhsOupType)))
  _sem_SelectItemList_Nil :: T_SelectItemList
  _sem_SelectItemList_Nil =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: SelectItemList
                _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _lhsOupEnv :: Environment
                _lhsOoriginalTree :: SelectItemList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 131, column 9)
                _lhsOannotatedTree =
                    ({-# LINE 131 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     []
                     {-# LINE 18446 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 180, column 9)
                _lhsOcolExprs =
                    ({-# LINE 180 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     []
                     {-# LINE 18452 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 181, column 9)
                _upType =
                    ({-# LINE 181 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     Nothing
                     {-# LINE 18458 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 192, column 7)
                _lhsOupType =
                    ({-# LINE 192 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _upType
                     {-# LINE 18464 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 193, column 7)
                _lhsOupEnv =
                    ({-# LINE 193 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     case fmap E.envSelectListEnvironment _upType     of
                       (Just (Right e)) -> e
                       _ -> E.brokeEnvironment
                     {-# LINE 18472 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 18478 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 18484 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 18490 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupEnv,_lhsOupType)))
  -- SelectList --------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           assignmentCastContext : Bool
           cat                  : Catalog
           downEnv              : Environment
           expectedCast         : Bool
           expectedType         : Maybe [TypeExtra]
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : SelectList 
           colExprs             : [(NameComponent,Maybe TypeExtra,ScalarExpr)]
           originalTree         : SelectList 
           upEnv                : Environment
           upType               : Maybe [(Text,TypeExtra)]
     alternatives:
        alternative SelectList:
           child ann            : Annotation 
           child items          : SelectItemList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data SelectList = SelectList (Annotation) (SelectItemList)
                  deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_SelectList :: SelectList ->
                    T_SelectList
  _sem_SelectList (SelectList _ann _items) =
      (_sem_SelectList_SelectList (_sem_Annotation _ann) (_sem_SelectItemList _items))
  -- semantic domain
  type T_SelectList = Bool ->
                      Catalog ->
                      Environment ->
                      Bool ->
                      (Maybe [TypeExtra]) ->
                      TypeCheckFlags ->
                      (Maybe TypeExtra) ->
                      ( SelectList,([(NameComponent,Maybe TypeExtra,ScalarExpr)]),SelectList,Environment,(Maybe [(Text,TypeExtra)]))
  data Inh_SelectList = Inh_SelectList {_assignmentCastContext_Inh_SelectList :: Bool,_cat_Inh_SelectList :: Catalog,_downEnv_Inh_SelectList :: Environment,_expectedCast_Inh_SelectList :: Bool,_expectedType_Inh_SelectList :: (Maybe [TypeExtra]),_flags_Inh_SelectList :: TypeCheckFlags,_imCast_Inh_SelectList :: (Maybe TypeExtra)}
  data Syn_SelectList = Syn_SelectList {_annotatedTree_Syn_SelectList :: SelectList,_colExprs_Syn_SelectList :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)]),_originalTree_Syn_SelectList :: SelectList,_upEnv_Syn_SelectList :: Environment,_upType_Syn_SelectList :: (Maybe [(Text,TypeExtra)])}
  _wrap_SelectList :: T_SelectList ->
                     Inh_SelectList ->
                     Syn_SelectList
  _wrap_SelectList sem (Inh_SelectList _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupEnv,_lhsOupType) = sem _lhsIassignmentCastContext _lhsIcat _lhsIdownEnv _lhsIexpectedCast _lhsIexpectedType _lhsIflags _lhsIimCast
       in  (Syn_SelectList _lhsOannotatedTree _lhsOcolExprs _lhsOoriginalTree _lhsOupEnv _lhsOupType))
  _sem_SelectList_SelectList :: T_Annotation ->
                               T_SelectItemList ->
                               T_SelectList
  _sem_SelectList_SelectList ann_ items_ =
      (\ _lhsIassignmentCastContext
         _lhsIcat
         _lhsIdownEnv
         _lhsIexpectedCast
         _lhsIexpectedType
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _itemsOexpectedCast :: Bool
                _lhsOannotatedTree :: SelectList
                _lhsOoriginalTree :: SelectList
                _lhsOcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _lhsOupEnv :: Environment
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _itemsOassignmentCastContext :: Bool
                _itemsOcat :: Catalog
                _itemsOdownEnv :: Environment
                _itemsOexpectedType :: (Maybe [TypeExtra])
                _itemsOflags :: TypeCheckFlags
                _itemsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _itemsIannotatedTree :: SelectItemList
                _itemsIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _itemsIoriginalTree :: SelectItemList
                _itemsIupEnv :: Environment
                _itemsIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 210, column 7)
                _annOtpe =
                    ({-# LINE 210 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     Left []
                     {-# LINE 18580 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag"(line 211, column 7)
                _itemsOexpectedCast =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     True
                     {-# LINE 18586 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SelectList _annIannotatedTree _itemsIannotatedTree
                     {-# LINE 18592 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SelectList _annIoriginalTree _itemsIoriginalTree
                     {-# LINE 18598 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 18604 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 18610 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOcolExprs =
                    ({-# LINE 157 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _itemsIcolExprs
                     {-# LINE 18616 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOupEnv =
                    ({-# LINE 161 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _itemsIupEnv
                     {-# LINE 18622 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOupType =
                    ({-# LINE 158 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _itemsIupType
                     {-# LINE 18628 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18634 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18640 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18646 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _itemsOassignmentCastContext =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     _lhsIassignmentCastContext
                     {-# LINE 18652 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _itemsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18658 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _itemsOdownEnv =
                    ({-# LINE 156 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIdownEnv
                     {-# LINE 18664 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _itemsOexpectedType =
                    ({-# LINE 159 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/SelectLists.ag" #-}
                     _lhsIexpectedType
                     {-# LINE 18670 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _itemsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18676 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _itemsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18682 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _itemsIannotatedTree,_itemsIcolExprs,_itemsIoriginalTree,_itemsIupEnv,_itemsIupType) =
                    items_ _itemsOassignmentCastContext _itemsOcat _itemsOdownEnv _itemsOexpectedCast _itemsOexpectedType _itemsOflags _itemsOimCast
            in  ( _lhsOannotatedTree,_lhsOcolExprs,_lhsOoriginalTree,_lhsOupEnv,_lhsOupType)))
  -- SetClause ---------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : SetClause 
           originalTree         : SetClause 
     alternatives:
        alternative SetClause:
           child ann            : Annotation 
           child setTarget      : {NameComponent}
           child ex             : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative MultiSetClause:
           child ann            : Annotation 
           child setTargets     : {[NameComponent]}
           child ex             : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data SetClause = SetClause (Annotation) (NameComponent) (ScalarExpr)
                 | MultiSetClause (Annotation) (([NameComponent])) (ScalarExpr)
                 deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_SetClause :: SetClause ->
                   T_SetClause
  _sem_SetClause (SetClause _ann _setTarget _ex) =
      (_sem_SetClause_SetClause (_sem_Annotation _ann) _setTarget (_sem_ScalarExpr _ex))
  _sem_SetClause (MultiSetClause _ann _setTargets _ex) =
      (_sem_SetClause_MultiSetClause (_sem_Annotation _ann) _setTargets (_sem_ScalarExpr _ex))
  -- semantic domain
  type T_SetClause = Catalog ->
                     TypeCheckFlags ->
                     (Maybe TypeExtra) ->
                     ( SetClause,SetClause)
  data Inh_SetClause = Inh_SetClause {_cat_Inh_SetClause :: Catalog,_flags_Inh_SetClause :: TypeCheckFlags,_imCast_Inh_SetClause :: (Maybe TypeExtra)}
  data Syn_SetClause = Syn_SetClause {_annotatedTree_Syn_SetClause :: SetClause,_originalTree_Syn_SetClause :: SetClause}
  _wrap_SetClause :: T_SetClause ->
                    Inh_SetClause ->
                    Syn_SetClause
  _wrap_SetClause sem (Inh_SetClause _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_SetClause _lhsOannotatedTree _lhsOoriginalTree))
  _sem_SetClause_SetClause :: T_Annotation ->
                             NameComponent ->
                             T_ScalarExpr ->
                             T_SetClause
  _sem_SetClause_SetClause ann_ setTarget_ ex_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exOdownEnv :: Environment
                _exOexpectedCast :: Bool
                _exOexpectedType :: (Maybe TypeExtra)
                _exOodbcFunction :: Bool
                _exOassignmentCastContext :: Bool
                _lhsOannotatedTree :: SetClause
                _lhsOoriginalTree :: SetClause
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exOcat :: Catalog
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: ScalarExpr
                _exIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exIoriginalTree :: ScalarExpr
                _exIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 104, column 27)
                _annOtpe =
                    ({-# LINE 104 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 18770 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 105, column 27)
                _exOdownEnv =
                    ({-# LINE 105 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 18776 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 106, column 27)
                _exOexpectedCast =
                    ({-# LINE 106 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 18782 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 107, column 27)
                _exOexpectedType =
                    ({-# LINE 107 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 18788 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 169, column 32)
                _exOodbcFunction =
                    ({-# LINE 169 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 18794 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 824, column 27)
                _exOassignmentCastContext =
                    ({-# LINE 824 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 18800 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetClause _annIannotatedTree setTarget_ _exIannotatedTree
                     {-# LINE 18806 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetClause _annIoriginalTree setTarget_ _exIoriginalTree
                     {-# LINE 18812 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 18818 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 18824 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18830 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18836 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18842 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18848 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18854 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18860 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIcolExprs,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOdownEnv _exOexpectedCast _exOexpectedType _exOflags _exOimCast _exOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_SetClause_MultiSetClause :: T_Annotation ->
                                  ([NameComponent]) ->
                                  T_ScalarExpr ->
                                  T_SetClause
  _sem_SetClause_MultiSetClause ann_ setTargets_ ex_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exOdownEnv :: Environment
                _exOexpectedCast :: Bool
                _exOexpectedType :: (Maybe TypeExtra)
                _exOodbcFunction :: Bool
                _exOassignmentCastContext :: Bool
                _lhsOannotatedTree :: SetClause
                _lhsOoriginalTree :: SetClause
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exOcat :: Catalog
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: ScalarExpr
                _exIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exIoriginalTree :: ScalarExpr
                _exIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 100, column 32)
                _annOtpe =
                    ({-# LINE 100 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 18899 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 101, column 32)
                _exOdownEnv =
                    ({-# LINE 101 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 18905 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 102, column 32)
                _exOexpectedCast =
                    ({-# LINE 102 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 18911 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 103, column 32)
                _exOexpectedType =
                    ({-# LINE 103 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 18917 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 169, column 32)
                _exOodbcFunction =
                    ({-# LINE 169 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 18923 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 823, column 32)
                _exOassignmentCastContext =
                    ({-# LINE 823 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 18929 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     MultiSetClause _annIannotatedTree setTargets_ _exIannotatedTree
                     {-# LINE 18935 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     MultiSetClause _annIoriginalTree setTargets_ _exIoriginalTree
                     {-# LINE 18941 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 18947 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 18953 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18959 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18965 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18971 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 18977 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 18983 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 18989 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIcolExprs,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOdownEnv _exOexpectedCast _exOexpectedType _exOflags _exOimCast _exOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- SetClauseList -----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : SetClauseList 
           originalTree         : SetClauseList 
     alternatives:
        alternative Cons:
           child hd             : SetClause 
           child tl             : SetClauseList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type SetClauseList = [SetClause]
  -- cata
  _sem_SetClauseList :: SetClauseList ->
                       T_SetClauseList
  _sem_SetClauseList list =
      (Prelude.foldr _sem_SetClauseList_Cons _sem_SetClauseList_Nil (Prelude.map _sem_SetClause list))
  -- semantic domain
  type T_SetClauseList = Catalog ->
                         TypeCheckFlags ->
                         (Maybe TypeExtra) ->
                         ( SetClauseList,SetClauseList)
  data Inh_SetClauseList = Inh_SetClauseList {_cat_Inh_SetClauseList :: Catalog,_flags_Inh_SetClauseList :: TypeCheckFlags,_imCast_Inh_SetClauseList :: (Maybe TypeExtra)}
  data Syn_SetClauseList = Syn_SetClauseList {_annotatedTree_Syn_SetClauseList :: SetClauseList,_originalTree_Syn_SetClauseList :: SetClauseList}
  _wrap_SetClauseList :: T_SetClauseList ->
                        Inh_SetClauseList ->
                        Syn_SetClauseList
  _wrap_SetClauseList sem (Inh_SetClauseList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_SetClauseList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_SetClauseList_Cons :: T_SetClause ->
                            T_SetClauseList ->
                            T_SetClauseList
  _sem_SetClauseList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: SetClauseList
                _lhsOoriginalTree :: SetClauseList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: SetClause
                _hdIoriginalTree :: SetClause
                _tlIannotatedTree :: SetClauseList
                _tlIoriginalTree :: SetClauseList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 19060 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 19066 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 19072 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 19078 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 19084 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 19090 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 19096 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 19102 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 19108 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 19114 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_SetClauseList_Nil :: T_SetClauseList
  _sem_SetClauseList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: SetClauseList
                _lhsOoriginalTree :: SetClauseList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 19132 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 19138 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 19144 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 19150 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- Statement ---------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : Statement 
           originalTree         : Statement 
     alternatives:
        alternative QueryStatement:
           child ann            : Annotation 
           child ex             : QueryExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Insert:
           child ann            : Annotation 
           child table          : Name 
           child targetCols     : {[NameComponent]}
           child insData        : QueryExpr 
           child returning      : MaybeSelectList 
           visit 0:
              local tpe         : {Either [TypeError] [TypeExtra]}
              local tooManyCols : {Maybe [TypeError]}
              local annotatedTree : _
              local originalTree : _
        alternative Update:
           child ann            : Annotation 
           child table          : Name 
           child assigns        : SetClauseList 
           child fromList       : TableRefList 
           child whr            : MaybeBoolExpr 
           child returning      : MaybeSelectList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Delete:
           child ann            : Annotation 
           child table          : Name 
           child using          : TableRefList 
           child whr            : MaybeBoolExpr 
           child returning      : MaybeSelectList 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local downEnv     : _
              local annotatedTree : _
              local originalTree : _
        alternative CopyFrom:
           child ann            : Annotation 
           child table          : Name 
           child targetCols     : {[NameComponent]}
           child source         : {CopyFromSource}
           child opts           : {[CopyFromOption]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CopyData:
           child ann            : Annotation 
           child insData        : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CopyTo:
           child ann            : Annotation 
           child cp             : {CopyToSource}
           child fn             : {String}
           child opts           : {[CopyToOption]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Truncate:
           child ann            : Annotation 
           child tables         : {[Name]}
           child restartIdentity : {RestartIdentity}
           child cascade        : {Cascade}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateTable:
           child ann            : Annotation 
           child name           : Name 
           child atts           : AttributeDefList 
           child cons           : ConstraintList 
           child partition      : MaybeTablePartitionDef 
           child rep            : {Replace}
           child options        : {[TableOption]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterTable:
           child ann            : Annotation 
           child name           : Name 
           child operation      : AlterTableOperation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterDatabase:
           child ann            : Annotation 
           child name           : Name 
           child operation      : AlterDatabaseOperation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateSequence:
           child ann            : Annotation 
           child name           : Name 
           child incr           : {Integer}
           child min            : {Maybe Integer}
           child max            : {Maybe Integer}
           child start          : {Integer}
           child cache          : {Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSequence:
           child ann            : Annotation 
           child name           : Name 
           child operation      : AlterSequenceOperation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateTableAs:
           child ann            : Annotation 
           child name           : Name 
           child rep            : {Replace}
           child expr           : QueryExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateView:
           child ann            : Annotation 
           child name           : Name 
           child colNames       : {MaybeNameComponentList}
           child expr           : QueryExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterView:
           child ann            : Annotation 
           child name           : Name 
           child colNames       : {MaybeNameComponentList}
           child expr           : QueryExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateType:
           child ann            : Annotation 
           child name           : Name 
           child atts           : TypeAttributeDefList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateUser:
           child ann            : Annotation 
           child name           : Name 
           child password       : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateLogin:
           child ann            : Annotation 
           child name           : Name 
           child password       : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterUser:
           child ann            : Annotation 
           child name           : Name 
           child password       : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterLogin:
           child ann            : Annotation 
           child name           : Name 
           child password       : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateSchema:
           child ann            : Annotation 
           child name           : Name 
           child owner          : {Maybe Name}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AlterSchema:
           child ann            : Annotation 
           child name           : Name 
           child operation      : AlterSchemaOperation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateFunction:
           child ann            : Annotation 
           child name           : Name 
           child params         : ParamDefList 
           child rettype        : TypeName 
           child rep            : {Replace}
           child lang           : {Language}
           child body           : FnBody 
           child vol            : {Volatility}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateDomain:
           child ann            : Annotation 
           child name           : Name 
           child typ            : TypeName 
           child constraintName : {String}
           child check          : MaybeBoolExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateLanguage:
           child ann            : Annotation 
           child name           : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateTrigger:
           child ann            : Annotation 
           child name           : {NameComponent}
           child wh             : {TriggerWhen}
           child events         : {[TriggerEvent]}
           child tbl            : Name 
           child firing         : {TriggerFire}
           child fnName         : Name 
           child fnArgs         : ScalarExprList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DropFunction:
           child ann            : Annotation 
           child ifE            : {IfExists}
           child sigs           : NameTypeNameListPairList 
           child cascade        : {Cascade}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DropSomething:
           child ann            : Annotation 
           child dropType       : {DropType}
           child ifE            : {IfExists}
           child names          : {[Name]}
           child cascade        : {Cascade}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DropTrigger:
           child ann            : Annotation 
           child ifE            : {IfExists}
           child name           : {NameComponent}
           child tbl            : Name 
           child cascade        : {Cascade}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateDatabase:
           child ann            : Annotation 
           child nm             : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Set:
           child ann            : Annotation 
           child name           : {String}
           child values         : {[SetValue]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Notify:
           child ann            : Annotation 
           child name           : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Into:
           child ann            : Annotation 
           child strict         : {Bool}
           child into           : {[Name]}
           child stmt           : Statement 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Assignment:
           child ann            : Annotation 
           child target         : Name 
           child value          : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Return:
           child ann            : Annotation 
           child value          : MaybeScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ReturnNext:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ReturnQuery:
           child ann            : Annotation 
           child sel            : QueryExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Raise:
           child ann            : Annotation 
           child level          : {RaiseType}
           child message        : {String}
           child args           : ScalarExprList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative NullStatement:
           child ann            : Annotation 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Perform:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Execute:
           child ann            : Annotation 
           child expr           : ScalarExpr 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ForQueryStatement:
           child ann            : Annotation 
           child lb             : {Maybe String}
           child var            : {NameComponent}
           child sel            : QueryExpr 
           child sts            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ForIntegerStatement:
           child ann            : Annotation 
           child lb             : {Maybe String}
           child var            : {NameComponent}
           child from           : ScalarExpr 
           child to             : ScalarExpr 
           child sts            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative LoopStatement:
           child ann            : Annotation 
           child lb             : {Maybe String}
           child sts            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative WhileStatement:
           child ann            : Annotation 
           child lb             : {Maybe String}
           child expr           : ScalarExpr 
           child sts            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ContinueStatement:
           child ann            : Annotation 
           child lb             : {Maybe String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ExitStatement:
           child ann            : Annotation 
           child lb             : {Maybe String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CaseStatementSimple:
           child ann            : Annotation 
           child val            : ScalarExpr 
           child cases          : ScalarExprListStatementListTripleList 
           child els            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CaseStatement:
           child ann            : Annotation 
           child cases          : ScalarExprListStatementListTripleList 
           child els            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative If:
           child ann            : Annotation 
           child cases          : ScalarExprStatementListPairList 
           child els            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Block:
           child ann            : Annotation 
           child lb             : {Maybe String}
           child vars           : VarDefList 
           child sts            : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative AntiStatement:
           child string         : {String}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative DeclareStatement:
           child ann            : Annotation 
           child ds             : {[(String,TypeName,Maybe ScalarExpr)]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ExecStatement:
           child ann            : Annotation 
           child spName         : Name 
           child args           : ScalarExprList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative CreateIndexTSQL:
           child ann            : Annotation 
           child nm             : {NameComponent}
           child obj            : Name 
           child cols           : {[NameComponent]}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data Statement = QueryStatement (Annotation) (QueryExpr)
                 | Insert (Annotation) (Name) (([NameComponent])) (QueryExpr) (MaybeSelectList)
                 | Update (Annotation) (Name) (SetClauseList) (TableRefList) (MaybeBoolExpr) (MaybeSelectList)
                 | Delete (Annotation) (Name) (TableRefList) (MaybeBoolExpr) (MaybeSelectList)
                 | CopyFrom (Annotation) (Name) (([NameComponent])) (CopyFromSource) (([CopyFromOption]))
                 | CopyData (Annotation) (String)
                 | CopyTo (Annotation) (CopyToSource) (String) (([CopyToOption]))
                 | Truncate (Annotation) (([Name])) (RestartIdentity) (Cascade)
                 | CreateTable (Annotation) (Name) (AttributeDefList) (ConstraintList) (MaybeTablePartitionDef) (Replace) (([TableOption]))
                 | AlterTable (Annotation) (Name) (AlterTableOperation)
                 | AlterDatabase (Annotation) (Name) (AlterDatabaseOperation)
                 | CreateSequence (Annotation) (Name) (Integer) ((Maybe Integer)) ((Maybe Integer)) (Integer) (Integer)
                 | AlterSequence (Annotation) (Name) (AlterSequenceOperation)
                 | CreateTableAs (Annotation) (Name) (Replace) (QueryExpr)
                 | CreateView (Annotation) (Name) (MaybeNameComponentList) (QueryExpr)
                 | AlterView (Annotation) (Name) (MaybeNameComponentList) (QueryExpr)
                 | CreateType (Annotation) (Name) (TypeAttributeDefList)
                 | CreateUser (Annotation) (Name) (String)
                 | CreateLogin (Annotation) (Name) (String)
                 | AlterUser (Annotation) (Name) (String)
                 | AlterLogin (Annotation) (Name) (String)
                 | CreateSchema (Annotation) (Name) ((Maybe Name))
                 | AlterSchema (Annotation) (Name) (AlterSchemaOperation)
                 | CreateFunction (Annotation) (Name) (ParamDefList) (TypeName) (Replace) (Language) (FnBody) (Volatility)
                 | CreateDomain (Annotation) (Name) (TypeName) (String) (MaybeBoolExpr)
                 | CreateLanguage (Annotation) (String)
                 | CreateTrigger (Annotation) (NameComponent) (TriggerWhen) (([TriggerEvent])) (Name) (TriggerFire) (Name) (ScalarExprList)
                 | DropFunction (Annotation) (IfExists) (NameTypeNameListPairList) (Cascade)
                 | DropSomething (Annotation) (DropType) (IfExists) (([Name])) (Cascade)
                 | DropTrigger (Annotation) (IfExists) (NameComponent) (Name) (Cascade)
                 | CreateDatabase (Annotation) (Name)
                 | Set (Annotation) (String) (([SetValue]))
                 | Notify (Annotation) (String)
                 | Into (Annotation) (Bool) (([Name])) (Statement)
                 | Assignment (Annotation) (Name) (ScalarExpr)
                 | Return (Annotation) (MaybeScalarExpr)
                 | ReturnNext (Annotation) (ScalarExpr)
                 | ReturnQuery (Annotation) (QueryExpr)
                 | Raise (Annotation) (RaiseType) (String) (ScalarExprList)
                 | NullStatement (Annotation)
                 | Perform (Annotation) (ScalarExpr)
                 | Execute (Annotation) (ScalarExpr)
                 | ForQueryStatement (Annotation) ((Maybe String)) (NameComponent) (QueryExpr) (StatementList)
                 | ForIntegerStatement (Annotation) ((Maybe String)) (NameComponent) (ScalarExpr) (ScalarExpr) (StatementList)
                 | LoopStatement (Annotation) ((Maybe String)) (StatementList)
                 | WhileStatement (Annotation) ((Maybe String)) (ScalarExpr) (StatementList)
                 | ContinueStatement (Annotation) ((Maybe String))
                 | ExitStatement (Annotation) ((Maybe String))
                 | CaseStatementSimple (Annotation) (ScalarExpr) (ScalarExprListStatementListTripleList) (StatementList)
                 | CaseStatement (Annotation) (ScalarExprListStatementListTripleList) (StatementList)
                 | If (Annotation) (ScalarExprStatementListPairList) (StatementList)
                 | Block (Annotation) ((Maybe String)) (VarDefList) (StatementList)
                 | AntiStatement (String)
                 | DeclareStatement (Annotation) (([(String,TypeName,Maybe ScalarExpr)]))
                 | ExecStatement (Annotation) (Name) (ScalarExprList)
                 | CreateIndexTSQL (Annotation) (NameComponent) (Name) (([NameComponent]))
                 deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_Statement :: Statement ->
                   T_Statement
  _sem_Statement (QueryStatement _ann _ex) =
      (_sem_Statement_QueryStatement (_sem_Annotation _ann) (_sem_QueryExpr _ex))
  _sem_Statement (Insert _ann _table _targetCols _insData _returning) =
      (_sem_Statement_Insert (_sem_Annotation _ann) (_sem_Name _table) _targetCols (_sem_QueryExpr _insData) (_sem_MaybeSelectList _returning))
  _sem_Statement (Update _ann _table _assigns _fromList _whr _returning) =
      (_sem_Statement_Update (_sem_Annotation _ann) (_sem_Name _table) (_sem_SetClauseList _assigns) (_sem_TableRefList _fromList) (_sem_MaybeBoolExpr _whr) (_sem_MaybeSelectList _returning))
  _sem_Statement (Delete _ann _table _using _whr _returning) =
      (_sem_Statement_Delete (_sem_Annotation _ann) (_sem_Name _table) (_sem_TableRefList _using) (_sem_MaybeBoolExpr _whr) (_sem_MaybeSelectList _returning))
  _sem_Statement (CopyFrom _ann _table _targetCols _source _opts) =
      (_sem_Statement_CopyFrom (_sem_Annotation _ann) (_sem_Name _table) _targetCols _source _opts)
  _sem_Statement (CopyData _ann _insData) =
      (_sem_Statement_CopyData (_sem_Annotation _ann) _insData)
  _sem_Statement (CopyTo _ann _cp _fn _opts) =
      (_sem_Statement_CopyTo (_sem_Annotation _ann) _cp _fn _opts)
  _sem_Statement (Truncate _ann _tables _restartIdentity _cascade) =
      (_sem_Statement_Truncate (_sem_Annotation _ann) _tables _restartIdentity _cascade)
  _sem_Statement (CreateTable _ann _name _atts _cons _partition _rep _options) =
      (_sem_Statement_CreateTable (_sem_Annotation _ann) (_sem_Name _name) (_sem_AttributeDefList _atts) (_sem_ConstraintList _cons) (_sem_MaybeTablePartitionDef _partition) _rep _options)
  _sem_Statement (AlterTable _ann _name _operation) =
      (_sem_Statement_AlterTable (_sem_Annotation _ann) (_sem_Name _name) (_sem_AlterTableOperation _operation))
  _sem_Statement (AlterDatabase _ann _name _operation) =
      (_sem_Statement_AlterDatabase (_sem_Annotation _ann) (_sem_Name _name) (_sem_AlterDatabaseOperation _operation))
  _sem_Statement (CreateSequence _ann _name _incr _min _max _start _cache) =
      (_sem_Statement_CreateSequence (_sem_Annotation _ann) (_sem_Name _name) _incr _min _max _start _cache)
  _sem_Statement (AlterSequence _ann _name _operation) =
      (_sem_Statement_AlterSequence (_sem_Annotation _ann) (_sem_Name _name) (_sem_AlterSequenceOperation _operation))
  _sem_Statement (CreateTableAs _ann _name _rep _expr) =
      (_sem_Statement_CreateTableAs (_sem_Annotation _ann) (_sem_Name _name) _rep (_sem_QueryExpr _expr))
  _sem_Statement (CreateView _ann _name _colNames _expr) =
      (_sem_Statement_CreateView (_sem_Annotation _ann) (_sem_Name _name) _colNames (_sem_QueryExpr _expr))
  _sem_Statement (AlterView _ann _name _colNames _expr) =
      (_sem_Statement_AlterView (_sem_Annotation _ann) (_sem_Name _name) _colNames (_sem_QueryExpr _expr))
  _sem_Statement (CreateType _ann _name _atts) =
      (_sem_Statement_CreateType (_sem_Annotation _ann) (_sem_Name _name) (_sem_TypeAttributeDefList _atts))
  _sem_Statement (CreateUser _ann _name _password) =
      (_sem_Statement_CreateUser (_sem_Annotation _ann) (_sem_Name _name) _password)
  _sem_Statement (CreateLogin _ann _name _password) =
      (_sem_Statement_CreateLogin (_sem_Annotation _ann) (_sem_Name _name) _password)
  _sem_Statement (AlterUser _ann _name _password) =
      (_sem_Statement_AlterUser (_sem_Annotation _ann) (_sem_Name _name) _password)
  _sem_Statement (AlterLogin _ann _name _password) =
      (_sem_Statement_AlterLogin (_sem_Annotation _ann) (_sem_Name _name) _password)
  _sem_Statement (CreateSchema _ann _name _owner) =
      (_sem_Statement_CreateSchema (_sem_Annotation _ann) (_sem_Name _name) _owner)
  _sem_Statement (AlterSchema _ann _name _operation) =
      (_sem_Statement_AlterSchema (_sem_Annotation _ann) (_sem_Name _name) (_sem_AlterSchemaOperation _operation))
  _sem_Statement (CreateFunction _ann _name _params _rettype _rep _lang _body _vol) =
      (_sem_Statement_CreateFunction (_sem_Annotation _ann) (_sem_Name _name) (_sem_ParamDefList _params) (_sem_TypeName _rettype) _rep _lang (_sem_FnBody _body) _vol)
  _sem_Statement (CreateDomain _ann _name _typ _constraintName _check) =
      (_sem_Statement_CreateDomain (_sem_Annotation _ann) (_sem_Name _name) (_sem_TypeName _typ) _constraintName (_sem_MaybeBoolExpr _check))
  _sem_Statement (CreateLanguage _ann _name) =
      (_sem_Statement_CreateLanguage (_sem_Annotation _ann) _name)
  _sem_Statement (CreateTrigger _ann _name _wh _events _tbl _firing _fnName _fnArgs) =
      (_sem_Statement_CreateTrigger (_sem_Annotation _ann) _name _wh _events (_sem_Name _tbl) _firing (_sem_Name _fnName) (_sem_ScalarExprList _fnArgs))
  _sem_Statement (DropFunction _ann _ifE _sigs _cascade) =
      (_sem_Statement_DropFunction (_sem_Annotation _ann) _ifE (_sem_NameTypeNameListPairList _sigs) _cascade)
  _sem_Statement (DropSomething _ann _dropType _ifE _names _cascade) =
      (_sem_Statement_DropSomething (_sem_Annotation _ann) _dropType _ifE _names _cascade)
  _sem_Statement (DropTrigger _ann _ifE _name _tbl _cascade) =
      (_sem_Statement_DropTrigger (_sem_Annotation _ann) _ifE _name (_sem_Name _tbl) _cascade)
  _sem_Statement (CreateDatabase _ann _nm) =
      (_sem_Statement_CreateDatabase (_sem_Annotation _ann) (_sem_Name _nm))
  _sem_Statement (Set _ann _name _values) =
      (_sem_Statement_Set (_sem_Annotation _ann) _name _values)
  _sem_Statement (Notify _ann _name) =
      (_sem_Statement_Notify (_sem_Annotation _ann) _name)
  _sem_Statement (Into _ann _strict _into _stmt) =
      (_sem_Statement_Into (_sem_Annotation _ann) _strict _into (_sem_Statement _stmt))
  _sem_Statement (Assignment _ann _target _value) =
      (_sem_Statement_Assignment (_sem_Annotation _ann) (_sem_Name _target) (_sem_ScalarExpr _value))
  _sem_Statement (Return _ann _value) =
      (_sem_Statement_Return (_sem_Annotation _ann) (_sem_MaybeScalarExpr _value))
  _sem_Statement (ReturnNext _ann _expr) =
      (_sem_Statement_ReturnNext (_sem_Annotation _ann) (_sem_ScalarExpr _expr))
  _sem_Statement (ReturnQuery _ann _sel) =
      (_sem_Statement_ReturnQuery (_sem_Annotation _ann) (_sem_QueryExpr _sel))
  _sem_Statement (Raise _ann _level _message _args) =
      (_sem_Statement_Raise (_sem_Annotation _ann) _level _message (_sem_ScalarExprList _args))
  _sem_Statement (NullStatement _ann) =
      (_sem_Statement_NullStatement (_sem_Annotation _ann))
  _sem_Statement (Perform _ann _expr) =
      (_sem_Statement_Perform (_sem_Annotation _ann) (_sem_ScalarExpr _expr))
  _sem_Statement (Execute _ann _expr) =
      (_sem_Statement_Execute (_sem_Annotation _ann) (_sem_ScalarExpr _expr))
  _sem_Statement (ForQueryStatement _ann _lb _var _sel _sts) =
      (_sem_Statement_ForQueryStatement (_sem_Annotation _ann) _lb _var (_sem_QueryExpr _sel) (_sem_StatementList _sts))
  _sem_Statement (ForIntegerStatement _ann _lb _var _from _to _sts) =
      (_sem_Statement_ForIntegerStatement (_sem_Annotation _ann) _lb _var (_sem_ScalarExpr _from) (_sem_ScalarExpr _to) (_sem_StatementList _sts))
  _sem_Statement (LoopStatement _ann _lb _sts) =
      (_sem_Statement_LoopStatement (_sem_Annotation _ann) _lb (_sem_StatementList _sts))
  _sem_Statement (WhileStatement _ann _lb _expr _sts) =
      (_sem_Statement_WhileStatement (_sem_Annotation _ann) _lb (_sem_ScalarExpr _expr) (_sem_StatementList _sts))
  _sem_Statement (ContinueStatement _ann _lb) =
      (_sem_Statement_ContinueStatement (_sem_Annotation _ann) _lb)
  _sem_Statement (ExitStatement _ann _lb) =
      (_sem_Statement_ExitStatement (_sem_Annotation _ann) _lb)
  _sem_Statement (CaseStatementSimple _ann _val _cases _els) =
      (_sem_Statement_CaseStatementSimple (_sem_Annotation _ann) (_sem_ScalarExpr _val) (_sem_ScalarExprListStatementListTripleList _cases) (_sem_StatementList _els))
  _sem_Statement (CaseStatement _ann _cases _els) =
      (_sem_Statement_CaseStatement (_sem_Annotation _ann) (_sem_ScalarExprListStatementListTripleList _cases) (_sem_StatementList _els))
  _sem_Statement (If _ann _cases _els) =
      (_sem_Statement_If (_sem_Annotation _ann) (_sem_ScalarExprStatementListPairList _cases) (_sem_StatementList _els))
  _sem_Statement (Block _ann _lb _vars _sts) =
      (_sem_Statement_Block (_sem_Annotation _ann) _lb (_sem_VarDefList _vars) (_sem_StatementList _sts))
  _sem_Statement (AntiStatement _string) =
      (_sem_Statement_AntiStatement _string)
  _sem_Statement (DeclareStatement _ann _ds) =
      (_sem_Statement_DeclareStatement (_sem_Annotation _ann) _ds)
  _sem_Statement (ExecStatement _ann _spName _args) =
      (_sem_Statement_ExecStatement (_sem_Annotation _ann) (_sem_Name _spName) (_sem_ScalarExprList _args))
  _sem_Statement (CreateIndexTSQL _ann _nm _obj _cols) =
      (_sem_Statement_CreateIndexTSQL (_sem_Annotation _ann) _nm (_sem_Name _obj) _cols)
  -- semantic domain
  type T_Statement = Catalog ->
                     TypeCheckFlags ->
                     (Maybe TypeExtra) ->
                     ( Statement,Statement)
  data Inh_Statement = Inh_Statement {_cat_Inh_Statement :: Catalog,_flags_Inh_Statement :: TypeCheckFlags,_imCast_Inh_Statement :: (Maybe TypeExtra)}
  data Syn_Statement = Syn_Statement {_annotatedTree_Syn_Statement :: Statement,_originalTree_Syn_Statement :: Statement}
  _wrap_Statement :: T_Statement ->
                    Inh_Statement ->
                    Syn_Statement
  _wrap_Statement sem (Inh_Statement _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_Statement _lhsOannotatedTree _lhsOoriginalTree))
  _sem_Statement_QueryStatement :: T_Annotation ->
                                  T_QueryExpr ->
                                  T_Statement
  _sem_Statement_QueryStatement ann_ ex_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exOexpectedType :: (Maybe [TypeExtra])
                _exOouterDownEnv :: (Maybe Environment)
                _exOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exOcat :: Catalog
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: QueryExpr
                _exIoriginalTree :: QueryExpr
                _exIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 19807 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 16, column 5)
                _exOexpectedType =
                    ({-# LINE 16 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     liftM (map snd) _exIupType
                     {-# LINE 19813 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 91, column 20)
                _exOouterDownEnv =
                    ({-# LINE 91 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Nothing
                     {-# LINE 19819 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 838, column 32)
                _exOassignmentCastContext =
                    ({-# LINE 838 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 19825 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     QueryStatement _annIannotatedTree _exIannotatedTree
                     {-# LINE 19831 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     QueryStatement _annIoriginalTree _exIoriginalTree
                     {-# LINE 19837 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 19843 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 19849 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 19855 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 19861 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 19867 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 19873 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 19879 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 19885 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOexpectedType _exOflags _exOimCast _exOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Insert :: T_Annotation ->
                          T_Name ->
                          ([NameComponent]) ->
                          T_QueryExpr ->
                          T_MaybeSelectList ->
                          T_Statement
  _sem_Statement_Insert ann_ table_ targetCols_ insData_ returning_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _returningOdownEnv :: Environment
                _tpe :: (Either [TypeError] [TypeExtra])
                _tableOtpe :: (Either [TypeError] TypeExtra)
                _insDataOexpectedType :: (Maybe [TypeExtra])
                _insDataOouterDownEnv :: (Maybe Environment)
                _tooManyCols :: (Maybe [TypeError])
                _insDataOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tableOcat :: Catalog
                _tableOflags :: TypeCheckFlags
                _tableOimCast :: (Maybe TypeExtra)
                _insDataOcat :: Catalog
                _insDataOflags :: TypeCheckFlags
                _insDataOimCast :: (Maybe TypeExtra)
                _returningOcat :: Catalog
                _returningOflags :: TypeCheckFlags
                _returningOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tableIannotatedTree :: Name
                _tableIoriginalTree :: Name
                _insDataIannotatedTree :: QueryExpr
                _insDataIoriginalTree :: QueryExpr
                _insDataIupType :: (Maybe [(Text,TypeExtra)])
                _returningIannotatedTree :: MaybeSelectList
                _returningIoriginalTree :: MaybeSelectList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 19, column 5)
                _annOtpe =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left []
                     {-# LINE 19937 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 22, column 5)
                _returningOdownEnv =
                    ({-# LINE 22 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 19943 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 39, column 5)
                _tpe =
                    ({-# LINE 39 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     do
                     let tnm = nameComponents _tableIoriginalTree
                     (_,pub,_) <- catLookupTableAndAttrs _lhsIcat tnm
                     case targetCols_ of
                          []  -> return $ map snd pub
                          tcs -> do
                                 tcs' <- mapM xnmcString tcs
                                 let utcs' = nub tcs'
                                 when (length utcs' /= length tcs') $
                                     Left $ map DuplicateColumnName
                                          $ nub (tcs' \\ utcs')
                                 forM tcs' $ \x ->
                                     maybe (Left [UnrecognisedIdentifier x])
                                           Right $ lookup x pub
                     {-# LINE 19962 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 58, column 5)
                _tableOtpe =
                    ({-# LINE 58 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left (either id (const []) _tpe
                           ++ maybe [] id _tooManyCols    )
                     {-# LINE 19969 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 61, column 5)
                _insDataOexpectedType =
                    ({-# LINE 61 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 19975 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 63, column 5)
                _insDataOouterDownEnv =
                    ({-# LINE 63 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Nothing
                     {-# LINE 19981 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 68, column 5)
                _tooManyCols =
                    ({-# LINE 68 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     do
                     x <- _insDataIupType
                     y <- either (const Nothing) Just _tpe
                     if (length x > length y)
                         then Just [TooManyColumnsInInsert]
                         else Nothing
                     {-# LINE 19992 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 836, column 24)
                _insDataOassignmentCastContext =
                    ({-# LINE 836 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 19998 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Insert _annIannotatedTree _tableIannotatedTree targetCols_ _insDataIannotatedTree _returningIannotatedTree
                     {-# LINE 20004 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Insert _annIoriginalTree _tableIoriginalTree targetCols_ _insDataIoriginalTree _returningIoriginalTree
                     {-# LINE 20010 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20016 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20022 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20028 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20034 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20040 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20046 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20052 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20058 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _insDataOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20064 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _insDataOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20070 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _insDataOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20076 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20082 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20088 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20094 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tableIannotatedTree,_tableIoriginalTree) =
                    table_ _tableOcat _tableOflags _tableOimCast _tableOtpe
                ( _insDataIannotatedTree,_insDataIoriginalTree,_insDataIupType) =
                    insData_ _insDataOassignmentCastContext _insDataOcat _insDataOexpectedType _insDataOflags _insDataOimCast _insDataOouterDownEnv
                ( _returningIannotatedTree,_returningIoriginalTree) =
                    returning_ _returningOcat _returningOdownEnv _returningOflags _returningOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Update :: T_Annotation ->
                          T_Name ->
                          T_SetClauseList ->
                          T_TableRefList ->
                          T_MaybeBoolExpr ->
                          T_MaybeSelectList ->
                          T_Statement
  _sem_Statement_Update ann_ table_ assigns_ fromList_ whr_ returning_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _tableOtpe :: (Either [TypeError] TypeExtra)
                _whrOdownEnv :: Environment
                _annOtpe :: (Either [TypeError] TypeExtra)
                _returningOdownEnv :: Environment
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tableOcat :: Catalog
                _tableOflags :: TypeCheckFlags
                _tableOimCast :: (Maybe TypeExtra)
                _assignsOcat :: Catalog
                _assignsOflags :: TypeCheckFlags
                _assignsOimCast :: (Maybe TypeExtra)
                _fromListOcat :: Catalog
                _fromListOflags :: TypeCheckFlags
                _fromListOimCast :: (Maybe TypeExtra)
                _whrOcat :: Catalog
                _whrOflags :: TypeCheckFlags
                _whrOimCast :: (Maybe TypeExtra)
                _returningOcat :: Catalog
                _returningOflags :: TypeCheckFlags
                _returningOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tableIannotatedTree :: Name
                _tableIoriginalTree :: Name
                _assignsIannotatedTree :: SetClauseList
                _assignsIoriginalTree :: SetClauseList
                _fromListIannotatedTree :: TableRefList
                _fromListIoriginalTree :: TableRefList
                _fromListIupEnv :: Environment
                _whrIannotatedTree :: MaybeBoolExpr
                _whrIoriginalTree :: MaybeBoolExpr
                _returningIannotatedTree :: MaybeSelectList
                _returningIoriginalTree :: MaybeSelectList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 216, column 24)
                _tableOtpe =
                    ({-# LINE 216 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 20157 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 217, column 24)
                _whrOdownEnv =
                    ({-# LINE 217 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 20163 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 19, column 5)
                _annOtpe =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left []
                     {-# LINE 20169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 22, column 5)
                _returningOdownEnv =
                    ({-# LINE 22 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 20175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Update _annIannotatedTree _tableIannotatedTree _assignsIannotatedTree _fromListIannotatedTree _whrIannotatedTree _returningIannotatedTree
                     {-# LINE 20181 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Update _annIoriginalTree _tableIoriginalTree _assignsIoriginalTree _fromListIoriginalTree _whrIoriginalTree _returningIoriginalTree
                     {-# LINE 20187 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20193 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20199 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20205 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20211 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20217 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20223 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20229 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20235 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _assignsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20241 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _assignsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20247 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _assignsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20253 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fromListOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20259 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fromListOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20265 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fromListOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20271 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _whrOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20277 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _whrOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20283 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _whrOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20289 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20295 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20301 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20307 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tableIannotatedTree,_tableIoriginalTree) =
                    table_ _tableOcat _tableOflags _tableOimCast _tableOtpe
                ( _assignsIannotatedTree,_assignsIoriginalTree) =
                    assigns_ _assignsOcat _assignsOflags _assignsOimCast
                ( _fromListIannotatedTree,_fromListIoriginalTree,_fromListIupEnv) =
                    fromList_ _fromListOcat _fromListOflags _fromListOimCast
                ( _whrIannotatedTree,_whrIoriginalTree) =
                    whr_ _whrOcat _whrOdownEnv _whrOflags _whrOimCast
                ( _returningIannotatedTree,_returningIoriginalTree) =
                    returning_ _returningOcat _returningOdownEnv _returningOflags _returningOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Delete :: T_Annotation ->
                          T_Name ->
                          T_TableRefList ->
                          T_MaybeBoolExpr ->
                          T_MaybeSelectList ->
                          T_Statement
  _sem_Statement_Delete ann_ table_ using_ whr_ returning_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _tableOtpe :: (Either [TypeError] TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _eEnv :: (Either [TypeError] Environment)
                _whrOdownEnv :: Environment
                _returningOdownEnv :: Environment
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tableOcat :: Catalog
                _tableOflags :: TypeCheckFlags
                _tableOimCast :: (Maybe TypeExtra)
                _usingOcat :: Catalog
                _usingOflags :: TypeCheckFlags
                _usingOimCast :: (Maybe TypeExtra)
                _whrOcat :: Catalog
                _whrOflags :: TypeCheckFlags
                _whrOimCast :: (Maybe TypeExtra)
                _returningOcat :: Catalog
                _returningOflags :: TypeCheckFlags
                _returningOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tableIannotatedTree :: Name
                _tableIoriginalTree :: Name
                _usingIannotatedTree :: TableRefList
                _usingIoriginalTree :: TableRefList
                _usingIupEnv :: Environment
                _whrIannotatedTree :: MaybeBoolExpr
                _whrIoriginalTree :: MaybeBoolExpr
                _returningIannotatedTree :: MaybeSelectList
                _returningIoriginalTree :: MaybeSelectList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 168, column 24)
                _tableOtpe =
                    ({-# LINE 168 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 20369 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 19, column 5)
                _annOtpe =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left []
                     {-# LINE 20375 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 26, column 5)
                _eEnv =
                    ({-# LINE 26 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     do
                     head <- E.envCreateTrefEnvironment _lhsIcat (nameComponents _tableIoriginalTree)
                     let rest = _usingIupEnv
                     E.createJoinTrefEnvironment _lhsIcat head rest E.Inner $ Just []
                     {-# LINE 20384 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 31, column 5)
                _downEnv =
                    ({-# LINE 31 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 20390 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 32, column 5)
                _whrOdownEnv =
                    ({-# LINE 32 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     _downEnv
                     {-# LINE 20396 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 33, column 5)
                _returningOdownEnv =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     _downEnv
                     {-# LINE 20402 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Delete _annIannotatedTree _tableIannotatedTree _usingIannotatedTree _whrIannotatedTree _returningIannotatedTree
                     {-# LINE 20408 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Delete _annIoriginalTree _tableIoriginalTree _usingIoriginalTree _whrIoriginalTree _returningIoriginalTree
                     {-# LINE 20414 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20420 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20426 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20432 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20438 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20444 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20450 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20456 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20462 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _usingOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20468 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _usingOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20474 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _usingOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20480 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _whrOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20486 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _whrOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20492 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _whrOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20498 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20504 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20510 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _returningOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20516 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tableIannotatedTree,_tableIoriginalTree) =
                    table_ _tableOcat _tableOflags _tableOimCast _tableOtpe
                ( _usingIannotatedTree,_usingIoriginalTree,_usingIupEnv) =
                    using_ _usingOcat _usingOflags _usingOimCast
                ( _whrIannotatedTree,_whrIoriginalTree) =
                    whr_ _whrOcat _whrOdownEnv _whrOflags _whrOimCast
                ( _returningIannotatedTree,_returningIoriginalTree) =
                    returning_ _returningOcat _returningOdownEnv _returningOflags _returningOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CopyFrom :: T_Annotation ->
                            T_Name ->
                            ([NameComponent]) ->
                            CopyFromSource ->
                            ([CopyFromOption]) ->
                            T_Statement
  _sem_Statement_CopyFrom ann_ table_ targetCols_ source_ opts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _tableOtpe :: (Either [TypeError] TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tableOcat :: Catalog
                _tableOflags :: TypeCheckFlags
                _tableOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tableIannotatedTree :: Name
                _tableIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 135, column 26)
                _tableOtpe =
                    ({-# LINE 135 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 20557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 19, column 5)
                _annOtpe =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left []
                     {-# LINE 20563 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CopyFrom _annIannotatedTree _tableIannotatedTree targetCols_ source_ opts_
                     {-# LINE 20569 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CopyFrom _annIoriginalTree _tableIoriginalTree targetCols_ source_ opts_
                     {-# LINE 20575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20599 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20605 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20611 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20617 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tableOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20623 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tableIannotatedTree,_tableIoriginalTree) =
                    table_ _tableOcat _tableOflags _tableOimCast _tableOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CopyData :: T_Annotation ->
                            String ->
                            T_Statement
  _sem_Statement_CopyData ann_ insData_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 134, column 26)
                _annOtpe =
                    ({-# LINE 134 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 20649 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CopyData _annIannotatedTree insData_
                     {-# LINE 20655 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CopyData _annIoriginalTree insData_
                     {-# LINE 20661 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20667 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20673 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20679 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20685 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20691 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CopyTo :: T_Annotation ->
                          CopyToSource ->
                          String ->
                          ([CopyToOption]) ->
                          T_Statement
  _sem_Statement_CopyTo ann_ cp_ fn_ opts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 19, column 5)
                _annOtpe =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left []
                     {-# LINE 20717 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CopyTo _annIannotatedTree cp_ fn_ opts_
                     {-# LINE 20723 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CopyTo _annIoriginalTree cp_ fn_ opts_
                     {-# LINE 20729 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20735 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20741 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20747 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20753 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20759 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Truncate :: T_Annotation ->
                            ([Name]) ->
                            RestartIdentity ->
                            Cascade ->
                            T_Statement
  _sem_Statement_Truncate ann_ tables_ restartIdentity_ cascade_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag"(line 19, column 5)
                _annOtpe =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Updates.ag" #-}
                     Left []
                     {-# LINE 20785 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Truncate _annIannotatedTree tables_ restartIdentity_ cascade_
                     {-# LINE 20791 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Truncate _annIoriginalTree tables_ restartIdentity_ cascade_
                     {-# LINE 20797 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20803 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20809 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20815 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20821 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20827 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateTable :: T_Annotation ->
                               T_Name ->
                               T_AttributeDefList ->
                               T_ConstraintList ->
                               T_MaybeTablePartitionDef ->
                               Replace ->
                               ([TableOption]) ->
                               T_Statement
  _sem_Statement_CreateTable ann_ name_ atts_ cons_ partition_ rep_ options_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _attsOcat :: Catalog
                _attsOflags :: TypeCheckFlags
                _attsOimCast :: (Maybe TypeExtra)
                _consOcat :: Catalog
                _consOflags :: TypeCheckFlags
                _consOimCast :: (Maybe TypeExtra)
                _partitionOcat :: Catalog
                _partitionOflags :: TypeCheckFlags
                _partitionOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _attsIannotatedTree :: AttributeDefList
                _attsIoriginalTree :: AttributeDefList
                _consIannotatedTree :: ConstraintList
                _consIoriginalTree :: ConstraintList
                _partitionIannotatedTree :: MaybeTablePartitionDef
                _partitionIoriginalTree :: MaybeTablePartitionDef
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 150, column 29)
                _annOtpe =
                    ({-# LINE 150 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 20877 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 151, column 29)
                _nameOtpe =
                    ({-# LINE 151 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 20883 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateTable _annIannotatedTree _nameIannotatedTree _attsIannotatedTree _consIannotatedTree _partitionIannotatedTree rep_ options_
                     {-# LINE 20889 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateTable _annIoriginalTree _nameIoriginalTree _attsIoriginalTree _consIoriginalTree _partitionIoriginalTree rep_ options_
                     {-# LINE 20895 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 20901 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 20907 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20913 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20919 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20925 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20931 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20937 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20943 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20949 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20955 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20961 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _consOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20967 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _consOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20973 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _consOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20979 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 20985 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 20991 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _partitionOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 20997 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _attsIannotatedTree,_attsIoriginalTree) =
                    atts_ _attsOcat _attsOflags _attsOimCast
                ( _consIannotatedTree,_consIoriginalTree) =
                    cons_ _consOcat _consOflags _consOimCast
                ( _partitionIannotatedTree,_partitionIoriginalTree) =
                    partition_ _partitionOcat _partitionOflags _partitionOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterTable :: T_Annotation ->
                              T_Name ->
                              T_AlterTableOperation ->
                              T_Statement
  _sem_Statement_AlterTable ann_ name_ operation_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _operationOcat :: Catalog
                _operationOflags :: TypeCheckFlags
                _operationOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _operationIannotatedTree :: AlterTableOperation
                _operationIoriginalTree :: AlterTableOperation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 115, column 28)
                _annOtpe =
                    ({-# LINE 115 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 116, column 28)
                _nameOtpe =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterTable _annIannotatedTree _nameIannotatedTree _operationIannotatedTree
                     {-# LINE 21053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterTable _annIoriginalTree _nameIoriginalTree _operationIoriginalTree
                     {-# LINE 21059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21095 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21101 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21107 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21113 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21119 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21125 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _operationIannotatedTree,_operationIoriginalTree) =
                    operation_ _operationOcat _operationOflags _operationOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterDatabase :: T_Annotation ->
                                 T_Name ->
                                 T_AlterDatabaseOperation ->
                                 T_Statement
  _sem_Statement_AlterDatabase ann_ name_ operation_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _operationOcat :: Catalog
                _operationOflags :: TypeCheckFlags
                _operationOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _operationIannotatedTree :: AlterDatabaseOperation
                _operationIoriginalTree :: AlterDatabaseOperation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 108, column 31)
                _annOtpe =
                    ({-# LINE 108 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21165 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 109, column 31)
                _nameOtpe =
                    ({-# LINE 109 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21171 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterDatabase _annIannotatedTree _nameIannotatedTree _operationIannotatedTree
                     {-# LINE 21177 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterDatabase _annIoriginalTree _nameIoriginalTree _operationIoriginalTree
                     {-# LINE 21183 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21189 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21195 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21201 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21207 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21213 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21219 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21225 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21231 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21237 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21243 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21249 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _operationIannotatedTree,_operationIoriginalTree) =
                    operation_ _operationOcat _operationOflags _operationOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateSequence :: T_Annotation ->
                                  T_Name ->
                                  Integer ->
                                  (Maybe Integer) ->
                                  (Maybe Integer) ->
                                  Integer ->
                                  Integer ->
                                  T_Statement
  _sem_Statement_CreateSequence ann_ name_ incr_ min_ max_ start_ cache_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 148, column 32)
                _annOtpe =
                    ({-# LINE 148 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21288 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 149, column 32)
                _nameOtpe =
                    ({-# LINE 149 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21294 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateSequence _annIannotatedTree _nameIannotatedTree incr_ min_ max_ start_ cache_
                     {-# LINE 21300 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateSequence _annIoriginalTree _nameIoriginalTree incr_ min_ max_ start_ cache_
                     {-# LINE 21306 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21312 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21318 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21324 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21330 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21336 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21342 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21348 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21354 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterSequence :: T_Annotation ->
                                 T_Name ->
                                 T_AlterSequenceOperation ->
                                 T_Statement
  _sem_Statement_AlterSequence ann_ name_ operation_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _operationOcat :: Catalog
                _operationOflags :: TypeCheckFlags
                _operationOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _operationIannotatedTree :: AlterSequenceOperation
                _operationIoriginalTree :: AlterSequenceOperation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 113, column 31)
                _annOtpe =
                    ({-# LINE 113 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21392 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 114, column 31)
                _nameOtpe =
                    ({-# LINE 114 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21398 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequence _annIannotatedTree _nameIannotatedTree _operationIannotatedTree
                     {-# LINE 21404 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSequence _annIoriginalTree _nameIoriginalTree _operationIoriginalTree
                     {-# LINE 21410 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21416 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21422 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21428 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21434 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21440 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21446 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21452 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21458 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21464 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21470 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21476 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _operationIannotatedTree,_operationIoriginalTree) =
                    operation_ _operationOcat _operationOflags _operationOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateTableAs :: T_Annotation ->
                                 T_Name ->
                                 Replace ->
                                 T_QueryExpr ->
                                 T_Statement
  _sem_Statement_CreateTableAs ann_ name_ rep_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOouterDownEnv :: (Maybe Environment)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _exprOexpectedType :: (Maybe [TypeExtra])
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _exprIannotatedTree :: QueryExpr
                _exprIoriginalTree :: QueryExpr
                _exprIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 152, column 31)
                _annOtpe =
                    ({-# LINE 152 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21521 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 153, column 31)
                _exprOouterDownEnv =
                    ({-# LINE 153 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 21527 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 154, column 31)
                _nameOtpe =
                    ({-# LINE 154 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21533 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 19, column 5)
                _exprOexpectedType =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     liftM (map snd) _exprIupType
                     {-# LINE 21539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 828, column 31)
                _exprOassignmentCastContext =
                    ({-# LINE 828 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 21545 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateTableAs _annIannotatedTree _nameIannotatedTree rep_ _exprIannotatedTree
                     {-# LINE 21551 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateTableAs _annIoriginalTree _nameIoriginalTree rep_ _exprIoriginalTree
                     {-# LINE 21557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21563 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21569 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21599 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21605 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21611 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21617 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21623 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _exprIannotatedTree,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOexpectedType _exprOflags _exprOimCast _exprOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateView :: T_Annotation ->
                              T_Name ->
                              MaybeNameComponentList ->
                              T_QueryExpr ->
                              T_Statement
  _sem_Statement_CreateView ann_ name_ colNames_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOouterDownEnv :: (Maybe Environment)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _exprOexpectedType :: (Maybe [TypeExtra])
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _exprIannotatedTree :: QueryExpr
                _exprIoriginalTree :: QueryExpr
                _exprIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 165, column 28)
                _annOtpe =
                    ({-# LINE 165 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 166, column 28)
                _exprOouterDownEnv =
                    ({-# LINE 166 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 21674 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 167, column 28)
                _nameOtpe =
                    ({-# LINE 167 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21680 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 19, column 5)
                _exprOexpectedType =
                    ({-# LINE 19 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     liftM (map snd) _exprIupType
                     {-# LINE 21686 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 830, column 28)
                _exprOassignmentCastContext =
                    ({-# LINE 830 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 21692 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateView _annIannotatedTree _nameIannotatedTree colNames_ _exprIannotatedTree
                     {-# LINE 21698 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateView _annIoriginalTree _nameIoriginalTree colNames_ _exprIoriginalTree
                     {-# LINE 21704 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21710 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21716 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21722 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21728 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21734 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21740 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21746 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21752 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21758 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21764 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21770 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _exprIannotatedTree,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOexpectedType _exprOflags _exprOimCast _exprOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterView :: T_Annotation ->
                             T_Name ->
                             MaybeNameComponentList ->
                             T_QueryExpr ->
                             T_Statement
  _sem_Statement_AlterView ann_ name_ colNames_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOexpectedType :: (Maybe [TypeExtra])
                _exprOouterDownEnv :: (Maybe Environment)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _exprIannotatedTree :: QueryExpr
                _exprIoriginalTree :: QueryExpr
                _exprIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 119, column 27)
                _annOtpe =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21815 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 120, column 27)
                _exprOexpectedType =
                    ({-# LINE 120 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 21821 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 121, column 27)
                _exprOouterDownEnv =
                    ({-# LINE 121 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 21827 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 122, column 27)
                _nameOtpe =
                    ({-# LINE 122 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21833 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 825, column 27)
                _exprOassignmentCastContext =
                    ({-# LINE 825 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 21839 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterView _annIannotatedTree _nameIannotatedTree colNames_ _exprIannotatedTree
                     {-# LINE 21845 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterView _annIoriginalTree _nameIoriginalTree colNames_ _exprIoriginalTree
                     {-# LINE 21851 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21857 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21863 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21869 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21875 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21881 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21887 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21893 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21899 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21905 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21911 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 21917 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _exprIannotatedTree,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOexpectedType _exprOflags _exprOimCast _exprOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateType :: T_Annotation ->
                              T_Name ->
                              T_TypeAttributeDefList ->
                              T_Statement
  _sem_Statement_CreateType ann_ name_ atts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _attsOcat :: Catalog
                _attsOflags :: TypeCheckFlags
                _attsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _attsIannotatedTree :: TypeAttributeDefList
                _attsIoriginalTree :: TypeAttributeDefList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 161, column 28)
                _annOtpe =
                    ({-# LINE 161 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21957 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 162, column 28)
                _nameOtpe =
                    ({-# LINE 162 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 21963 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateType _annIannotatedTree _nameIannotatedTree _attsIannotatedTree
                     {-# LINE 21969 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateType _annIoriginalTree _nameIoriginalTree _attsIoriginalTree
                     {-# LINE 21975 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 21981 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 21987 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 21993 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 21999 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22005 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22011 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22017 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22023 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22029 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22035 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _attsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _attsIannotatedTree,_attsIoriginalTree) =
                    atts_ _attsOcat _attsOflags _attsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateUser :: T_Annotation ->
                              T_Name ->
                              String ->
                              T_Statement
  _sem_Statement_CreateUser ann_ name_ password_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 163, column 28)
                _annOtpe =
                    ({-# LINE 163 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22076 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 164, column 28)
                _nameOtpe =
                    ({-# LINE 164 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22082 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateUser _annIannotatedTree _nameIannotatedTree password_
                     {-# LINE 22088 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateUser _annIoriginalTree _nameIoriginalTree password_
                     {-# LINE 22094 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22100 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22106 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22112 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22118 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22124 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22130 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22136 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22142 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateLogin :: T_Annotation ->
                               T_Name ->
                               String ->
                               T_Statement
  _sem_Statement_CreateLogin ann_ name_ password_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 145, column 29)
                _annOtpe =
                    ({-# LINE 145 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 146, column 29)
                _nameOtpe =
                    ({-# LINE 146 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22181 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateLogin _annIannotatedTree _nameIannotatedTree password_
                     {-# LINE 22187 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateLogin _annIoriginalTree _nameIoriginalTree password_
                     {-# LINE 22193 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22199 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22205 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22211 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22217 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22223 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22229 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22235 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22241 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterUser :: T_Annotation ->
                             T_Name ->
                             String ->
                             T_Statement
  _sem_Statement_AlterUser ann_ name_ password_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 117, column 27)
                _annOtpe =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22274 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 118, column 27)
                _nameOtpe =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22280 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterUser _annIannotatedTree _nameIannotatedTree password_
                     {-# LINE 22286 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterUser _annIoriginalTree _nameIoriginalTree password_
                     {-# LINE 22292 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22298 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22304 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22310 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22316 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22322 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22328 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22334 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22340 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterLogin :: T_Annotation ->
                              T_Name ->
                              String ->
                              T_Statement
  _sem_Statement_AlterLogin ann_ name_ password_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 110, column 28)
                _annOtpe =
                    ({-# LINE 110 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22373 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 111, column 28)
                _nameOtpe =
                    ({-# LINE 111 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22379 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterLogin _annIannotatedTree _nameIannotatedTree password_
                     {-# LINE 22385 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterLogin _annIoriginalTree _nameIoriginalTree password_
                     {-# LINE 22391 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22397 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22403 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22409 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22415 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22421 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22427 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22433 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22439 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateSchema :: T_Annotation ->
                                T_Name ->
                                (Maybe Name) ->
                                T_Statement
  _sem_Statement_CreateSchema ann_ name_ owner_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 147, column 30)
                _annOtpe =
                    ({-# LINE 147 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22472 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateSchema _annIannotatedTree _nameIannotatedTree owner_
                     {-# LINE 22478 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateSchema _annIoriginalTree _nameIoriginalTree owner_
                     {-# LINE 22484 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22490 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22496 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22502 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22514 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22520 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22526 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22532 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (chain)
                _nameOtpe =
                    ({-# LINE 46 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     error "missing rule: Statement.CreateSchema.name.tpe"
                     {-# LINE 22538 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AlterSchema :: T_Annotation ->
                               T_Name ->
                               T_AlterSchemaOperation ->
                               T_Statement
  _sem_Statement_AlterSchema ann_ name_ operation_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _operationOcat :: Catalog
                _operationOflags :: TypeCheckFlags
                _operationOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _operationIannotatedTree :: AlterSchemaOperation
                _operationIoriginalTree :: AlterSchemaOperation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 112, column 29)
                _annOtpe =
                    ({-# LINE 112 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22576 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSchema _annIannotatedTree _nameIannotatedTree _operationIannotatedTree
                     {-# LINE 22582 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AlterSchema _annIoriginalTree _nameIoriginalTree _operationIoriginalTree
                     {-# LINE 22588 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22594 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22600 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22606 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22612 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22618 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22624 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22630 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22636 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (chain)
                _nameOtpe =
                    ({-# LINE 46 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     error "missing rule: Statement.AlterSchema.name.tpe"
                     {-# LINE 22642 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22648 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22654 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _operationOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22660 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _operationIannotatedTree,_operationIoriginalTree) =
                    operation_ _operationOcat _operationOflags _operationOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateFunction :: T_Annotation ->
                                  T_Name ->
                                  T_ParamDefList ->
                                  T_TypeName ->
                                  Replace ->
                                  Language ->
                                  T_FnBody ->
                                  Volatility ->
                                  T_Statement
  _sem_Statement_CreateFunction ann_ name_ params_ rettype_ rep_ lang_ body_ vol_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _paramsOcat :: Catalog
                _paramsOflags :: TypeCheckFlags
                _paramsOimCast :: (Maybe TypeExtra)
                _rettypeOcat :: Catalog
                _rettypeOflags :: TypeCheckFlags
                _rettypeOimCast :: (Maybe TypeExtra)
                _bodyOcat :: Catalog
                _bodyOflags :: TypeCheckFlags
                _bodyOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _paramsIannotatedTree :: ParamDefList
                _paramsIoriginalTree :: ParamDefList
                _rettypeIannotatedTree :: TypeName
                _rettypeInamedType :: (Maybe TypeExtra)
                _rettypeIoriginalTree :: TypeName
                _bodyIannotatedTree :: FnBody
                _bodyIoriginalTree :: FnBody
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 141, column 32)
                _annOtpe =
                    ({-# LINE 141 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22716 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 142, column 32)
                _nameOtpe =
                    ({-# LINE 142 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22722 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateFunction _annIannotatedTree _nameIannotatedTree _paramsIannotatedTree _rettypeIannotatedTree rep_ lang_ _bodyIannotatedTree vol_
                     {-# LINE 22728 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateFunction _annIoriginalTree _nameIoriginalTree _paramsIoriginalTree _rettypeIoriginalTree rep_ lang_ _bodyIoriginalTree vol_
                     {-# LINE 22734 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22740 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22746 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22752 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22758 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22764 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22770 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22776 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22782 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _paramsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22788 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _paramsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22794 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _paramsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22800 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _rettypeOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22806 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _rettypeOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22812 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _rettypeOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22818 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _bodyOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22824 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _bodyOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22830 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _bodyOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22836 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _paramsIannotatedTree,_paramsIoriginalTree) =
                    params_ _paramsOcat _paramsOflags _paramsOimCast
                ( _rettypeIannotatedTree,_rettypeInamedType,_rettypeIoriginalTree) =
                    rettype_ _rettypeOcat _rettypeOflags _rettypeOimCast
                ( _bodyIannotatedTree,_bodyIoriginalTree) =
                    body_ _bodyOcat _bodyOflags _bodyOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateDomain :: T_Annotation ->
                                T_Name ->
                                T_TypeName ->
                                String ->
                                T_MaybeBoolExpr ->
                                T_Statement
  _sem_Statement_CreateDomain ann_ name_ typ_ constraintName_ check_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _checkOdownEnv :: Environment
                _nameOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nameOcat :: Catalog
                _nameOflags :: TypeCheckFlags
                _nameOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _checkOcat :: Catalog
                _checkOflags :: TypeCheckFlags
                _checkOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nameIannotatedTree :: Name
                _nameIoriginalTree :: Name
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                _checkIannotatedTree :: MaybeBoolExpr
                _checkIoriginalTree :: MaybeBoolExpr
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 138, column 30)
                _annOtpe =
                    ({-# LINE 138 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22889 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 139, column 30)
                _checkOdownEnv =
                    ({-# LINE 139 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 22895 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 140, column 30)
                _nameOtpe =
                    ({-# LINE 140 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 22901 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateDomain _annIannotatedTree _nameIannotatedTree _typIannotatedTree constraintName_ _checkIannotatedTree
                     {-# LINE 22907 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateDomain _annIoriginalTree _nameIoriginalTree _typIoriginalTree constraintName_ _checkIoriginalTree
                     {-# LINE 22913 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 22919 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 22925 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22931 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22937 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22943 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22949 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22955 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22961 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22967 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22973 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22979 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _checkOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 22985 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _checkOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 22991 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _checkOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 22997 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nameIannotatedTree,_nameIoriginalTree) =
                    name_ _nameOcat _nameOflags _nameOimCast _nameOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
                ( _checkIannotatedTree,_checkIoriginalTree) =
                    check_ _checkOcat _checkOdownEnv _checkOflags _checkOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateLanguage :: T_Annotation ->
                                  String ->
                                  T_Statement
  _sem_Statement_CreateLanguage ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 144, column 32)
                _annOtpe =
                    ({-# LINE 144 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23027 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateLanguage _annIannotatedTree name_
                     {-# LINE 23033 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateLanguage _annIoriginalTree name_
                     {-# LINE 23039 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23045 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23051 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23057 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23063 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23069 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateTrigger :: T_Annotation ->
                                 NameComponent ->
                                 TriggerWhen ->
                                 ([TriggerEvent]) ->
                                 T_Name ->
                                 TriggerFire ->
                                 T_Name ->
                                 T_ScalarExprList ->
                                 T_Statement
  _sem_Statement_CreateTrigger ann_ name_ wh_ events_ tbl_ firing_ fnName_ fnArgs_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _fnArgsOdownEnv :: Environment
                _fnArgsOexpectedCast :: Bool
                _fnArgsOexpectedTypes :: ([TypeExtra])
                _fnNameOtpe :: (Either [TypeError] TypeExtra)
                _tblOtpe :: (Either [TypeError] TypeExtra)
                _fnArgsOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tblOcat :: Catalog
                _tblOflags :: TypeCheckFlags
                _tblOimCast :: (Maybe TypeExtra)
                _fnNameOcat :: Catalog
                _fnNameOflags :: TypeCheckFlags
                _fnNameOimCast :: (Maybe TypeExtra)
                _fnArgsOcat :: Catalog
                _fnArgsOflags :: TypeCheckFlags
                _fnArgsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tblIannotatedTree :: Name
                _tblIoriginalTree :: Name
                _fnNameIannotatedTree :: Name
                _fnNameIoriginalTree :: Name
                _fnArgsIannotatedTree :: ScalarExprList
                _fnArgsIoriginalTree :: ScalarExprList
                _fnArgsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 155, column 31)
                _annOtpe =
                    ({-# LINE 155 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23121 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 156, column 31)
                _fnArgsOdownEnv =
                    ({-# LINE 156 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 23127 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 157, column 31)
                _fnArgsOexpectedCast =
                    ({-# LINE 157 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 23133 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 158, column 31)
                _fnArgsOexpectedTypes =
                    ({-# LINE 158 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     []
                     {-# LINE 23139 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 159, column 31)
                _fnNameOtpe =
                    ({-# LINE 159 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23145 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 160, column 31)
                _tblOtpe =
                    ({-# LINE 160 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23151 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 829, column 31)
                _fnArgsOassignmentCastContext =
                    ({-# LINE 829 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 23157 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateTrigger _annIannotatedTree name_ wh_ events_ _tblIannotatedTree firing_ _fnNameIannotatedTree _fnArgsIannotatedTree
                     {-# LINE 23163 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateTrigger _annIoriginalTree name_ wh_ events_ _tblIoriginalTree firing_ _fnNameIoriginalTree _fnArgsIoriginalTree
                     {-# LINE 23169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23181 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23187 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23193 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23199 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23205 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23211 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23217 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23223 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23229 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23235 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnArgsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23241 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnArgsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23247 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnArgsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23253 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tblIannotatedTree,_tblIoriginalTree) =
                    tbl_ _tblOcat _tblOflags _tblOimCast _tblOtpe
                ( _fnNameIannotatedTree,_fnNameIoriginalTree) =
                    fnName_ _fnNameOcat _fnNameOflags _fnNameOimCast _fnNameOtpe
                ( _fnArgsIannotatedTree,_fnArgsIoriginalTree,_fnArgsIupTypes) =
                    fnArgs_ _fnArgsOassignmentCastContext _fnArgsOcat _fnArgsOdownEnv _fnArgsOexpectedCast _fnArgsOexpectedTypes _fnArgsOflags _fnArgsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_DropFunction :: T_Annotation ->
                                IfExists ->
                                T_NameTypeNameListPairList ->
                                Cascade ->
                                T_Statement
  _sem_Statement_DropFunction ann_ ifE_ sigs_ cascade_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _sigsOcat :: Catalog
                _sigsOflags :: TypeCheckFlags
                _sigsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _sigsIannotatedTree :: NameTypeNameListPairList
                _sigsIoriginalTree :: NameTypeNameListPairList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 169, column 30)
                _annOtpe =
                    ({-# LINE 169 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23290 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropFunction _annIannotatedTree ifE_ _sigsIannotatedTree cascade_
                     {-# LINE 23296 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropFunction _annIoriginalTree ifE_ _sigsIoriginalTree cascade_
                     {-# LINE 23302 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23308 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23314 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23320 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23326 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23332 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _sigsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23338 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _sigsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23344 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _sigsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23350 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _sigsIannotatedTree,_sigsIoriginalTree) =
                    sigs_ _sigsOcat _sigsOflags _sigsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_DropSomething :: T_Annotation ->
                                 DropType ->
                                 IfExists ->
                                 ([Name]) ->
                                 Cascade ->
                                 T_Statement
  _sem_Statement_DropSomething ann_ dropType_ ifE_ names_ cascade_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 23379 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropSomething _annIannotatedTree dropType_ ifE_ names_ cascade_
                     {-# LINE 23385 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropSomething _annIoriginalTree dropType_ ifE_ names_ cascade_
                     {-# LINE 23391 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23397 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23403 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23409 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23415 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23421 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_DropTrigger :: T_Annotation ->
                               IfExists ->
                               NameComponent ->
                               T_Name ->
                               Cascade ->
                               T_Statement
  _sem_Statement_DropTrigger ann_ ifE_ name_ tbl_ cascade_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _tblOtpe :: (Either [TypeError] TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tblOcat :: Catalog
                _tblOflags :: TypeCheckFlags
                _tblOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tblIannotatedTree :: Name
                _tblIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 170, column 29)
                _tblOtpe =
                    ({-# LINE 170 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23454 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 23460 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropTrigger _annIannotatedTree ifE_ name_ _tblIannotatedTree cascade_
                     {-# LINE 23466 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DropTrigger _annIoriginalTree ifE_ name_ _tblIoriginalTree cascade_
                     {-# LINE 23472 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23478 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23484 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23490 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23496 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23502 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23514 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23520 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tblIannotatedTree,_tblIoriginalTree) =
                    tbl_ _tblOcat _tblOflags _tblOimCast _tblOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateDatabase :: T_Annotation ->
                                  T_Name ->
                                  T_Statement
  _sem_Statement_CreateDatabase ann_ nm_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _nmOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _nmOcat :: Catalog
                _nmOflags :: TypeCheckFlags
                _nmOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _nmIannotatedTree :: Name
                _nmIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 136, column 32)
                _annOtpe =
                    ({-# LINE 136 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23552 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 137, column 32)
                _nmOtpe =
                    ({-# LINE 137 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23558 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateDatabase _annIannotatedTree _nmIannotatedTree
                     {-# LINE 23564 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateDatabase _annIoriginalTree _nmIoriginalTree
                     {-# LINE 23570 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23576 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23582 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23588 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23594 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23600 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nmOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23606 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nmOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23612 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _nmOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23618 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _nmIannotatedTree,_nmIoriginalTree) =
                    nm_ _nmOcat _nmOflags _nmOimCast _nmOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Set :: T_Annotation ->
                       String ->
                       ([SetValue]) ->
                       T_Statement
  _sem_Statement_Set ann_ name_ values_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 215, column 21)
                _annOtpe =
                    ({-# LINE 215 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23645 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Set _annIannotatedTree name_ values_
                     {-# LINE 23651 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Set _annIoriginalTree name_ values_
                     {-# LINE 23657 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23663 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23669 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23675 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23681 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23687 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Notify :: T_Annotation ->
                          String ->
                          T_Statement
  _sem_Statement_Notify ann_ name_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 193, column 24)
                _annOtpe =
                    ({-# LINE 193 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 23711 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Notify _annIannotatedTree name_
                     {-# LINE 23717 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Notify _annIoriginalTree name_
                     {-# LINE 23723 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23729 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23735 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23741 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23747 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23753 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Into :: T_Annotation ->
                        Bool ->
                        ([Name]) ->
                        T_Statement ->
                        T_Statement
  _sem_Statement_Into ann_ strict_ into_ stmt_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _stmtOcat :: Catalog
                _stmtOflags :: TypeCheckFlags
                _stmtOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _stmtIannotatedTree :: Statement
                _stmtIoriginalTree :: Statement
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 23784 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Into _annIannotatedTree strict_ into_ _stmtIannotatedTree
                     {-# LINE 23790 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Into _annIoriginalTree strict_ into_ _stmtIoriginalTree
                     {-# LINE 23796 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23802 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23808 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23814 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23820 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23826 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stmtOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23832 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stmtOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23838 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stmtOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23844 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _stmtIannotatedTree,_stmtIoriginalTree) =
                    stmt_ _stmtOcat _stmtOflags _stmtOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Assignment :: T_Annotation ->
                              T_Name ->
                              T_ScalarExpr ->
                              T_Statement
  _sem_Statement_Assignment ann_ target_ value_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _valueOexpectedCast :: Bool
                _valueOexpectedType :: (Maybe TypeExtra)
                _valueOodbcFunction :: Bool
                _annOtpe :: (Either [TypeError] TypeExtra)
                _targetOtpe :: (Either [TypeError] TypeExtra)
                _valueOdownEnv :: Environment
                _valueOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _targetOcat :: Catalog
                _targetOflags :: TypeCheckFlags
                _targetOimCast :: (Maybe TypeExtra)
                _valueOcat :: Catalog
                _valueOflags :: TypeCheckFlags
                _valueOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _targetIannotatedTree :: Name
                _targetIoriginalTree :: Name
                _valueIannotatedTree :: ScalarExpr
                _valueIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _valueIoriginalTree :: ScalarExpr
                _valueIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 123, column 28)
                _valueOexpectedCast =
                    ({-# LINE 123 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 23889 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 124, column 28)
                _valueOexpectedType =
                    ({-# LINE 124 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 23895 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 125, column 28)
                _valueOodbcFunction =
                    ({-# LINE 125 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 23901 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 23907 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 26, column 5)
                _targetOtpe =
                    ({-# LINE 26 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 23913 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 27, column 5)
                _valueOdownEnv =
                    ({-# LINE 27 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 23919 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 826, column 28)
                _valueOassignmentCastContext =
                    ({-# LINE 826 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 23925 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Assignment _annIannotatedTree _targetIannotatedTree _valueIannotatedTree
                     {-# LINE 23931 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Assignment _annIoriginalTree _targetIoriginalTree _valueIoriginalTree
                     {-# LINE 23937 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 23943 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 23949 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23955 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23961 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23967 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _targetOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23973 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _targetOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23979 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _targetOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 23985 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 23991 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 23997 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24003 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _targetIannotatedTree,_targetIoriginalTree) =
                    target_ _targetOcat _targetOflags _targetOimCast _targetOtpe
                ( _valueIannotatedTree,_valueIcolExprs,_valueIoriginalTree,_valueIupType) =
                    value_ _valueOassignmentCastContext _valueOcat _valueOdownEnv _valueOexpectedCast _valueOexpectedType _valueOflags _valueOimCast _valueOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Return :: T_Annotation ->
                          T_MaybeScalarExpr ->
                          T_Statement
  _sem_Statement_Return ann_ value_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _valueOdownEnv :: Environment
                _valueOexpectedCast :: Bool
                _valueOexpectedType :: (Maybe TypeExtra)
                _valueOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _valueOcat :: Catalog
                _valueOflags :: TypeCheckFlags
                _valueOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _valueIannotatedTree :: MaybeScalarExpr
                _valueIoriginalTree :: MaybeScalarExpr
                _valueIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 204, column 24)
                _annOtpe =
                    ({-# LINE 204 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 205, column 24)
                _valueOdownEnv =
                    ({-# LINE 205 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 24047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 206, column 24)
                _valueOexpectedCast =
                    ({-# LINE 206 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 207, column 24)
                _valueOexpectedType =
                    ({-# LINE 207 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 24059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 840, column 24)
                _valueOassignmentCastContext =
                    ({-# LINE 840 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Return _annIannotatedTree _valueIannotatedTree
                     {-# LINE 24071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Return _annIoriginalTree _valueIoriginalTree
                     {-# LINE 24077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24095 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24101 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24107 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24113 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24119 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valueOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24125 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _valueIannotatedTree,_valueIoriginalTree,_valueIupType) =
                    value_ _valueOassignmentCastContext _valueOcat _valueOdownEnv _valueOexpectedCast _valueOexpectedType _valueOflags _valueOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ReturnNext :: T_Annotation ->
                              T_ScalarExpr ->
                              T_Statement
  _sem_Statement_ReturnNext ann_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 208, column 28)
                _annOtpe =
                    ({-# LINE 208 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24163 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 209, column 28)
                _exprOdownEnv =
                    ({-# LINE 209 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 24169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 210, column 28)
                _exprOexpectedCast =
                    ({-# LINE 210 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 211, column 28)
                _exprOexpectedType =
                    ({-# LINE 211 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 24181 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 212, column 28)
                _exprOodbcFunction =
                    ({-# LINE 212 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24187 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 841, column 28)
                _exprOassignmentCastContext =
                    ({-# LINE 841 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24193 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ReturnNext _annIannotatedTree _exprIannotatedTree
                     {-# LINE 24199 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ReturnNext _annIoriginalTree _exprIoriginalTree
                     {-# LINE 24205 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24211 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24217 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24223 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24229 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24235 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24241 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24247 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24253 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ReturnQuery :: T_Annotation ->
                               T_QueryExpr ->
                               T_Statement
  _sem_Statement_ReturnQuery ann_ sel_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _selOouterDownEnv :: (Maybe Environment)
                _selOexpectedType :: (Maybe [TypeExtra])
                _selOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _selOcat :: Catalog
                _selOflags :: TypeCheckFlags
                _selOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selIannotatedTree :: QueryExpr
                _selIoriginalTree :: QueryExpr
                _selIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 213, column 29)
                _annOtpe =
                    ({-# LINE 213 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24288 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 214, column 29)
                _selOouterDownEnv =
                    ({-# LINE 214 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 24294 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 22, column 5)
                _selOexpectedType =
                    ({-# LINE 22 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     liftM (map snd) _selIupType
                     {-# LINE 24300 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 842, column 29)
                _selOassignmentCastContext =
                    ({-# LINE 842 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24306 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ReturnQuery _annIannotatedTree _selIannotatedTree
                     {-# LINE 24312 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ReturnQuery _annIoriginalTree _selIoriginalTree
                     {-# LINE 24318 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24324 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24330 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24336 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24342 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24348 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24354 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24360 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24366 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selIannotatedTree,_selIoriginalTree,_selIupType) =
                    sel_ _selOassignmentCastContext _selOcat _selOexpectedType _selOflags _selOimCast _selOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Raise :: T_Annotation ->
                         RaiseType ->
                         String ->
                         T_ScalarExprList ->
                         T_Statement
  _sem_Statement_Raise ann_ level_ message_ args_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _argsOdownEnv :: Environment
                _argsOexpectedCast :: Bool
                _argsOexpectedTypes :: ([TypeExtra])
                _argsOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _argsOcat :: Catalog
                _argsOflags :: TypeCheckFlags
                _argsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _argsIannotatedTree :: ScalarExprList
                _argsIoriginalTree :: ScalarExprList
                _argsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 200, column 23)
                _annOtpe =
                    ({-# LINE 200 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24404 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 201, column 23)
                _argsOdownEnv =
                    ({-# LINE 201 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 24410 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 202, column 23)
                _argsOexpectedCast =
                    ({-# LINE 202 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24416 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 203, column 23)
                _argsOexpectedTypes =
                    ({-# LINE 203 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     []
                     {-# LINE 24422 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 839, column 23)
                _argsOassignmentCastContext =
                    ({-# LINE 839 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24428 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Raise _annIannotatedTree level_ message_ _argsIannotatedTree
                     {-# LINE 24434 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Raise _annIoriginalTree level_ message_ _argsIoriginalTree
                     {-# LINE 24440 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24446 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24452 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24458 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24464 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24470 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24476 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24482 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24488 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _argsIannotatedTree,_argsIoriginalTree,_argsIupTypes) =
                    args_ _argsOassignmentCastContext _argsOcat _argsOdownEnv _argsOexpectedCast _argsOexpectedTypes _argsOflags _argsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_NullStatement :: T_Annotation ->
                                 T_Statement
  _sem_Statement_NullStatement ann_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 194, column 31)
                _annOtpe =
                    ({-# LINE 194 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24513 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NullStatement _annIannotatedTree
                     {-# LINE 24519 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     NullStatement _annIoriginalTree
                     {-# LINE 24525 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24531 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24537 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24543 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24549 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24555 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Perform :: T_Annotation ->
                           T_ScalarExpr ->
                           T_Statement
  _sem_Statement_Perform ann_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 195, column 25)
                _annOtpe =
                    ({-# LINE 195 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24591 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 196, column 25)
                _exprOdownEnv =
                    ({-# LINE 196 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 24597 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 197, column 25)
                _exprOexpectedCast =
                    ({-# LINE 197 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24603 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 198, column 25)
                _exprOexpectedType =
                    ({-# LINE 198 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 24609 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 199, column 25)
                _exprOodbcFunction =
                    ({-# LINE 199 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24615 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 837, column 25)
                _exprOassignmentCastContext =
                    ({-# LINE 837 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24621 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Perform _annIannotatedTree _exprIannotatedTree
                     {-# LINE 24627 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Perform _annIoriginalTree _exprIoriginalTree
                     {-# LINE 24633 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24639 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24645 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24651 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24657 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24663 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24669 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24675 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24681 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Execute :: T_Annotation ->
                           T_ScalarExpr ->
                           T_Statement
  _sem_Statement_Execute ann_ expr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 175, column 25)
                _annOtpe =
                    ({-# LINE 175 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24719 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 176, column 25)
                _exprOdownEnv =
                    ({-# LINE 176 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 24725 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 177, column 25)
                _exprOexpectedCast =
                    ({-# LINE 177 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24731 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 178, column 25)
                _exprOexpectedType =
                    ({-# LINE 178 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 24737 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 179, column 25)
                _exprOodbcFunction =
                    ({-# LINE 179 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 24743 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 832, column 25)
                _exprOassignmentCastContext =
                    ({-# LINE 832 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24749 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Execute _annIannotatedTree _exprIannotatedTree
                     {-# LINE 24755 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Execute _annIoriginalTree _exprIoriginalTree
                     {-# LINE 24761 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24767 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24773 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24779 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24785 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24791 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24797 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24803 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24809 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ForQueryStatement :: T_Annotation ->
                                     (Maybe String) ->
                                     NameComponent ->
                                     T_QueryExpr ->
                                     T_StatementList ->
                                     T_Statement
  _sem_Statement_ForQueryStatement ann_ lb_ var_ sel_ sts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _selOouterDownEnv :: (Maybe Environment)
                _selOexpectedType :: (Maybe [TypeExtra])
                _selOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _selOcat :: Catalog
                _selOflags :: TypeCheckFlags
                _selOimCast :: (Maybe TypeExtra)
                _stsOcat :: Catalog
                _stsOflags :: TypeCheckFlags
                _stsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selIannotatedTree :: QueryExpr
                _selIoriginalTree :: QueryExpr
                _selIupType :: (Maybe [(Text,TypeExtra)])
                _stsIannotatedTree :: StatementList
                _stsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 190, column 35)
                _annOtpe =
                    ({-# LINE 190 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 24852 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 191, column 35)
                _selOouterDownEnv =
                    ({-# LINE 191 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 24858 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 22, column 5)
                _selOexpectedType =
                    ({-# LINE 22 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     liftM (map snd) _selIupType
                     {-# LINE 24864 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 835, column 35)
                _selOassignmentCastContext =
                    ({-# LINE 835 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 24870 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ForQueryStatement _annIannotatedTree lb_ var_ _selIannotatedTree _stsIannotatedTree
                     {-# LINE 24876 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ForQueryStatement _annIoriginalTree lb_ var_ _selIoriginalTree _stsIoriginalTree
                     {-# LINE 24882 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 24888 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 24894 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24900 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24906 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24912 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24918 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24924 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24930 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 24936 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 24942 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 24948 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selIannotatedTree,_selIoriginalTree,_selIupType) =
                    sel_ _selOassignmentCastContext _selOcat _selOexpectedType _selOflags _selOimCast _selOouterDownEnv
                ( _stsIannotatedTree,_stsIoriginalTree) =
                    sts_ _stsOcat _stsOflags _stsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ForIntegerStatement :: T_Annotation ->
                                       (Maybe String) ->
                                       NameComponent ->
                                       T_ScalarExpr ->
                                       T_ScalarExpr ->
                                       T_StatementList ->
                                       T_Statement
  _sem_Statement_ForIntegerStatement ann_ lb_ var_ from_ to_ sts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _fromOdownEnv :: Environment
                _fromOexpectedCast :: Bool
                _fromOexpectedType :: (Maybe TypeExtra)
                _fromOodbcFunction :: Bool
                _toOdownEnv :: Environment
                _toOexpectedCast :: Bool
                _toOexpectedType :: (Maybe TypeExtra)
                _toOodbcFunction :: Bool
                _fromOassignmentCastContext :: Bool
                _toOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _fromOcat :: Catalog
                _fromOflags :: TypeCheckFlags
                _fromOimCast :: (Maybe TypeExtra)
                _toOcat :: Catalog
                _toOflags :: TypeCheckFlags
                _toOimCast :: (Maybe TypeExtra)
                _stsOcat :: Catalog
                _stsOflags :: TypeCheckFlags
                _stsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _fromIannotatedTree :: ScalarExpr
                _fromIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _fromIoriginalTree :: ScalarExpr
                _fromIupType :: (Maybe TypeExtra)
                _toIannotatedTree :: ScalarExpr
                _toIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _toIoriginalTree :: ScalarExpr
                _toIupType :: (Maybe TypeExtra)
                _stsIannotatedTree :: StatementList
                _stsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 181, column 37)
                _annOtpe =
                    ({-# LINE 181 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25009 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 182, column 37)
                _fromOdownEnv =
                    ({-# LINE 182 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 25015 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 183, column 37)
                _fromOexpectedCast =
                    ({-# LINE 183 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25021 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 184, column 37)
                _fromOexpectedType =
                    ({-# LINE 184 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 25027 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 185, column 37)
                _fromOodbcFunction =
                    ({-# LINE 185 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25033 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 186, column 37)
                _toOdownEnv =
                    ({-# LINE 186 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 25039 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 187, column 37)
                _toOexpectedCast =
                    ({-# LINE 187 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25045 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 188, column 37)
                _toOexpectedType =
                    ({-# LINE 188 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 25051 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 189, column 37)
                _toOodbcFunction =
                    ({-# LINE 189 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25057 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 833, column 37)
                _fromOassignmentCastContext =
                    ({-# LINE 833 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 25063 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 834, column 37)
                _toOassignmentCastContext =
                    ({-# LINE 834 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 25069 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ForIntegerStatement _annIannotatedTree lb_ var_ _fromIannotatedTree _toIannotatedTree _stsIannotatedTree
                     {-# LINE 25075 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ForIntegerStatement _annIoriginalTree lb_ var_ _fromIoriginalTree _toIoriginalTree _stsIoriginalTree
                     {-# LINE 25081 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25087 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25093 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fromOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fromOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25123 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fromOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25129 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _toOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25135 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _toOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25141 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _toOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25147 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25153 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25159 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25165 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _fromIannotatedTree,_fromIcolExprs,_fromIoriginalTree,_fromIupType) =
                    from_ _fromOassignmentCastContext _fromOcat _fromOdownEnv _fromOexpectedCast _fromOexpectedType _fromOflags _fromOimCast _fromOodbcFunction
                ( _toIannotatedTree,_toIcolExprs,_toIoriginalTree,_toIupType) =
                    to_ _toOassignmentCastContext _toOcat _toOdownEnv _toOexpectedCast _toOexpectedType _toOflags _toOimCast _toOodbcFunction
                ( _stsIannotatedTree,_stsIoriginalTree) =
                    sts_ _stsOcat _stsOflags _stsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_LoopStatement :: T_Annotation ->
                                 (Maybe String) ->
                                 T_StatementList ->
                                 T_Statement
  _sem_Statement_LoopStatement ann_ lb_ sts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _stsOcat :: Catalog
                _stsOflags :: TypeCheckFlags
                _stsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _stsIannotatedTree :: StatementList
                _stsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 192, column 31)
                _annOtpe =
                    ({-# LINE 192 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25201 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     LoopStatement _annIannotatedTree lb_ _stsIannotatedTree
                     {-# LINE 25207 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     LoopStatement _annIoriginalTree lb_ _stsIoriginalTree
                     {-# LINE 25213 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25219 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25225 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25231 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25237 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25243 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25249 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25255 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25261 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _stsIannotatedTree,_stsIoriginalTree) =
                    sts_ _stsOcat _stsOflags _stsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_WhileStatement :: T_Annotation ->
                                  (Maybe String) ->
                                  T_ScalarExpr ->
                                  T_StatementList ->
                                  T_Statement
  _sem_Statement_WhileStatement ann_ lb_ expr_ sts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _exprOdownEnv :: Environment
                _exprOexpectedCast :: Bool
                _exprOexpectedType :: (Maybe TypeExtra)
                _exprOodbcFunction :: Bool
                _exprOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exprOcat :: Catalog
                _exprOflags :: TypeCheckFlags
                _exprOimCast :: (Maybe TypeExtra)
                _stsOcat :: Catalog
                _stsOflags :: TypeCheckFlags
                _stsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exprIannotatedTree :: ScalarExpr
                _exprIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _exprIoriginalTree :: ScalarExpr
                _exprIupType :: (Maybe TypeExtra)
                _stsIannotatedTree :: StatementList
                _stsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 218, column 32)
                _annOtpe =
                    ({-# LINE 218 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25306 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 219, column 32)
                _exprOdownEnv =
                    ({-# LINE 219 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 25312 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 220, column 32)
                _exprOexpectedCast =
                    ({-# LINE 220 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25318 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 221, column 32)
                _exprOexpectedType =
                    ({-# LINE 221 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 25324 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 222, column 32)
                _exprOodbcFunction =
                    ({-# LINE 222 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25330 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 843, column 32)
                _exprOassignmentCastContext =
                    ({-# LINE 843 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 25336 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WhileStatement _annIannotatedTree lb_ _exprIannotatedTree _stsIannotatedTree
                     {-# LINE 25342 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WhileStatement _annIoriginalTree lb_ _exprIoriginalTree _stsIoriginalTree
                     {-# LINE 25348 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25354 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25360 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25366 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25372 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25378 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25384 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25390 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25396 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25402 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25408 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25414 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exprIannotatedTree,_exprIcolExprs,_exprIoriginalTree,_exprIupType) =
                    expr_ _exprOassignmentCastContext _exprOcat _exprOdownEnv _exprOexpectedCast _exprOexpectedType _exprOflags _exprOimCast _exprOodbcFunction
                ( _stsIannotatedTree,_stsIoriginalTree) =
                    sts_ _stsOcat _stsOflags _stsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ContinueStatement :: T_Annotation ->
                                     (Maybe String) ->
                                     T_Statement
  _sem_Statement_ContinueStatement ann_ lb_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 133, column 35)
                _annOtpe =
                    ({-# LINE 133 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25442 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ContinueStatement _annIannotatedTree lb_
                     {-# LINE 25448 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ContinueStatement _annIoriginalTree lb_
                     {-# LINE 25454 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25460 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25466 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25472 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25478 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25484 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ExitStatement :: T_Annotation ->
                                 (Maybe String) ->
                                 T_Statement
  _sem_Statement_ExitStatement ann_ lb_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 180, column 31)
                _annOtpe =
                    ({-# LINE 180 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ExitStatement _annIannotatedTree lb_
                     {-# LINE 25514 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ExitStatement _annIoriginalTree lb_
                     {-# LINE 25520 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25526 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25532 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25538 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25544 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25550 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CaseStatementSimple :: T_Annotation ->
                                       T_ScalarExpr ->
                                       T_ScalarExprListStatementListTripleList ->
                                       T_StatementList ->
                                       T_Statement
  _sem_Statement_CaseStatementSimple ann_ val_ cases_ els_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _valOdownEnv :: Environment
                _valOexpectedCast :: Bool
                _valOexpectedType :: (Maybe TypeExtra)
                _valOodbcFunction :: Bool
                _valOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _valOcat :: Catalog
                _valOflags :: TypeCheckFlags
                _valOimCast :: (Maybe TypeExtra)
                _casesOcat :: Catalog
                _casesOflags :: TypeCheckFlags
                _casesOimCast :: (Maybe TypeExtra)
                _elsOcat :: Catalog
                _elsOflags :: TypeCheckFlags
                _elsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _valIannotatedTree :: ScalarExpr
                _valIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _valIoriginalTree :: ScalarExpr
                _valIupType :: (Maybe TypeExtra)
                _casesIannotatedTree :: ScalarExprListStatementListTripleList
                _casesIoriginalTree :: ScalarExprListStatementListTripleList
                _elsIannotatedTree :: StatementList
                _elsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 128, column 37)
                _annOtpe =
                    ({-# LINE 128 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25598 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 129, column 37)
                _valOdownEnv =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 25604 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 130, column 37)
                _valOexpectedCast =
                    ({-# LINE 130 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25610 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 131, column 37)
                _valOexpectedType =
                    ({-# LINE 131 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 25616 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 132, column 37)
                _valOodbcFunction =
                    ({-# LINE 132 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 25622 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 827, column 37)
                _valOassignmentCastContext =
                    ({-# LINE 827 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 25628 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CaseStatementSimple _annIannotatedTree _valIannotatedTree _casesIannotatedTree _elsIannotatedTree
                     {-# LINE 25634 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CaseStatementSimple _annIoriginalTree _valIoriginalTree _casesIoriginalTree _elsIoriginalTree
                     {-# LINE 25640 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25646 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25652 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25658 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25664 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25670 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25676 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25682 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _valOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25688 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25694 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25700 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25706 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25712 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25718 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25724 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _valIannotatedTree,_valIcolExprs,_valIoriginalTree,_valIupType) =
                    val_ _valOassignmentCastContext _valOcat _valOdownEnv _valOexpectedCast _valOexpectedType _valOflags _valOimCast _valOodbcFunction
                ( _casesIannotatedTree,_casesIoriginalTree) =
                    cases_ _casesOcat _casesOflags _casesOimCast
                ( _elsIannotatedTree,_elsIoriginalTree) =
                    els_ _elsOcat _elsOflags _elsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CaseStatement :: T_Annotation ->
                                 T_ScalarExprListStatementListTripleList ->
                                 T_StatementList ->
                                 T_Statement
  _sem_Statement_CaseStatement ann_ cases_ els_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _casesOcat :: Catalog
                _casesOflags :: TypeCheckFlags
                _casesOimCast :: (Maybe TypeExtra)
                _elsOcat :: Catalog
                _elsOflags :: TypeCheckFlags
                _elsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _casesIannotatedTree :: ScalarExprListStatementListTripleList
                _casesIoriginalTree :: ScalarExprListStatementListTripleList
                _elsIannotatedTree :: StatementList
                _elsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 127, column 31)
                _annOtpe =
                    ({-# LINE 127 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 25765 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CaseStatement _annIannotatedTree _casesIannotatedTree _elsIannotatedTree
                     {-# LINE 25771 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CaseStatement _annIoriginalTree _casesIoriginalTree _elsIoriginalTree
                     {-# LINE 25777 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25783 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25789 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25795 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25801 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25807 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25813 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25819 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25825 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25831 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25837 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25843 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _casesIannotatedTree,_casesIoriginalTree) =
                    cases_ _casesOcat _casesOflags _casesOimCast
                ( _elsIannotatedTree,_elsIoriginalTree) =
                    els_ _elsOcat _elsOflags _elsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_If :: T_Annotation ->
                      T_ScalarExprStatementListPairList ->
                      T_StatementList ->
                      T_Statement
  _sem_Statement_If ann_ cases_ els_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _casesOcat :: Catalog
                _casesOflags :: TypeCheckFlags
                _casesOimCast :: (Maybe TypeExtra)
                _elsOcat :: Catalog
                _elsOflags :: TypeCheckFlags
                _elsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _casesIannotatedTree :: ScalarExprStatementListPairList
                _casesIoriginalTree :: ScalarExprStatementListPairList
                _elsIannotatedTree :: StatementList
                _elsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 25882 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     If _annIannotatedTree _casesIannotatedTree _elsIannotatedTree
                     {-# LINE 25888 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     If _annIoriginalTree _casesIoriginalTree _elsIoriginalTree
                     {-# LINE 25894 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 25900 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 25906 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25912 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25918 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25924 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25930 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25936 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _casesOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25942 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 25948 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 25954 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _elsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 25960 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _casesIannotatedTree,_casesIoriginalTree) =
                    cases_ _casesOcat _casesOflags _casesOimCast
                ( _elsIannotatedTree,_elsIoriginalTree) =
                    els_ _elsOcat _elsOflags _elsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_Block :: T_Annotation ->
                         (Maybe String) ->
                         T_VarDefList ->
                         T_StatementList ->
                         T_Statement
  _sem_Statement_Block ann_ lb_ vars_ sts_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _varsOcat :: Catalog
                _varsOflags :: TypeCheckFlags
                _varsOimCast :: (Maybe TypeExtra)
                _stsOcat :: Catalog
                _stsOflags :: TypeCheckFlags
                _stsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _varsIannotatedTree :: VarDefList
                _varsIoriginalTree :: VarDefList
                _stsIannotatedTree :: StatementList
                _stsIoriginalTree :: StatementList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 126, column 23)
                _annOtpe =
                    ({-# LINE 126 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 26000 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Block _annIannotatedTree lb_ _varsIannotatedTree _stsIannotatedTree
                     {-# LINE 26006 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Block _annIoriginalTree lb_ _varsIoriginalTree _stsIoriginalTree
                     {-# LINE 26012 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26036 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26042 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _varsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26048 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _varsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26054 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _varsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26060 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26066 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26072 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _stsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26078 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _varsIannotatedTree,_varsIoriginalTree) =
                    vars_ _varsOcat _varsOflags _varsOimCast
                ( _stsIannotatedTree,_stsIoriginalTree) =
                    sts_ _stsOcat _stsOflags _stsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_AntiStatement :: String ->
                                 T_Statement
  _sem_Statement_AntiStatement string_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AntiStatement string_
                     {-# LINE 26099 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     AntiStatement string_
                     {-# LINE 26105 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26111 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26117 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_DeclareStatement :: T_Annotation ->
                                    ([(String,TypeName,Maybe ScalarExpr)]) ->
                                    T_Statement
  _sem_Statement_DeclareStatement ann_ ds_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 26139 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DeclareStatement _annIannotatedTree ds_
                     {-# LINE 26145 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     DeclareStatement _annIoriginalTree ds_
                     {-# LINE 26151 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26157 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26163 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26181 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_ExecStatement :: T_Annotation ->
                                 T_Name ->
                                 T_ScalarExprList ->
                                 T_Statement
  _sem_Statement_ExecStatement ann_ spName_ args_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _argsOdownEnv :: Environment
                _argsOexpectedCast :: Bool
                _argsOexpectedTypes :: ([TypeExtra])
                _spNameOtpe :: (Either [TypeError] TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _argsOassignmentCastContext :: Bool
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _spNameOcat :: Catalog
                _spNameOflags :: TypeCheckFlags
                _spNameOimCast :: (Maybe TypeExtra)
                _argsOcat :: Catalog
                _argsOflags :: TypeCheckFlags
                _argsOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _spNameIannotatedTree :: Name
                _spNameIoriginalTree :: Name
                _argsIannotatedTree :: ScalarExprList
                _argsIoriginalTree :: ScalarExprList
                _argsIupTypes :: ([Maybe TypeExtra])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 171, column 31)
                _argsOdownEnv =
                    ({-# LINE 171 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 26222 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 172, column 31)
                _argsOexpectedCast =
                    ({-# LINE 172 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 26228 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 173, column 31)
                _argsOexpectedTypes =
                    ({-# LINE 173 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     []
                     {-# LINE 26234 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 174, column 31)
                _spNameOtpe =
                    ({-# LINE 174 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 26240 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 26246 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 831, column 31)
                _argsOassignmentCastContext =
                    ({-# LINE 831 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 26252 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ExecStatement _annIannotatedTree _spNameIannotatedTree _argsIannotatedTree
                     {-# LINE 26258 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ExecStatement _annIoriginalTree _spNameIoriginalTree _argsIoriginalTree
                     {-# LINE 26264 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26270 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26276 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26282 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26288 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26294 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _spNameOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26300 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _spNameOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26306 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _spNameOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26312 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26318 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26324 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _argsOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26330 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _spNameIannotatedTree,_spNameIoriginalTree) =
                    spName_ _spNameOcat _spNameOflags _spNameOimCast _spNameOtpe
                ( _argsIannotatedTree,_argsIoriginalTree,_argsIupTypes) =
                    args_ _argsOassignmentCastContext _argsOcat _argsOdownEnv _argsOexpectedCast _argsOexpectedTypes _argsOflags _argsOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_Statement_CreateIndexTSQL :: T_Annotation ->
                                   NameComponent ->
                                   T_Name ->
                                   ([NameComponent]) ->
                                   T_Statement
  _sem_Statement_CreateIndexTSQL ann_ nm_ obj_ cols_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _objOtpe :: (Either [TypeError] TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: Statement
                _lhsOoriginalTree :: Statement
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _objOcat :: Catalog
                _objOflags :: TypeCheckFlags
                _objOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _objIannotatedTree :: Name
                _objIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 143, column 33)
                _objOtpe =
                    ({-# LINE 143 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 26366 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag"(line 13, column 5)
                _annOtpe =
                    ({-# LINE 13 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Statements.ag" #-}
                     Left []
                     {-# LINE 26372 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateIndexTSQL _annIannotatedTree nm_ _objIannotatedTree cols_
                     {-# LINE 26378 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     CreateIndexTSQL _annIoriginalTree nm_ _objIoriginalTree cols_
                     {-# LINE 26384 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26390 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26396 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26402 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26408 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26414 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _objOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26420 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _objOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26426 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _objOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26432 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _objIannotatedTree,_objIoriginalTree) =
                    obj_ _objOcat _objOflags _objOimCast _objOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- StatementList -----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : StatementList 
           originalTree         : StatementList 
     alternatives:
        alternative Cons:
           child hd             : Statement 
           child tl             : StatementList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type StatementList = [Statement]
  -- cata
  _sem_StatementList :: StatementList ->
                       T_StatementList
  _sem_StatementList list =
      (Prelude.foldr _sem_StatementList_Cons _sem_StatementList_Nil (Prelude.map _sem_Statement list))
  -- semantic domain
  type T_StatementList = Catalog ->
                         TypeCheckFlags ->
                         (Maybe TypeExtra) ->
                         ( StatementList,StatementList)
  data Inh_StatementList = Inh_StatementList {_cat_Inh_StatementList :: Catalog,_flags_Inh_StatementList :: TypeCheckFlags,_imCast_Inh_StatementList :: (Maybe TypeExtra)}
  data Syn_StatementList = Syn_StatementList {_annotatedTree_Syn_StatementList :: StatementList,_originalTree_Syn_StatementList :: StatementList}
  _wrap_StatementList :: T_StatementList ->
                        Inh_StatementList ->
                        Syn_StatementList
  _wrap_StatementList sem (Inh_StatementList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_StatementList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_StatementList_Cons :: T_Statement ->
                            T_StatementList ->
                            T_StatementList
  _sem_StatementList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: StatementList
                _lhsOoriginalTree :: StatementList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: Statement
                _hdIoriginalTree :: Statement
                _tlIannotatedTree :: StatementList
                _tlIoriginalTree :: StatementList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 26503 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 26509 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26515 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26521 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26527 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26533 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26539 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26545 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26551 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26557 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_StatementList_Nil :: T_StatementList
  _sem_StatementList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: StatementList
                _lhsOoriginalTree :: StatementList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 26575 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 26581 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26587 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26593 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- TablePartitionDef -------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TablePartitionDef 
           originalTree         : TablePartitionDef 
     alternatives:
        alternative TablePartitionDef:
           child ann            : Annotation 
           child colname        : {NameComponent}
           child interval       : {Integer}
           child timeframe      : {TablePartitionDateTimeInterval}
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data TablePartitionDef = TablePartitionDef (Annotation) (NameComponent) (Integer) (TablePartitionDateTimeInterval)
                         deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_TablePartitionDef :: TablePartitionDef ->
                           T_TablePartitionDef
  _sem_TablePartitionDef (TablePartitionDef _ann _colname _interval _timeframe) =
      (_sem_TablePartitionDef_TablePartitionDef (_sem_Annotation _ann) _colname _interval _timeframe)
  -- semantic domain
  type T_TablePartitionDef = Catalog ->
                             TypeCheckFlags ->
                             (Maybe TypeExtra) ->
                             ( TablePartitionDef,TablePartitionDef)
  data Inh_TablePartitionDef = Inh_TablePartitionDef {_cat_Inh_TablePartitionDef :: Catalog,_flags_Inh_TablePartitionDef :: TypeCheckFlags,_imCast_Inh_TablePartitionDef :: (Maybe TypeExtra)}
  data Syn_TablePartitionDef = Syn_TablePartitionDef {_annotatedTree_Syn_TablePartitionDef :: TablePartitionDef,_originalTree_Syn_TablePartitionDef :: TablePartitionDef}
  _wrap_TablePartitionDef :: T_TablePartitionDef ->
                            Inh_TablePartitionDef ->
                            Syn_TablePartitionDef
  _wrap_TablePartitionDef sem (Inh_TablePartitionDef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TablePartitionDef _lhsOannotatedTree _lhsOoriginalTree))
  _sem_TablePartitionDef_TablePartitionDef :: T_Annotation ->
                                             NameComponent ->
                                             Integer ->
                                             TablePartitionDateTimeInterval ->
                                             T_TablePartitionDef
  _sem_TablePartitionDef_TablePartitionDef ann_ colname_ interval_ timeframe_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TablePartitionDef
                _lhsOoriginalTree :: TablePartitionDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 223, column 43)
                _annOtpe =
                    ({-# LINE 223 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 26657 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TablePartitionDef _annIannotatedTree colname_ interval_ timeframe_
                     {-# LINE 26663 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TablePartitionDef _annIoriginalTree colname_ interval_ timeframe_
                     {-# LINE 26669 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 26675 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26681 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26687 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26693 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26699 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- TableRef ----------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TableRef 
           originalTree         : TableRef 
           upEnv                : Environment
     alternatives:
        alternative Tref:
           child ann            : Annotation 
           child tbl            : Name 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local newAlias    : _
              local annotatedTree : _
              local originalTree : _
        alternative FunTref:
           child ann            : Annotation 
           child fn             : ScalarExpr 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local newAlias    : _
              local annotatedTree : _
              local originalTree : _
        alternative SubTref:
           child ann            : Annotation 
           child sel            : QueryExpr 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local newAlias    : _
              local annotatedTree : _
              local originalTree : _
        alternative JoinTref:
           child ann            : Annotation 
           child tref0          : TableRef 
           child nat            : {Natural}
           child joinType       : {JoinType}
           child joinHint       : {Maybe JoinHint}
           child tref1          : TableRef 
           child onExpr         : OnExpr 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local newAlias    : _
              local annotatedTree : _
              local originalTree : _
        alternative TableAlias:
           child ann            : Annotation 
           child tb             : {NameComponent}
           child tref           : TableRef 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local annotatedTree : _
              local originalTree : _
        alternative FullAlias:
           child ann            : Annotation 
           child tb             : {NameComponent}
           child cols           : {[NameComponent]}
           child tref           : TableRef 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local annotatedTree : _
              local originalTree : _
        alternative TableRefParens:
           child ann            : Annotation 
           child tref           : TableRef 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local newAlias    : _
              local annotatedTree : _
              local originalTree : _
        alternative OdbcTableRef:
           child ann            : Annotation 
           child tref           : TableRef 
           visit 0:
              local eEnv        : {Either [TypeError] Environment}
              local newAlias    : _
              local annotatedTree : _
              local originalTree : _
  -}
  data TableRef = Tref (Annotation) (Name)
                | FunTref (Annotation) (ScalarExpr)
                | SubTref (Annotation) (QueryExpr)
                | JoinTref (Annotation) (TableRef) (Natural) (JoinType) ((Maybe JoinHint)) (TableRef) (OnExpr)
                | TableAlias (Annotation) (NameComponent) (TableRef)
                | FullAlias (Annotation) (NameComponent) (([NameComponent])) (TableRef)
                | TableRefParens (Annotation) (TableRef)
                | OdbcTableRef (Annotation) (TableRef)
                deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_TableRef :: TableRef ->
                  T_TableRef
  _sem_TableRef (Tref _ann _tbl) =
      (_sem_TableRef_Tref (_sem_Annotation _ann) (_sem_Name _tbl))
  _sem_TableRef (FunTref _ann _fn) =
      (_sem_TableRef_FunTref (_sem_Annotation _ann) (_sem_ScalarExpr _fn))
  _sem_TableRef (SubTref _ann _sel) =
      (_sem_TableRef_SubTref (_sem_Annotation _ann) (_sem_QueryExpr _sel))
  _sem_TableRef (JoinTref _ann _tref0 _nat _joinType _joinHint _tref1 _onExpr) =
      (_sem_TableRef_JoinTref (_sem_Annotation _ann) (_sem_TableRef _tref0) _nat _joinType _joinHint (_sem_TableRef _tref1) (_sem_OnExpr _onExpr))
  _sem_TableRef (TableAlias _ann _tb _tref) =
      (_sem_TableRef_TableAlias (_sem_Annotation _ann) _tb (_sem_TableRef _tref))
  _sem_TableRef (FullAlias _ann _tb _cols _tref) =
      (_sem_TableRef_FullAlias (_sem_Annotation _ann) _tb _cols (_sem_TableRef _tref))
  _sem_TableRef (TableRefParens _ann _tref) =
      (_sem_TableRef_TableRefParens (_sem_Annotation _ann) (_sem_TableRef _tref))
  _sem_TableRef (OdbcTableRef _ann _tref) =
      (_sem_TableRef_OdbcTableRef (_sem_Annotation _ann) (_sem_TableRef _tref))
  -- semantic domain
  type T_TableRef = Catalog ->
                    TypeCheckFlags ->
                    (Maybe TypeExtra) ->
                    ( TableRef,TableRef,Environment)
  data Inh_TableRef = Inh_TableRef {_cat_Inh_TableRef :: Catalog,_flags_Inh_TableRef :: TypeCheckFlags,_imCast_Inh_TableRef :: (Maybe TypeExtra)}
  data Syn_TableRef = Syn_TableRef {_annotatedTree_Syn_TableRef :: TableRef,_originalTree_Syn_TableRef :: TableRef,_upEnv_Syn_TableRef :: Environment}
  _wrap_TableRef :: T_TableRef ->
                   Inh_TableRef ->
                   Syn_TableRef
  _wrap_TableRef sem (Inh_TableRef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TableRef _lhsOannotatedTree _lhsOoriginalTree _lhsOupEnv))
  _sem_TableRef_Tref :: T_Annotation ->
                       T_Name ->
                       T_TableRef
  _sem_TableRef_Tref ann_ tbl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _tblOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TableRef
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tblOcat :: Catalog
                _tblOflags :: TypeCheckFlags
                _tblOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tblIannotatedTree :: Name
                _tblIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 26856 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 26862 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 42, column 7)
                _eEnv =
                    ({-# LINE 42 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     E.envCreateTrefEnvironment _lhsIcat (nameComponents _tblIoriginalTree)
                     {-# LINE 26868 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 43, column 7)
                _tblOtpe =
                    ({-# LINE 43 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     Left []
                     {-# LINE 26874 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 75, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     let mk (q,is) = FullAlias emptyAnnotation
                                              (Nmc q)
                                              (map Nmc is)
                                              $ wrapIfJoin _annotatedTree
                         wrapIfJoin tr = case tr of
                                            JoinTref {} -> TableRefParens emptyAnnotation tr
                                            _ -> tr
                     in maybe _annotatedTree     mk _newAlias
                     {-# LINE 26887 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 150, column 7)
                _newAlias =
                    ({-# LINE 150 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if tcfAddFullTablerefAliases _lhsIflags
                     then do
                       ((_,n),cs,_) <- either (const Nothing) Just
                                     $ catLookupTableAndAttrs _lhsIcat
                                     (nameComponents _tblIoriginalTree)
                       return (T.unpack n, (map (T.unpack . fst) cs))
                     else Nothing
                     {-# LINE 26899 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Tref _annIannotatedTree _tblIannotatedTree
                     {-# LINE 26905 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Tref _annIoriginalTree _tblIoriginalTree
                     {-# LINE 26911 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 26917 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26923 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26929 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26935 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 26941 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 26947 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tblOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 26953 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tblIannotatedTree,_tblIoriginalTree) =
                    tbl_ _tblOcat _tblOflags _tblOimCast _tblOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_FunTref :: T_Annotation ->
                          T_ScalarExpr ->
                          T_TableRef
  _sem_TableRef_FunTref ann_ fn_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _fnOdownEnv :: Environment
                _fnOexpectedCast :: Bool
                _fnOexpectedType :: (Maybe TypeExtra)
                _fnOodbcFunction :: Bool
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _lhsOannotatedTree :: TableRef
                _fnOassignmentCastContext :: Bool
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _fnOcat :: Catalog
                _fnOflags :: TypeCheckFlags
                _fnOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _fnIannotatedTree :: ScalarExpr
                _fnIcolExprs :: ([(NameComponent,Maybe TypeExtra,ScalarExpr)])
                _fnIoriginalTree :: ScalarExpr
                _fnIupType :: (Maybe TypeExtra)
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 224, column 24)
                _fnOdownEnv =
                    ({-# LINE 224 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 26993 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 225, column 24)
                _fnOexpectedCast =
                    ({-# LINE 225 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 26999 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 226, column 24)
                _fnOexpectedType =
                    ({-# LINE 226 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Nothing
                     {-# LINE 27005 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 227, column 24)
                _fnOodbcFunction =
                    ({-# LINE 227 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     False
                     {-# LINE 27011 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27018 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27024 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 71, column 7)
                _eEnv =
                    ({-# LINE 71 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     Left []
                     {-# LINE 27030 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 75, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     let mk (q,is) = FullAlias emptyAnnotation
                                              (Nmc q)
                                              (map Nmc is)
                                              $ wrapIfJoin _annotatedTree
                         wrapIfJoin tr = case tr of
                                            JoinTref {} -> TableRefParens emptyAnnotation tr
                                            _ -> tr
                     in maybe _annotatedTree     mk _newAlias
                     {-# LINE 27043 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 135, column 7)
                _newAlias =
                    ({-# LINE 135 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if tcfAddFullTablerefAliases _lhsIflags
                     then do
                       env <- either (const Nothing) Just _eEnv
                       cs <- either (const Nothing) Just $ E.envExpandStar Nothing env
                       let qs = map (fst . fst) cs
                       if all (== head qs) qs
                         then return (T.unpack $ head qs, map (T.unpack . snd . fst) cs)
                         else
                                                              Nothing
                     else Nothing
                     {-# LINE 27058 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 844, column 24)
                _fnOassignmentCastContext =
                    ({-# LINE 844 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 27064 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     FunTref _annIannotatedTree _fnIannotatedTree
                     {-# LINE 27070 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     FunTref _annIoriginalTree _fnIoriginalTree
                     {-# LINE 27076 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27082 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27088 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27094 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27100 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27106 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27112 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _fnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27118 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _fnIannotatedTree,_fnIcolExprs,_fnIoriginalTree,_fnIupType) =
                    fn_ _fnOassignmentCastContext _fnOcat _fnOdownEnv _fnOexpectedCast _fnOexpectedType _fnOflags _fnOimCast _fnOodbcFunction
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_SubTref :: T_Annotation ->
                          T_QueryExpr ->
                          T_TableRef
  _sem_TableRef_SubTref ann_ sel_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _selOexpectedType :: (Maybe [TypeExtra])
                _lhsOannotatedTree :: TableRef
                _selOouterDownEnv :: (Maybe Environment)
                _selOassignmentCastContext :: Bool
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _selOcat :: Catalog
                _selOflags :: TypeCheckFlags
                _selOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _selIannotatedTree :: QueryExpr
                _selIoriginalTree :: QueryExpr
                _selIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27156 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27162 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 58, column 7)
                _eEnv =
                    ({-# LINE 58 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     maybe (Left []) id
                     $ fmap E.envSelectListEnvironment _selIupType
                     {-# LINE 27169 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 60, column 7)
                _selOexpectedType =
                    ({-# LINE 60 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     liftM (map snd) _selIupType
                     {-# LINE 27175 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 75, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     let mk (q,is) = FullAlias emptyAnnotation
                                              (Nmc q)
                                              (map Nmc is)
                                              $ wrapIfJoin _annotatedTree
                         wrapIfJoin tr = case tr of
                                            JoinTref {} -> TableRefParens emptyAnnotation tr
                                            _ -> tr
                     in maybe _annotatedTree     mk _newAlias
                     {-# LINE 27188 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 135, column 7)
                _newAlias =
                    ({-# LINE 135 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if tcfAddFullTablerefAliases _lhsIflags
                     then do
                       env <- either (const Nothing) Just _eEnv
                       cs <- either (const Nothing) Just $ E.envExpandStar Nothing env
                       let qs = map (fst . fst) cs
                       if all (== head qs) qs
                         then return (T.unpack $ head qs, map (T.unpack . snd . fst) cs)
                         else
                                                              Nothing
                     else Nothing
                     {-# LINE 27203 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 93, column 13)
                _selOouterDownEnv =
                    ({-# LINE 93 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Nothing
                     {-# LINE 27209 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 845, column 24)
                _selOassignmentCastContext =
                    ({-# LINE 845 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 27215 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SubTref _annIannotatedTree _selIannotatedTree
                     {-# LINE 27221 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SubTref _annIoriginalTree _selIoriginalTree
                     {-# LINE 27227 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27233 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27239 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27245 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27251 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27257 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27263 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _selOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27269 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _selIannotatedTree,_selIoriginalTree,_selIupType) =
                    sel_ _selOassignmentCastContext _selOcat _selOexpectedType _selOflags _selOimCast _selOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_JoinTref :: T_Annotation ->
                           T_TableRef ->
                           Natural ->
                           JoinType ->
                           (Maybe JoinHint) ->
                           T_TableRef ->
                           T_OnExpr ->
                           T_TableRef
  _sem_TableRef_JoinTref ann_ tref0_ nat_ joinType_ joinHint_ tref1_ onExpr_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _onExprOdownEnv :: Environment
                _lhsOannotatedTree :: TableRef
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tref0Ocat :: Catalog
                _tref0Oflags :: TypeCheckFlags
                _tref0OimCast :: (Maybe TypeExtra)
                _tref1Ocat :: Catalog
                _tref1Oflags :: TypeCheckFlags
                _tref1OimCast :: (Maybe TypeExtra)
                _onExprOcat :: Catalog
                _onExprOflags :: TypeCheckFlags
                _onExprOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tref0IannotatedTree :: TableRef
                _tref0IoriginalTree :: TableRef
                _tref0IupEnv :: Environment
                _tref1IannotatedTree :: TableRef
                _tref1IoriginalTree :: TableRef
                _tref1IupEnv :: Environment
                _onExprIannotatedTree :: OnExpr
                _onExprIoriginalTree :: OnExpr
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27321 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27327 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 46, column 7)
                _eEnv =
                    ({-# LINE 46 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     E.createJoinTrefEnvironment _lhsIcat
                       _tref0IupEnv _tref1IupEnv (convertJoinType joinType_)
                       $ case (joinType_,_onExprIoriginalTree) of
                          (x,Nothing) | x /= Cross -> Nothing
                          (_,Just (JoinUsing _ nms)) -> Just nms
                          _ -> Just []
                     {-# LINE 27338 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 56, column 7)
                _onExprOdownEnv =
                    ({-# LINE 56 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27344 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 75, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     let mk (q,is) = FullAlias emptyAnnotation
                                              (Nmc q)
                                              (map Nmc is)
                                              $ wrapIfJoin _annotatedTree
                         wrapIfJoin tr = case tr of
                                            JoinTref {} -> TableRefParens emptyAnnotation tr
                                            _ -> tr
                     in maybe _annotatedTree     mk _newAlias
                     {-# LINE 27357 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 135, column 7)
                _newAlias =
                    ({-# LINE 135 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if tcfAddFullTablerefAliases _lhsIflags
                     then do
                       env <- either (const Nothing) Just _eEnv
                       cs <- either (const Nothing) Just $ E.envExpandStar Nothing env
                       let qs = map (fst . fst) cs
                       if all (== head qs) qs
                         then return (T.unpack $ head qs, map (T.unpack . snd . fst) cs)
                         else
                                                              Nothing
                     else Nothing
                     {-# LINE 27372 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     JoinTref _annIannotatedTree _tref0IannotatedTree nat_ joinType_ joinHint_ _tref1IannotatedTree _onExprIannotatedTree
                     {-# LINE 27378 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     JoinTref _annIoriginalTree _tref0IoriginalTree nat_ joinType_ joinHint_ _tref1IoriginalTree _onExprIoriginalTree
                     {-# LINE 27384 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27390 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27396 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27402 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27408 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tref0Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27414 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tref0Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27420 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tref0OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27426 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tref1Ocat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27432 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tref1Oflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27438 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tref1OimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27444 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _onExprOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27450 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _onExprOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27456 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _onExprOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27462 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tref0IannotatedTree,_tref0IoriginalTree,_tref0IupEnv) =
                    tref0_ _tref0Ocat _tref0Oflags _tref0OimCast
                ( _tref1IannotatedTree,_tref1IoriginalTree,_tref1IupEnv) =
                    tref1_ _tref1Ocat _tref1Oflags _tref1OimCast
                ( _onExprIannotatedTree,_onExprIoriginalTree) =
                    onExpr_ _onExprOcat _onExprOdownEnv _onExprOflags _onExprOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_TableAlias :: T_Annotation ->
                             NameComponent ->
                             T_TableRef ->
                             T_TableRef
  _sem_TableRef_TableAlias ann_ tb_ tref_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _lhsOannotatedTree :: TableRef
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _trefOcat :: Catalog
                _trefOflags :: TypeCheckFlags
                _trefOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _trefIannotatedTree :: TableRef
                _trefIoriginalTree :: TableRef
                _trefIupEnv :: Environment
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27502 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27508 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 68, column 7)
                _eEnv =
                    ({-# LINE 68 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     Right $ E.createTrefAliasedEnvironment
                             (ncStrT tb_) Nothing _trefIupEnv
                     {-# LINE 27515 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 124, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 124 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     case _trefIannotatedTree of
                       FullAlias _ _ c tr -> FullAlias emptyAnnotation tb_ c tr
                       TableAlias _ _ tr -> TableAlias emptyAnnotation tb_ tr
                       _ -> _annotatedTree
                     {-# LINE 27524 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TableAlias _annIannotatedTree tb_ _trefIannotatedTree
                     {-# LINE 27530 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TableAlias _annIoriginalTree tb_ _trefIoriginalTree
                     {-# LINE 27536 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27542 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27548 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27554 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27560 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27566 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27572 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27578 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _trefIannotatedTree,_trefIoriginalTree,_trefIupEnv) =
                    tref_ _trefOcat _trefOflags _trefOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_FullAlias :: T_Annotation ->
                            NameComponent ->
                            ([NameComponent]) ->
                            T_TableRef ->
                            T_TableRef
  _sem_TableRef_FullAlias ann_ tb_ cols_ tref_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _lhsOannotatedTree :: TableRef
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _trefOcat :: Catalog
                _trefOflags :: TypeCheckFlags
                _trefOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _trefIannotatedTree :: TableRef
                _trefIoriginalTree :: TableRef
                _trefIupEnv :: Environment
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27615 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27621 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 65, column 7)
                _eEnv =
                    ({-# LINE 65 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     Right $ E.createTrefAliasedEnvironment
                             (ncStrT tb_) (Just $ map ncStrT cols_) _trefIupEnv
                     {-# LINE 27628 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 103, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 103 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     case _trefIannotatedTree of
                       FullAlias _ t _ tr -> FullAlias emptyAnnotation
                                               (if tb_ == Nmc "" then t else tb_) cols_                       tr
                       TableAlias _ _ tr -> FullAlias emptyAnnotation tb_ cols_                        tr
                       _ -> _annotatedTree
                     {-# LINE 27638 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     FullAlias _annIannotatedTree tb_ cols_ _trefIannotatedTree
                     {-# LINE 27644 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     FullAlias _annIoriginalTree tb_ cols_ _trefIoriginalTree
                     {-# LINE 27650 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27656 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27662 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27674 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27680 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27686 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27692 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _trefIannotatedTree,_trefIoriginalTree,_trefIupEnv) =
                    tref_ _trefOcat _trefOflags _trefOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_TableRefParens :: T_Annotation ->
                                 T_TableRef ->
                                 T_TableRef
  _sem_TableRef_TableRefParens ann_ tref_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _lhsOannotatedTree :: TableRef
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _trefOcat :: Catalog
                _trefOflags :: TypeCheckFlags
                _trefOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _trefIannotatedTree :: TableRef
                _trefIoriginalTree :: TableRef
                _trefIupEnv :: Environment
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27727 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27733 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 63, column 7)
                _eEnv =
                    ({-# LINE 63 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     Right $ _trefIupEnv
                     {-# LINE 27739 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 75, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     let mk (q,is) = FullAlias emptyAnnotation
                                              (Nmc q)
                                              (map Nmc is)
                                              $ wrapIfJoin _annotatedTree
                         wrapIfJoin tr = case tr of
                                            JoinTref {} -> TableRefParens emptyAnnotation tr
                                            _ -> tr
                     in maybe _annotatedTree     mk _newAlias
                     {-# LINE 27752 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 135, column 7)
                _newAlias =
                    ({-# LINE 135 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if tcfAddFullTablerefAliases _lhsIflags
                     then do
                       env <- either (const Nothing) Just _eEnv
                       cs <- either (const Nothing) Just $ E.envExpandStar Nothing env
                       let qs = map (fst . fst) cs
                       if all (== head qs) qs
                         then return (T.unpack $ head qs, map (T.unpack . snd . fst) cs)
                         else
                                                              Nothing
                     else Nothing
                     {-# LINE 27767 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TableRefParens _annIannotatedTree _trefIannotatedTree
                     {-# LINE 27773 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TableRefParens _annIoriginalTree _trefIoriginalTree
                     {-# LINE 27779 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27785 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27791 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27797 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27803 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27809 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27815 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27821 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _trefIannotatedTree,_trefIoriginalTree,_trefIupEnv) =
                    tref_ _trefOcat _trefOflags _trefOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRef_OdbcTableRef :: T_Annotation ->
                               T_TableRef ->
                               T_TableRef
  _sem_TableRef_OdbcTableRef ann_ tref_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOupEnv :: Environment
                _eEnv :: (Either [TypeError] Environment)
                _lhsOannotatedTree :: TableRef
                _lhsOoriginalTree :: TableRef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _trefOcat :: Catalog
                _trefOflags :: TypeCheckFlags
                _trefOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _trefIannotatedTree :: TableRef
                _trefIoriginalTree :: TableRef
                _trefIupEnv :: Environment
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 33, column 7)
                _annOtpe =
                    ({-# LINE 33 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either Left (Right . mkTypeExtraNN . TrefType)
                     (_eEnv     >>= E.envExpandStar Nothing)
                     {-# LINE 27856 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 36, column 7)
                _lhsOupEnv =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     either (const E.brokeEnvironment) id _eEnv
                     {-# LINE 27862 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 63, column 7)
                _eEnv =
                    ({-# LINE 63 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     Right $ _trefIupEnv
                     {-# LINE 27868 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 75, column 7)
                _lhsOannotatedTree =
                    ({-# LINE 75 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     let mk (q,is) = FullAlias emptyAnnotation
                                              (Nmc q)
                                              (map Nmc is)
                                              $ wrapIfJoin _annotatedTree
                         wrapIfJoin tr = case tr of
                                            JoinTref {} -> TableRefParens emptyAnnotation tr
                                            _ -> tr
                     in maybe _annotatedTree     mk _newAlias
                     {-# LINE 27881 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 135, column 7)
                _newAlias =
                    ({-# LINE 135 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if tcfAddFullTablerefAliases _lhsIflags
                     then do
                       env <- either (const Nothing) Just _eEnv
                       cs <- either (const Nothing) Just $ E.envExpandStar Nothing env
                       let qs = map (fst . fst) cs
                       if all (== head qs) qs
                         then return (T.unpack $ head qs, map (T.unpack . snd . fst) cs)
                         else
                                                              Nothing
                     else Nothing
                     {-# LINE 27896 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     OdbcTableRef _annIannotatedTree _trefIannotatedTree
                     {-# LINE 27902 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     OdbcTableRef _annIoriginalTree _trefIoriginalTree
                     {-# LINE 27908 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 27914 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27920 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27926 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27932 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 27938 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 27944 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _trefOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 27950 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _trefIannotatedTree,_trefIoriginalTree,_trefIupEnv) =
                    tref_ _trefOcat _trefOflags _trefOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  -- TableRefList ------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TableRefList 
           originalTree         : TableRefList 
           upEnv                : Environment
     alternatives:
        alternative Cons:
           child hd             : TableRef 
           child tl             : TableRefList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type TableRefList = [TableRef]
  -- cata
  _sem_TableRefList :: TableRefList ->
                      T_TableRefList
  _sem_TableRefList list =
      (Prelude.foldr _sem_TableRefList_Cons _sem_TableRefList_Nil (Prelude.map _sem_TableRef list))
  -- semantic domain
  type T_TableRefList = Catalog ->
                        TypeCheckFlags ->
                        (Maybe TypeExtra) ->
                        ( TableRefList,TableRefList,Environment)
  data Inh_TableRefList = Inh_TableRefList {_cat_Inh_TableRefList :: Catalog,_flags_Inh_TableRefList :: TypeCheckFlags,_imCast_Inh_TableRefList :: (Maybe TypeExtra)}
  data Syn_TableRefList = Syn_TableRefList {_annotatedTree_Syn_TableRefList :: TableRefList,_originalTree_Syn_TableRefList :: TableRefList,_upEnv_Syn_TableRefList :: Environment}
  _wrap_TableRefList :: T_TableRefList ->
                       Inh_TableRefList ->
                       Syn_TableRefList
  _wrap_TableRefList sem (Inh_TableRefList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TableRefList _lhsOannotatedTree _lhsOoriginalTree _lhsOupEnv))
  _sem_TableRefList_Cons :: T_TableRef ->
                           T_TableRefList ->
                           T_TableRefList
  _sem_TableRefList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupEnv :: Environment
                _lhsOannotatedTree :: TableRefList
                _lhsOoriginalTree :: TableRefList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: TableRef
                _hdIoriginalTree :: TableRef
                _hdIupEnv :: Environment
                _tlIannotatedTree :: TableRefList
                _tlIoriginalTree :: TableRefList
                _tlIupEnv :: Environment
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 20, column 7)
                _lhsOupEnv =
                    ({-# LINE 20 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     if E.isEmptyEnv _tlIupEnv
                     then _hdIupEnv
                     else
                            either (error . show) id $
                            E.createJoinTrefEnvironment _lhsIcat _hdIupEnv _tlIupEnv E.Inner $ Just []
                     {-# LINE 28029 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 28035 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 28041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree,_hdIupEnv) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree,_tlIupEnv) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  _sem_TableRefList_Nil :: T_TableRefList
  _sem_TableRefList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOupEnv :: Environment
                _lhsOannotatedTree :: TableRefList
                _lhsOoriginalTree :: TableRefList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag"(line 18, column 9)
                _lhsOupEnv =
                    ({-# LINE 18 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/TableRefs.ag" #-}
                     E.emptyEnvironment
                     {-# LINE 28108 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 28114 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 28120 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28126 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28132 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree,_lhsOupEnv)))
  -- TypeAttributeDef --------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TypeAttributeDef 
           originalTree         : TypeAttributeDef 
     alternatives:
        alternative TypeAttDef:
           child ann            : Annotation 
           child name           : {NameComponent}
           child typ            : TypeName 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data TypeAttributeDef = TypeAttDef (Annotation) (NameComponent) (TypeName)
                        deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_TypeAttributeDef :: TypeAttributeDef ->
                          T_TypeAttributeDef
  _sem_TypeAttributeDef (TypeAttDef _ann _name _typ) =
      (_sem_TypeAttributeDef_TypeAttDef (_sem_Annotation _ann) _name (_sem_TypeName _typ))
  -- semantic domain
  type T_TypeAttributeDef = Catalog ->
                            TypeCheckFlags ->
                            (Maybe TypeExtra) ->
                            ( TypeAttributeDef,TypeAttributeDef)
  data Inh_TypeAttributeDef = Inh_TypeAttributeDef {_cat_Inh_TypeAttributeDef :: Catalog,_flags_Inh_TypeAttributeDef :: TypeCheckFlags,_imCast_Inh_TypeAttributeDef :: (Maybe TypeExtra)}
  data Syn_TypeAttributeDef = Syn_TypeAttributeDef {_annotatedTree_Syn_TypeAttributeDef :: TypeAttributeDef,_originalTree_Syn_TypeAttributeDef :: TypeAttributeDef}
  _wrap_TypeAttributeDef :: T_TypeAttributeDef ->
                           Inh_TypeAttributeDef ->
                           Syn_TypeAttributeDef
  _wrap_TypeAttributeDef sem (Inh_TypeAttributeDef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TypeAttributeDef _lhsOannotatedTree _lhsOoriginalTree))
  _sem_TypeAttributeDef_TypeAttDef :: T_Annotation ->
                                     NameComponent ->
                                     T_TypeName ->
                                     T_TypeAttributeDef
  _sem_TypeAttributeDef_TypeAttDef ann_ name_ typ_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TypeAttributeDef
                _lhsOoriginalTree :: TypeAttributeDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 228, column 35)
                _annOtpe =
                    ({-# LINE 228 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 28200 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TypeAttDef _annIannotatedTree name_ _typIannotatedTree
                     {-# LINE 28206 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     TypeAttDef _annIoriginalTree name_ _typIoriginalTree
                     {-# LINE 28212 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28218 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28224 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28230 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28236 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28242 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28248 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28254 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28260 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- TypeAttributeDefList ----------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TypeAttributeDefList 
           originalTree         : TypeAttributeDefList 
     alternatives:
        alternative Cons:
           child hd             : TypeAttributeDef 
           child tl             : TypeAttributeDefList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type TypeAttributeDefList = [TypeAttributeDef]
  -- cata
  _sem_TypeAttributeDefList :: TypeAttributeDefList ->
                              T_TypeAttributeDefList
  _sem_TypeAttributeDefList list =
      (Prelude.foldr _sem_TypeAttributeDefList_Cons _sem_TypeAttributeDefList_Nil (Prelude.map _sem_TypeAttributeDef list))
  -- semantic domain
  type T_TypeAttributeDefList = Catalog ->
                                TypeCheckFlags ->
                                (Maybe TypeExtra) ->
                                ( TypeAttributeDefList,TypeAttributeDefList)
  data Inh_TypeAttributeDefList = Inh_TypeAttributeDefList {_cat_Inh_TypeAttributeDefList :: Catalog,_flags_Inh_TypeAttributeDefList :: TypeCheckFlags,_imCast_Inh_TypeAttributeDefList :: (Maybe TypeExtra)}
  data Syn_TypeAttributeDefList = Syn_TypeAttributeDefList {_annotatedTree_Syn_TypeAttributeDefList :: TypeAttributeDefList,_originalTree_Syn_TypeAttributeDefList :: TypeAttributeDefList}
  _wrap_TypeAttributeDefList :: T_TypeAttributeDefList ->
                               Inh_TypeAttributeDefList ->
                               Syn_TypeAttributeDefList
  _wrap_TypeAttributeDefList sem (Inh_TypeAttributeDefList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TypeAttributeDefList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_TypeAttributeDefList_Cons :: T_TypeAttributeDef ->
                                   T_TypeAttributeDefList ->
                                   T_TypeAttributeDefList
  _sem_TypeAttributeDefList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: TypeAttributeDefList
                _lhsOoriginalTree :: TypeAttributeDefList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: TypeAttributeDef
                _hdIoriginalTree :: TypeAttributeDef
                _tlIannotatedTree :: TypeAttributeDefList
                _tlIoriginalTree :: TypeAttributeDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 28331 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 28337 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28343 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28349 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28355 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28361 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28367 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28373 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28379 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28385 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_TypeAttributeDefList_Nil :: T_TypeAttributeDefList
  _sem_TypeAttributeDefList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: TypeAttributeDefList
                _lhsOoriginalTree :: TypeAttributeDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 28403 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 28409 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28415 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28421 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- TypeName ----------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TypeName 
           namedType            : Maybe TypeExtra
           originalTree         : TypeName 
     alternatives:
        alternative SimpleTypeName:
           child ann            : Annotation 
           child tn             : Name 
           visit 0:
              local canType     : {[NameComponent] -> [NameComponent]}
              local tpe         : {Either [TypeError] TypeExtra}
              local annotatedTree : _
              local originalTree : _
        alternative PrecTypeName:
           child ann            : Annotation 
           child tn             : Name 
           child prec           : {Integer}
           visit 0:
              local canType     : {[NameComponent] -> [NameComponent]}
              local tpe         : {Either [TypeError] TypeExtra}
              local annotatedTree : _
              local originalTree : _
        alternative Prec2TypeName:
           child ann            : Annotation 
           child tn             : Name 
           child prec           : {Integer}
           child prec1          : {Integer}
           visit 0:
              local canType     : {[NameComponent] -> [NameComponent]}
              local tpe         : {Either [TypeError] TypeExtra}
              local annotatedTree : _
              local originalTree : _
        alternative ArrayTypeName:
           child ann            : Annotation 
           child typ            : TypeName 
           visit 0:
              local canType     : {[NameComponent] -> [NameComponent]}
              local tpe         : {Either [TypeError] TypeExtra}
              local annotatedTree : _
              local originalTree : _
        alternative SetOfTypeName:
           child ann            : Annotation 
           child typ            : TypeName 
           visit 0:
              local canType     : {[NameComponent] -> [NameComponent]}
              local tpe         : {Either [TypeError] TypeExtra}
              local annotatedTree : _
              local originalTree : _
  -}
  data TypeName = SimpleTypeName (Annotation) (Name)
                | PrecTypeName (Annotation) (Name) (Integer)
                | Prec2TypeName (Annotation) (Name) (Integer) (Integer)
                | ArrayTypeName (Annotation) (TypeName)
                | SetOfTypeName (Annotation) (TypeName)
                deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_TypeName :: TypeName ->
                  T_TypeName
  _sem_TypeName (SimpleTypeName _ann _tn) =
      (_sem_TypeName_SimpleTypeName (_sem_Annotation _ann) (_sem_Name _tn))
  _sem_TypeName (PrecTypeName _ann _tn _prec) =
      (_sem_TypeName_PrecTypeName (_sem_Annotation _ann) (_sem_Name _tn) _prec)
  _sem_TypeName (Prec2TypeName _ann _tn _prec _prec1) =
      (_sem_TypeName_Prec2TypeName (_sem_Annotation _ann) (_sem_Name _tn) _prec _prec1)
  _sem_TypeName (ArrayTypeName _ann _typ) =
      (_sem_TypeName_ArrayTypeName (_sem_Annotation _ann) (_sem_TypeName _typ))
  _sem_TypeName (SetOfTypeName _ann _typ) =
      (_sem_TypeName_SetOfTypeName (_sem_Annotation _ann) (_sem_TypeName _typ))
  -- semantic domain
  type T_TypeName = Catalog ->
                    TypeCheckFlags ->
                    (Maybe TypeExtra) ->
                    ( TypeName,(Maybe TypeExtra),TypeName)
  data Inh_TypeName = Inh_TypeName {_cat_Inh_TypeName :: Catalog,_flags_Inh_TypeName :: TypeCheckFlags,_imCast_Inh_TypeName :: (Maybe TypeExtra)}
  data Syn_TypeName = Syn_TypeName {_annotatedTree_Syn_TypeName :: TypeName,_namedType_Syn_TypeName :: (Maybe TypeExtra),_originalTree_Syn_TypeName :: TypeName}
  _wrap_TypeName :: T_TypeName ->
                   Inh_TypeName ->
                   Syn_TypeName
  _wrap_TypeName sem (Inh_TypeName _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TypeName _lhsOannotatedTree _lhsOnamedType _lhsOoriginalTree))
  _sem_TypeName_SimpleTypeName :: T_Annotation ->
                                 T_Name ->
                                 T_TypeName
  _sem_TypeName_SimpleTypeName ann_ tn_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOnamedType :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _tnOtpe :: (Either [TypeError] TypeExtra)
                _canType :: ([NameComponent] -> [NameComponent])
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TypeName
                _lhsOoriginalTree :: TypeName
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tnOcat :: Catalog
                _tnOflags :: TypeCheckFlags
                _tnOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tnIannotatedTree :: Name
                _tnIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 36, column 10)
                _lhsOnamedType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 28540 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 37, column 10)
                _annOtpe =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either Left (const $ Left []) _tpe
                     {-# LINE 28546 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 39, column 10)
                _tnOtpe =
                    ({-# LINE 39 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     Left []
                     {-# LINE 28552 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 51, column 10)
                _canType =
                    ({-# LINE 51 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     \x -> case x of
                        [Nmc nc] -> [Nmc $ T.unpack $ canonicalizeTypeName (tcfDialect _lhsIflags) $ T.pack nc]
                        _ -> x
                     {-# LINE 28560 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 63, column 10)
                _tpe =
                    ({-# LINE 63 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     mkTypeExtraNN `liftM` catLookupType _lhsIcat (_canType     $ nameComponents _tnIoriginalTree)
                     {-# LINE 28566 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SimpleTypeName _annIannotatedTree _tnIannotatedTree
                     {-# LINE 28572 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SimpleTypeName _annIoriginalTree _tnIoriginalTree
                     {-# LINE 28578 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28584 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28590 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28596 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28602 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28608 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28614 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28620 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28626 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tnIannotatedTree,_tnIoriginalTree) =
                    tn_ _tnOcat _tnOflags _tnOimCast _tnOtpe
            in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
  _sem_TypeName_PrecTypeName :: T_Annotation ->
                               T_Name ->
                               Integer ->
                               T_TypeName
  _sem_TypeName_PrecTypeName ann_ tn_ prec_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOnamedType :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _tnOtpe :: (Either [TypeError] TypeExtra)
                _canType :: ([NameComponent] -> [NameComponent])
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TypeName
                _lhsOoriginalTree :: TypeName
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tnOcat :: Catalog
                _tnOflags :: TypeCheckFlags
                _tnOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tnIannotatedTree :: Name
                _tnIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 36, column 10)
                _lhsOnamedType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 28662 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 37, column 10)
                _annOtpe =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either Left (const $ Left []) _tpe
                     {-# LINE 28668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 39, column 10)
                _tnOtpe =
                    ({-# LINE 39 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     Left []
                     {-# LINE 28674 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 51, column 10)
                _canType =
                    ({-# LINE 51 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     \x -> case x of
                        [Nmc nc] -> [Nmc $ T.unpack $ canonicalizeTypeName (tcfDialect _lhsIflags) $ T.pack nc]
                        _ -> x
                     {-# LINE 28682 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 77, column 9)
                _tpe =
                    ({-# LINE 77 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     ((\t -> t{tePrecision = Just $ fromIntegral prec_}) . mkTypeExtraNN)
                     `liftM` catLookupType _lhsIcat (nameComponents _tnIoriginalTree)
                     {-# LINE 28689 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PrecTypeName _annIannotatedTree _tnIannotatedTree prec_
                     {-# LINE 28695 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     PrecTypeName _annIoriginalTree _tnIoriginalTree prec_
                     {-# LINE 28701 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28707 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28713 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28719 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28725 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28731 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28737 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28743 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28749 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tnIannotatedTree,_tnIoriginalTree) =
                    tn_ _tnOcat _tnOflags _tnOimCast _tnOtpe
            in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
  _sem_TypeName_Prec2TypeName :: T_Annotation ->
                                T_Name ->
                                Integer ->
                                Integer ->
                                T_TypeName
  _sem_TypeName_Prec2TypeName ann_ tn_ prec_ prec1_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOnamedType :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _tnOtpe :: (Either [TypeError] TypeExtra)
                _canType :: ([NameComponent] -> [NameComponent])
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TypeName
                _lhsOoriginalTree :: TypeName
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _tnOcat :: Catalog
                _tnOflags :: TypeCheckFlags
                _tnOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _tnIannotatedTree :: Name
                _tnIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 36, column 10)
                _lhsOnamedType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 28786 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 37, column 10)
                _annOtpe =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either Left (const $ Left []) _tpe
                     {-# LINE 28792 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 39, column 10)
                _tnOtpe =
                    ({-# LINE 39 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     Left []
                     {-# LINE 28798 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 51, column 10)
                _canType =
                    ({-# LINE 51 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     \x -> case x of
                        [Nmc nc] -> [Nmc $ T.unpack $ canonicalizeTypeName (tcfDialect _lhsIflags) $ T.pack nc]
                        _ -> x
                     {-# LINE 28806 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 80, column 9)
                _tpe =
                    ({-# LINE 80 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     ((\t -> t{tePrecision = Just $ fromIntegral prec_,
                               teScale = Just $ fromIntegral prec1_})
                           . mkTypeExtraNN)
                     `liftM` catLookupType _lhsIcat (nameComponents _tnIoriginalTree)
                     {-# LINE 28815 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Prec2TypeName _annIannotatedTree _tnIannotatedTree prec_ prec1_
                     {-# LINE 28821 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     Prec2TypeName _annIoriginalTree _tnIoriginalTree prec_ prec1_
                     {-# LINE 28827 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28833 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28839 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28845 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28851 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28857 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28863 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28869 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tnOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28875 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _tnIannotatedTree,_tnIoriginalTree) =
                    tn_ _tnOcat _tnOflags _tnOimCast _tnOtpe
            in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
  _sem_TypeName_ArrayTypeName :: T_Annotation ->
                                T_TypeName ->
                                T_TypeName
  _sem_TypeName_ArrayTypeName ann_ typ_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOnamedType :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _canType :: ([NameComponent] -> [NameComponent])
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TypeName
                _lhsOoriginalTree :: TypeName
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 36, column 10)
                _lhsOnamedType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 28910 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 37, column 10)
                _annOtpe =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either Left (const $ Left []) _tpe
                     {-# LINE 28916 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 51, column 10)
                _canType =
                    ({-# LINE 51 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     \x -> case x of
                        [Nmc nc] -> [Nmc $ T.unpack $ canonicalizeTypeName (tcfDialect _lhsIflags) $ T.pack nc]
                        _ -> x
                     {-# LINE 28924 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 71, column 9)
                _tpe =
                    ({-# LINE 71 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     maybe (Left []) Right _typInamedType
                     >>= Right . (\t -> t{teType = ArrayType $ teType t})
                     {-# LINE 28931 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ArrayTypeName _annIannotatedTree _typIannotatedTree
                     {-# LINE 28937 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ArrayTypeName _annIoriginalTree _typIoriginalTree
                     {-# LINE 28943 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 28949 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 28955 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28961 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28967 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28973 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 28979 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 28985 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 28991 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
  _sem_TypeName_SetOfTypeName :: T_Annotation ->
                                T_TypeName ->
                                T_TypeName
  _sem_TypeName_SetOfTypeName ann_ typ_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOnamedType :: (Maybe TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _canType :: ([NameComponent] -> [NameComponent])
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: TypeName
                _lhsOoriginalTree :: TypeName
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 36, column 10)
                _lhsOnamedType =
                    ({-# LINE 36 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either (const Nothing) Just _tpe
                     {-# LINE 29026 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 37, column 10)
                _annOtpe =
                    ({-# LINE 37 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     either Left (const $ Left []) _tpe
                     {-# LINE 29032 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 51, column 10)
                _canType =
                    ({-# LINE 51 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     \x -> case x of
                        [Nmc nc] -> [Nmc $ T.unpack $ canonicalizeTypeName (tcfDialect _lhsIflags) $ T.pack nc]
                        _ -> x
                     {-# LINE 29040 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag"(line 74, column 9)
                _tpe =
                    ({-# LINE 74 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Misc.ag" #-}
                     maybe (Left []) Right _typInamedType
                     >>= Right . (\t -> t{teType = Pseudo $ SetOfType $ teType t})
                     {-# LINE 29047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetOfTypeName _annIannotatedTree _typIannotatedTree
                     {-# LINE 29053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     SetOfTypeName _annIoriginalTree _typIoriginalTree
                     {-# LINE 29059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29095 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29101 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29107 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOnamedType,_lhsOoriginalTree)))
  -- TypeNameList ------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : TypeNameList 
           originalTree         : TypeNameList 
     alternatives:
        alternative Cons:
           child hd             : TypeName 
           child tl             : TypeNameList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type TypeNameList = [TypeName]
  -- cata
  _sem_TypeNameList :: TypeNameList ->
                      T_TypeNameList
  _sem_TypeNameList list =
      (Prelude.foldr _sem_TypeNameList_Cons _sem_TypeNameList_Nil (Prelude.map _sem_TypeName list))
  -- semantic domain
  type T_TypeNameList = Catalog ->
                        TypeCheckFlags ->
                        (Maybe TypeExtra) ->
                        ( TypeNameList,TypeNameList)
  data Inh_TypeNameList = Inh_TypeNameList {_cat_Inh_TypeNameList :: Catalog,_flags_Inh_TypeNameList :: TypeCheckFlags,_imCast_Inh_TypeNameList :: (Maybe TypeExtra)}
  data Syn_TypeNameList = Syn_TypeNameList {_annotatedTree_Syn_TypeNameList :: TypeNameList,_originalTree_Syn_TypeNameList :: TypeNameList}
  _wrap_TypeNameList :: T_TypeNameList ->
                       Inh_TypeNameList ->
                       Syn_TypeNameList
  _wrap_TypeNameList sem (Inh_TypeNameList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_TypeNameList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_TypeNameList_Cons :: T_TypeName ->
                           T_TypeNameList ->
                           T_TypeNameList
  _sem_TypeNameList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: TypeNameList
                _lhsOoriginalTree :: TypeNameList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: TypeName
                _hdInamedType :: (Maybe TypeExtra)
                _hdIoriginalTree :: TypeName
                _tlIannotatedTree :: TypeNameList
                _tlIoriginalTree :: TypeNameList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 29179 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 29185 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29191 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29197 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29203 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29209 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29215 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29221 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29227 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29233 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdInamedType,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_TypeNameList_Nil :: T_TypeNameList
  _sem_TypeNameList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: TypeNameList
                _lhsOoriginalTree :: TypeNameList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 29251 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 29257 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29263 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29269 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- VarDef ------------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : VarDef 
           originalTree         : VarDef 
     alternatives:
        alternative VarDef:
           child ann            : Annotation 
           child name           : {NameComponent}
           child typ            : TypeName 
           child value          : {Maybe ScalarExpr}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative ParamAlias:
           child ann            : Annotation 
           child name           : {NameComponent}
           child i              : {Integer}
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative VarAlias:
           child ann            : Annotation 
           child name           : {NameComponent}
           child aliased        : Name 
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  data VarDef = VarDef (Annotation) (NameComponent) (TypeName) ((Maybe ScalarExpr))
              | ParamAlias (Annotation) (NameComponent) (Integer)
              | VarAlias (Annotation) (NameComponent) (Name)
              deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_VarDef :: VarDef ->
                T_VarDef
  _sem_VarDef (VarDef _ann _name _typ _value) =
      (_sem_VarDef_VarDef (_sem_Annotation _ann) _name (_sem_TypeName _typ) _value)
  _sem_VarDef (ParamAlias _ann _name _i) =
      (_sem_VarDef_ParamAlias (_sem_Annotation _ann) _name _i)
  _sem_VarDef (VarAlias _ann _name _aliased) =
      (_sem_VarDef_VarAlias (_sem_Annotation _ann) _name (_sem_Name _aliased))
  -- semantic domain
  type T_VarDef = Catalog ->
                  TypeCheckFlags ->
                  (Maybe TypeExtra) ->
                  ( VarDef,VarDef)
  data Inh_VarDef = Inh_VarDef {_cat_Inh_VarDef :: Catalog,_flags_Inh_VarDef :: TypeCheckFlags,_imCast_Inh_VarDef :: (Maybe TypeExtra)}
  data Syn_VarDef = Syn_VarDef {_annotatedTree_Syn_VarDef :: VarDef,_originalTree_Syn_VarDef :: VarDef}
  _wrap_VarDef :: T_VarDef ->
                 Inh_VarDef ->
                 Syn_VarDef
  _wrap_VarDef sem (Inh_VarDef _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_VarDef _lhsOannotatedTree _lhsOoriginalTree))
  _sem_VarDef_VarDef :: T_Annotation ->
                       NameComponent ->
                       T_TypeName ->
                       (Maybe ScalarExpr) ->
                       T_VarDef
  _sem_VarDef_VarDef ann_ name_ typ_ value_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: VarDef
                _lhsOoriginalTree :: VarDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _typOcat :: Catalog
                _typOflags :: TypeCheckFlags
                _typOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _typIannotatedTree :: TypeName
                _typInamedType :: (Maybe TypeExtra)
                _typIoriginalTree :: TypeName
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 232, column 21)
                _annOtpe =
                    ({-# LINE 232 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 29359 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     VarDef _annIannotatedTree name_ _typIannotatedTree value_
                     {-# LINE 29365 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     VarDef _annIoriginalTree name_ _typIoriginalTree value_
                     {-# LINE 29371 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29377 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29383 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29389 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29395 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29401 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29407 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29413 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _typOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29419 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _typIannotatedTree,_typInamedType,_typIoriginalTree) =
                    typ_ _typOcat _typOflags _typOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_VarDef_ParamAlias :: T_Annotation ->
                           NameComponent ->
                           Integer ->
                           T_VarDef
  _sem_VarDef_ParamAlias ann_ name_ i_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: VarDef
                _lhsOoriginalTree :: VarDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 229, column 25)
                _annOtpe =
                    ({-# LINE 229 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 29446 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ParamAlias _annIannotatedTree name_ i_
                     {-# LINE 29452 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     ParamAlias _annIoriginalTree name_ i_
                     {-# LINE 29458 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29464 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29470 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29476 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29482 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29488 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_VarDef_VarAlias :: T_Annotation ->
                         NameComponent ->
                         T_Name ->
                         T_VarDef
  _sem_VarDef_VarAlias ann_ name_ aliased_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _aliasedOtpe :: (Either [TypeError] TypeExtra)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _lhsOannotatedTree :: VarDef
                _lhsOoriginalTree :: VarDef
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _aliasedOcat :: Catalog
                _aliasedOflags :: TypeCheckFlags
                _aliasedOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _aliasedIannotatedTree :: Name
                _aliasedIoriginalTree :: Name
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 230, column 23)
                _aliasedOtpe =
                    ({-# LINE 230 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 29519 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag"(line 231, column 23)
                _annOtpe =
                    ({-# LINE 231 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/Boilerplate.ag" #-}
                     Left []
                     {-# LINE 29525 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     VarAlias _annIannotatedTree name_ _aliasedIannotatedTree
                     {-# LINE 29531 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     VarAlias _annIoriginalTree name_ _aliasedIoriginalTree
                     {-# LINE 29537 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29543 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29549 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29555 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29561 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29567 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _aliasedOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29573 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _aliasedOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29579 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _aliasedOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29585 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _aliasedIannotatedTree,_aliasedIoriginalTree) =
                    aliased_ _aliasedOcat _aliasedOflags _aliasedOimCast _aliasedOtpe
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- VarDefList --------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : VarDefList 
           originalTree         : VarDefList 
     alternatives:
        alternative Cons:
           child hd             : VarDef 
           child tl             : VarDefList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type VarDefList = [VarDef]
  -- cata
  _sem_VarDefList :: VarDefList ->
                    T_VarDefList
  _sem_VarDefList list =
      (Prelude.foldr _sem_VarDefList_Cons _sem_VarDefList_Nil (Prelude.map _sem_VarDef list))
  -- semantic domain
  type T_VarDefList = Catalog ->
                      TypeCheckFlags ->
                      (Maybe TypeExtra) ->
                      ( VarDefList,VarDefList)
  data Inh_VarDefList = Inh_VarDefList {_cat_Inh_VarDefList :: Catalog,_flags_Inh_VarDefList :: TypeCheckFlags,_imCast_Inh_VarDefList :: (Maybe TypeExtra)}
  data Syn_VarDefList = Syn_VarDefList {_annotatedTree_Syn_VarDefList :: VarDefList,_originalTree_Syn_VarDefList :: VarDefList}
  _wrap_VarDefList :: T_VarDefList ->
                     Inh_VarDefList ->
                     Syn_VarDefList
  _wrap_VarDefList sem (Inh_VarDefList _lhsIcat _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOoriginalTree) = sem _lhsIcat _lhsIflags _lhsIimCast
       in  (Syn_VarDefList _lhsOannotatedTree _lhsOoriginalTree))
  _sem_VarDefList_Cons :: T_VarDef ->
                         T_VarDefList ->
                         T_VarDefList
  _sem_VarDefList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: VarDefList
                _lhsOoriginalTree :: VarDefList
                _hdOcat :: Catalog
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: VarDef
                _hdIoriginalTree :: VarDef
                _tlIannotatedTree :: VarDefList
                _tlIoriginalTree :: VarDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 29656 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 29662 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29668 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29674 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29680 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29686 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29692 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29698 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29704 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29710 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIoriginalTree) =
                    hd_ _hdOcat _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  _sem_VarDefList_Nil :: T_VarDefList
  _sem_VarDefList_Nil =
      (\ _lhsIcat
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOannotatedTree :: VarDefList
                _lhsOoriginalTree :: VarDefList
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 29728 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 29734 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 29740 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29746 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOoriginalTree)))
  -- WithQuery ---------------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           catExtIncomp         : Either [TypeError] Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : WithQuery 
           colAliases           : Maybe [NameComponent]
           name                 : Text
           originalTree         : WithQuery 
           upType               : Maybe [(Text,TypeExtra)]
     alternatives:
        alternative WithQuery:
           child ann            : Annotation 
           child name           : {NameComponent}
           child colAliases     : {Maybe [NameComponent]}
           child ex             : QueryExpr 
           visit 0:
              local tpee        : {Either [TypeError] [(Text,TypeExtra)]}
              local tpe         : {Either [TypeError] TypeExtra}
              local annotatedTree : _
              local originalTree : _
  -}
  data WithQuery = WithQuery (Annotation) (NameComponent) ((Maybe [NameComponent])) (QueryExpr)
                 deriving ( Data,Eq,Show,Typeable)
  -- cata
  _sem_WithQuery :: WithQuery ->
                   T_WithQuery
  _sem_WithQuery (WithQuery _ann _name _colAliases _ex) =
      (_sem_WithQuery_WithQuery (_sem_Annotation _ann) _name _colAliases (_sem_QueryExpr _ex))
  -- semantic domain
  type T_WithQuery = Catalog ->
                     (Either [TypeError] Catalog) ->
                     TypeCheckFlags ->
                     (Maybe TypeExtra) ->
                     ( WithQuery,(Maybe [NameComponent]),Text,WithQuery,(Maybe [(Text,TypeExtra)]))
  data Inh_WithQuery = Inh_WithQuery {_cat_Inh_WithQuery :: Catalog,_catExtIncomp_Inh_WithQuery :: (Either [TypeError] Catalog),_flags_Inh_WithQuery :: TypeCheckFlags,_imCast_Inh_WithQuery :: (Maybe TypeExtra)}
  data Syn_WithQuery = Syn_WithQuery {_annotatedTree_Syn_WithQuery :: WithQuery,_colAliases_Syn_WithQuery :: (Maybe [NameComponent]),_name_Syn_WithQuery :: Text,_originalTree_Syn_WithQuery :: WithQuery,_upType_Syn_WithQuery :: (Maybe [(Text,TypeExtra)])}
  _wrap_WithQuery :: T_WithQuery ->
                    Inh_WithQuery ->
                    Syn_WithQuery
  _wrap_WithQuery sem (Inh_WithQuery _lhsIcat _lhsIcatExtIncomp _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOcolAliases,_lhsOname,_lhsOoriginalTree,_lhsOupType) = sem _lhsIcat _lhsIcatExtIncomp _lhsIflags _lhsIimCast
       in  (Syn_WithQuery _lhsOannotatedTree _lhsOcolAliases _lhsOname _lhsOoriginalTree _lhsOupType))
  _sem_WithQuery_WithQuery :: T_Annotation ->
                             NameComponent ->
                             (Maybe [NameComponent]) ->
                             T_QueryExpr ->
                             T_WithQuery
  _sem_WithQuery_WithQuery ann_ name_ colAliases_ ex_ =
      (\ _lhsIcat
         _lhsIcatExtIncomp
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOname :: Text
                _lhsOannotatedTree :: WithQuery
                _lhsOcolAliases :: (Maybe [NameComponent])
                _tpee :: (Either [TypeError] [(Text,TypeExtra)])
                _tpe :: (Either [TypeError] TypeExtra)
                _lhsOupType :: (Maybe [(Text,TypeExtra)])
                _exOouterDownEnv :: (Maybe Environment)
                _annOtpe :: (Either [TypeError] TypeExtra)
                _exOexpectedType :: (Maybe [TypeExtra])
                _exOassignmentCastContext :: Bool
                _lhsOoriginalTree :: WithQuery
                _annOcat :: Catalog
                _annOflags :: TypeCheckFlags
                _annOimCast :: (Maybe TypeExtra)
                _exOcat :: Catalog
                _exOflags :: TypeCheckFlags
                _exOimCast :: (Maybe TypeExtra)
                _annIannotatedTree :: Annotation
                _annIoriginalTree :: Annotation
                _exIannotatedTree :: QueryExpr
                _exIoriginalTree :: QueryExpr
                _exIupType :: (Maybe [(Text,TypeExtra)])
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 56, column 9)
                _lhsOname =
                    ({-# LINE 56 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     ncStrT name_
                     {-# LINE 29832 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 57, column 9)
                _lhsOannotatedTree =
                    ({-# LINE 57 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     WithQuery _annIannotatedTree name_ colAliases_ _exIannotatedTree
                     {-# LINE 29838 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 58, column 9)
                _lhsOcolAliases =
                    ({-# LINE 58 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     colAliases_
                     {-# LINE 29844 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 62, column 9)
                _tpee =
                    ({-# LINE 62 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     maybe (Left []) Right _exIupType
                     {-# LINE 29850 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 64, column 9)
                _tpe =
                    ({-# LINE 64 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM (mkTypeExtra . CompositeType) _tpee
                     {-# LINE 29856 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 66, column 9)
                _lhsOupType =
                    ({-# LINE 66 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     either (const Nothing) Just _tpee
                     {-# LINE 29862 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 95, column 15)
                _exOouterDownEnv =
                    ({-# LINE 95 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Nothing
                     {-# LINE 29868 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 101, column 9)
                _annOtpe =
                    ({-# LINE 101 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     Left []
                     {-# LINE 29874 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 102, column 9)
                _exOexpectedType =
                    ({-# LINE 102 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     liftM (map snd) _exIupType
                     {-# LINE 29880 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag"(line 846, column 27)
                _exOassignmentCastContext =
                    ({-# LINE 846 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/ScalarExprs.ag" #-}
                     False
                     {-# LINE 29886 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WithQuery _annIannotatedTree name_ colAliases_ _exIannotatedTree
                     {-# LINE 29892 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     WithQuery _annIoriginalTree name_ colAliases_ _exIoriginalTree
                     {-# LINE 29898 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 29904 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29910 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29916 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _annOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29922 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 29928 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 29934 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _exOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 29940 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _annIannotatedTree,_annIoriginalTree) =
                    ann_ _annOcat _annOflags _annOimCast _annOtpe
                ( _exIannotatedTree,_exIoriginalTree,_exIupType) =
                    ex_ _exOassignmentCastContext _exOcat _exOexpectedType _exOflags _exOimCast _exOouterDownEnv
            in  ( _lhsOannotatedTree,_lhsOcolAliases,_lhsOname,_lhsOoriginalTree,_lhsOupType)))
  -- WithQueryList -----------------------------------------------
  {-
     visit 0:
        inherited attributes:
           cat                  : Catalog
           catExtIncomp         : Either [TypeError] Catalog
           flags                : TypeCheckFlags
           imCast               : Maybe TypeExtra
        synthesized attributes:
           annotatedTree        : WithQueryList 
           catExtComp           : Either [TypeError] Catalog
           originalTree         : WithQueryList 
     alternatives:
        alternative Cons:
           child hd             : WithQuery 
           child tl             : WithQueryList 
           visit 0:
              local annotatedTree : _
              local originalTree : _
        alternative Nil:
           visit 0:
              local annotatedTree : _
              local originalTree : _
  -}
  type WithQueryList = [WithQuery]
  -- cata
  _sem_WithQueryList :: WithQueryList ->
                       T_WithQueryList
  _sem_WithQueryList list =
      (Prelude.foldr _sem_WithQueryList_Cons _sem_WithQueryList_Nil (Prelude.map _sem_WithQuery list))
  -- semantic domain
  type T_WithQueryList = Catalog ->
                         (Either [TypeError] Catalog) ->
                         TypeCheckFlags ->
                         (Maybe TypeExtra) ->
                         ( WithQueryList,(Either [TypeError] Catalog),WithQueryList)
  data Inh_WithQueryList = Inh_WithQueryList {_cat_Inh_WithQueryList :: Catalog,_catExtIncomp_Inh_WithQueryList :: (Either [TypeError] Catalog),_flags_Inh_WithQueryList :: TypeCheckFlags,_imCast_Inh_WithQueryList :: (Maybe TypeExtra)}
  data Syn_WithQueryList = Syn_WithQueryList {_annotatedTree_Syn_WithQueryList :: WithQueryList,_catExtComp_Syn_WithQueryList :: (Either [TypeError] Catalog),_originalTree_Syn_WithQueryList :: WithQueryList}
  _wrap_WithQueryList :: T_WithQueryList ->
                        Inh_WithQueryList ->
                        Syn_WithQueryList
  _wrap_WithQueryList sem (Inh_WithQueryList _lhsIcat _lhsIcatExtIncomp _lhsIflags _lhsIimCast) =
      (let ( _lhsOannotatedTree,_lhsOcatExtComp,_lhsOoriginalTree) = sem _lhsIcat _lhsIcatExtIncomp _lhsIflags _lhsIimCast
       in  (Syn_WithQueryList _lhsOannotatedTree _lhsOcatExtComp _lhsOoriginalTree))
  _sem_WithQueryList_Cons :: T_WithQuery ->
                            T_WithQueryList ->
                            T_WithQueryList
  _sem_WithQueryList_Cons hd_ tl_ =
      (\ _lhsIcat
         _lhsIcatExtIncomp
         _lhsIflags
         _lhsIimCast ->
           (let _tlOcatExtIncomp :: (Either [TypeError] Catalog)
                _hdOcat :: Catalog
                _lhsOannotatedTree :: WithQueryList
                _lhsOoriginalTree :: WithQueryList
                _lhsOcatExtComp :: (Either [TypeError] Catalog)
                _hdOcatExtIncomp :: (Either [TypeError] Catalog)
                _hdOflags :: TypeCheckFlags
                _hdOimCast :: (Maybe TypeExtra)
                _tlOcat :: Catalog
                _tlOflags :: TypeCheckFlags
                _tlOimCast :: (Maybe TypeExtra)
                _hdIannotatedTree :: WithQuery
                _hdIcolAliases :: (Maybe [NameComponent])
                _hdIname :: Text
                _hdIoriginalTree :: WithQuery
                _hdIupType :: (Maybe [(Text,TypeExtra)])
                _tlIannotatedTree :: WithQueryList
                _tlIcatExtComp :: (Either [TypeError] Catalog)
                _tlIoriginalTree :: WithQueryList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 34, column 9)
                _tlOcatExtIncomp =
                    ({-# LINE 34 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     do
                     let getWithEx (WithQuery _ _ _ ex) = ex
                     upType' <- maybe (Left . anErrs . ann . getWithEx $ _hdIannotatedTree) Right
                       _hdIupType
                     colTyPairs <- mapM (secondM typeToCatName) upType'
                     colTyPairs' <- case _hdIcolAliases of
                       Just alsNms -> do
                         unless (length alsNms == length colTyPairs) $
                           Left [BadCatalogUpdate "number of aliases differs from number of expressions in the select"]
                         return $ zip (map ncStrT alsNms) $ map snd colTyPairs
                       Nothing -> return colTyPairs
                     updateCatalog [CatCreateTable ("public", _hdIname ) colTyPairs'] =<< _lhsIcatExtIncomp
                     {-# LINE 30033 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 47, column 9)
                _hdOcat =
                    ({-# LINE 47 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     case _lhsIcatExtIncomp of
                       Right catExtIncomp -> catExtIncomp
                       Left _ -> _lhsIcat
                     {-# LINE 30041 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIannotatedTree _tlIannotatedTree
                     {-# LINE 30047 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     (:) _hdIoriginalTree _tlIoriginalTree
                     {-# LINE 30053 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 30059 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 30065 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (up)
                _lhsOcatExtComp =
                    ({-# LINE 29 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _tlIcatExtComp
                     {-# LINE 30071 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOcatExtIncomp =
                    ({-# LINE 24 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIcatExtIncomp
                     {-# LINE 30077 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 30083 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _hdOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 30089 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOcat =
                    ({-# LINE 116 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIcat
                     {-# LINE 30095 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOflags =
                    ({-# LINE 117 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIflags
                     {-# LINE 30101 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- copy rule (down)
                _tlOimCast =
                    ({-# LINE 129 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _lhsIimCast
                     {-# LINE 30107 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                ( _hdIannotatedTree,_hdIcolAliases,_hdIname,_hdIoriginalTree,_hdIupType) =
                    hd_ _hdOcat _hdOcatExtIncomp _hdOflags _hdOimCast
                ( _tlIannotatedTree,_tlIcatExtComp,_tlIoriginalTree) =
                    tl_ _tlOcat _tlOcatExtIncomp _tlOflags _tlOimCast
            in  ( _lhsOannotatedTree,_lhsOcatExtComp,_lhsOoriginalTree)))
  _sem_WithQueryList_Nil :: T_WithQueryList
  _sem_WithQueryList_Nil =
      (\ _lhsIcat
         _lhsIcatExtIncomp
         _lhsIflags
         _lhsIimCast ->
           (let _lhsOcatExtComp :: (Either [TypeError] Catalog)
                _lhsOannotatedTree :: WithQueryList
                _lhsOoriginalTree :: WithQueryList
                -- "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag"(line 52, column 9)
                _lhsOcatExtComp =
                    ({-# LINE 52 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/QueryExprs/QueryExprs.ag" #-}
                     _lhsIcatExtIncomp
                     {-# LINE 30127 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _annotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 30133 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _originalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     []
                     {-# LINE 30139 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOannotatedTree =
                    ({-# LINE 118 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _annotatedTree
                     {-# LINE 30145 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
                -- self rule
                _lhsOoriginalTree =
                    ({-# LINE 119 "hssqlppp/src/Database/HsSqlPpp/Internals/TypeChecking/TypeChecking.ag" #-}
                     _originalTree
                     {-# LINE 30151 "hssqlppp/src/Database/HsSqlPpp/Internals/AstInternal.hs" #-}
                     )
            in  ( _lhsOannotatedTree,_lhsOcatExtComp,_lhsOoriginalTree)))
  