graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Data.Text.Casing

Description

This module is inspired by casing package. Instead of String this package uses Data.Text.Text

  • PascalCase - no spacing between words, first letter in word is uppercase, all others are lowercase.
  • camelCase - like PascalCase, but the very first letter is lowercase.
  • snake_Case - underscores delimit words, case is unrestricted.
Synopsis

Documentation

data GQLNameIdentifier Source #

An opaque type, representing a parsed identifier with prefix and suffixes.

data NameOrigin Source #

Represents the origin of a name entity.

For a custom table name foo, the select by pk field name elements:

However, for a table name foo_bar, the select by pk field name elements foo, bar, by and pk are all AutogeneratedName

Instances

Instances details
Show NameOrigin Source # 
Instance details

Defined in Data.Text.Casing

fromTupleWith :: NameOrigin -> (Name, [NameSuffix]) -> GQLNameIdentifier Source #

fromCustomTuple :: (Name, [NameSuffix]) -> GQLNameIdentifier Source #

transformNameWith :: (Text -> Text) -> Name -> Name Source #

transforms a graphql name with a transforming function

Note: This will return the graphql name without transformation if the transformed name is not a valid GraphQL identifier

transformNameAndOriginWith :: (Text -> Text) -> NameWithOrigin -> NameWithOrigin Source #

same as transformNameWith but will not transform if the name is a custom name

transformGQLSuffixWith :: (Text -> Text) -> NameSuffix -> NameSuffix Source #

similar to transformNameWith but transforms NameSuffix instead of Name

transformGQLSuffixAndOriginWith :: (Text -> Text) -> NameSuffixWithOrigin -> NameSuffixWithOrigin Source #

This is essentially same as second transformGQLSuffixWith

transformGQLIdentifierWith :: (Text -> Text) -> GQLNameIdentifier -> GQLNameIdentifier Source #

transforms a GQLNameIdentifier; this will apply the transformations on prefix as well as suffixes

identifierToList :: GQLNameIdentifier -> [Text] Source #

converts identifiers to Text (i.e. unNames and unNameSuffixs identifiers)

toSnakeT :: [Text] -> Text Source #

To snake_case for Data.Text

>>> toSnakeT ["my","random","text","list"]
"my_random_text_list"

toPascalT :: [Text] -> Text Source #

To PascalCase for Data.Text

>>> toPascalT ["my","random","text","list"]
"MyRandomTextList"

toCamelT :: [Text] -> Text Source #

To camelCase for Data.Text

>>> toCamelT ["my","random","text","list"]
"myRandomTextList"

toSnakeG :: GQLNameIdentifier -> Name Source #

To snake_case for GQLNameIdentifier

toPascalG :: GQLNameIdentifier -> Name Source #

To PascalCase for GQLNameIdentifier

toCamelG :: GQLNameIdentifier -> Name Source #

To camelCase for GQLNameIdentifier

transformPrefixAndSuffixAndConcat :: GQLNameIdentifier -> (Text -> Text) -> (Text -> Text) -> Name Source #

Transforms GQLNameIdentifier and returns a G.Name

fromSnake :: Text -> [Text] Source #

Convert from snake_cased

>>> fromSnake "_hello_world_foo"
["_hello","world","foo"]

snakeToPascal :: Text -> Text Source #

Directly convert to PascalCase through fromSnake

snakeToCamel :: Text -> Text Source #

Directly convert to camelCase through fromSnake

lowerFirstChar :: Text -> Text Source #

An internal helper function to lowercase the first character

upperFirstChar :: Text -> Text Source #

An internal helper function to uppercase the first character