hssqlppp-0.5.18: SQL parser and type checker

Safe HaskellNone
LanguageHaskell2010

Database.HsSqlPpp.Utility

Contents

Description

This module contains a collection of utility functions

Synopsis

ast utils

resetAnnotations :: Data a => a -> a

replace all the annotations in a tree with emptyAnnotation

queryType :: Catalog -> Text -> Maybe Type

Gets the type of the sql source passed in. Expects the string to contain a query expr

canonicalizeTypeName :: Text -> Text

convert the name of a type to its canonical name. For types without multiple names, it returns the name unchanged

canonicalizeTypeNames :: Data a => a -> a

run canonicalizeTypeName on all the TypeName nodes in an ast

typechecked ast utils

addExplicitCasts :: Data a => a -> a

run on a typechecked tree. Finds all the places where an implicit cast has been used in the typechecking and inserts an explicit cast

addImplicitCasts :: Data a => Catalog -> a -> a

variation of the above, which uses ImplicitCast ctor

tcTreeInfo :: Data a => a -> (Maybe TypeExtra, [([TypeError], Maybe SourcePosition)], [QueryExpr], [ScalarExpr])

Gets some information useful for checking a typechecked tree returns the type of the top level node, a list of type errors from the tree, a list of the queryexpr nodes, and a list of the scalar exprs respectively, which have their type as nothing which indicates that the typechecking didn't complete successfully

emacsShowErrors :: [([TypeError], Maybe SourcePosition)] -> String

show a type error list in emacs format