data-basic-0.3.0.0: A database library with a focus on ease of use, type safety and useful error messages

Safe HaskellNone
LanguageHaskell2010

Internal.Data.Basic.TH.Helper

Description

module Internal. : Data.Basic.TH.Types Description : Data types and utility function used during TH generation phase License : MIT

This module Internal.contains helper functions that are used in code generation process.

Synopsis

Documentation

listToTypeLevel :: [Type] -> Type Source #

lifts a list of types to a type level (i.e. typelevel list) e.g. `listToTypeLeve [Int, String, Double] = '[ Int, String, Double ]`

addFields :: Exp -> Int -> Exp Source #

Used to append n times `$ field` to the expression

addField :: Exp -> Exp Source #

Used to append `$ field` at the end of the expression

quasyPlural :: Text -> Text Source #

returns a plural of a known noun. Basically just appends s or es

nameUnnamedConstraints :: Throws ParseError m => EntityInfo -> m EntityInfo Source #

Tries to name multiples constraints

nameUnnamedConstraint :: Throws ParseError m => EntityInfo -> Constraint -> m Constraint Source #

Mechanism for naming unnamed constraints. If a constraint cannot be named, an error is trown

nameConstraint :: Text -> [NameComponent] -> Text Source #

Provides default naming scheme for constraints

getName :: Name -> Text Source #

Converts a Name to a plain text @TODO test complex naming schemes

getDynamicDefaultColumns :: ParseContext -> EntityInfo -> [ColumnInfo] Source #

Retrieves a list of optional columns in an entity

getEntityByName :: Throws ParseError m => Name -> [EntityInfo] -> m EntityInfo Source #

Tries to retrieve entity information. If an entity with that name doesn't exist an error is thrown.

getEntityBySQLName :: Throws ParseError m => Name -> [EntityInfo] -> m EntityInfo Source #

Tries to retrieve entity information. If an entity with that name doesn't exist an error is thrown.

getColumn :: Throws ParseError m => EntityInfo -> Text -> m ColumnInfo Source #

Tries to retrieve column information from entity. If a column with that name doesn't exist an error is thrown.

normalizeName :: Text -> Text Source #

Converts camel case or snake case to normal form. Examples:

normalizeName "ABCDE"

"abcde" > normalizeName ABC_DE "abcDe" > normalizeName AbcDe "abcDe" > normalizeName "abcDe" "abcDe" > normalizeName "abcde" "abcde"

getEntityPrimaryKey :: ParseContext -> EntityInfo -> Maybe PrimaryKeyConstraint Source #

Retrieves the primary key for an entity from ParseContext

columnNameToLensName :: Text -> Text Source #

Generates name for the column lens (i.e. lowercases first letter)