Copyright(c) digitally induced GmbH 2020
Safe HaskellNone

IHP.NameSupport

Description

 
Synopsis

Documentation

tableNameToModelName :: Text -> Text Source #

Transforms a underscore table name to a camel case model name.

>>> tableNameToModelName "users"
"User"
>>> tableNameToModelName "projects"
"Project"

columnNameToFieldName :: Text -> Text Source #

Transforms a underscore table column name to a camel case attribute name for use in haskell.

>>> columnNameToFieldName "email"
"email"
>>> columnNameToFieldName "project_id"
"projectId"

modelNameToTableName :: Text -> Text Source #

Transforms a camel case model name to a underscored table name.

>>> modelNameToTableName "User"
"users"
>>> modelNameToTableName "UserProject"
"user_projects"

humanize :: Text -> Text Source #

Returns a more friendly version for an identifier

ucfirst :: Text -> Text Source #

Make a text's first character uppercase

>>> ucfirst "hello world"
"Hello World"
>>> ucfirst "Already uppercase"
"Already uppercase"

lcfirst :: Text -> Text Source #

Make a text's first character lowercase

>>> lcfirst "Hello World"
"hello World"
>>> lcfirst "alread lowercase"
"already lowercase"

fieldNameToColumnName :: Text -> Text Source #

Transforms a camel case attribute name from haskell to a underscore table column name for the database.

>>> fieldNameToColumnName "email"
"email"
>>> fieldNameToColumnName "projectId"
"project_id"

escapeHaskellKeyword :: Text -> Text Source #

Add '_' to the end of a name if it is a reserved haskell keyword

>>> escapeHaskellKeyword "test"
"test"
>>> escapeHaskellKeyword "type"
"type_"

tableNameToControllerName :: Text -> Text Source #

Transforms a underscore table name to a name for a controller

>>> tableNameToControllerName "users"
"Users"
>>> tableNameToControllerName "projects"
"Projects"
>>> tableNameToControllerName "user_projects"
"UserProjects"

toSlug :: Text -> Text Source #

Transforms a string to a value to be safely used in urls

>>> toSlug "IHP Release: 21.08.2020 (v21082020)"
"ihp-release-21-08-2020-v21082020"
>>> toSlug "Hallo! @ Welt"
"hallo-welt"