persistent-2.17.1.0: Type-safe, multi-backend data serialization.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Database.Persist.Quasi.Internal.TypeParser

Synopsis

- data TypeExpr
  - = TypeApplication TypeExpr [TypeExpr]
  - | TypeConstructorExpr TypeConstructor
  - | TypeLitString String
  - | TypeLitInt String
  - | TypeLitPromotedConstructor TypeConstructor
- data TypeConstructor
  - = ListConstructor
  - | TypeConstructor String
- typeExpr :: MonadParsec e String m => m TypeExpr
- innerTypeExpr :: MonadParsec e String m => m TypeExpr
- typeExprContent :: TypeExpr -> Text

# Documentation

data TypeExpr Source #

A parsed type expression.

Since: 2.17.1.0

Constructors

TypeApplication TypeExpr [TypeExpr] |
TypeConstructorExpr TypeConstructor |
TypeLitString String |
TypeLitInt String |
TypeLitPromotedConstructor TypeConstructor |

#### Instances

Instances details

Show TypeExpr Source # |
Instance details Defined in Database.Persist.Quasi.Internal.TypeParser Methods showsPrec :: Int -> TypeExpr -> ShowS Source # show :: TypeExpr -> String Source # showList :: [TypeExpr] -> ShowS Source #
Eq TypeExpr Source # |
Instance details Defined in Database.Persist.Quasi.Internal.TypeParser Methods (==) :: TypeExpr -> TypeExpr -> Bool Source # (/=) :: TypeExpr -> TypeExpr -> Bool Source #

data TypeConstructor Source #

A parsed type constructor.

Since: 2.17.1.0

Constructors

ListConstructor |
TypeConstructor String |

#### Instances

Instances details

Show TypeConstructor Source # |
Instance details Defined in Database.Persist.Quasi.Internal.TypeParser Methods showsPrec :: Int -> TypeConstructor -> ShowS Source # show :: TypeConstructor -> String Source # showList :: [TypeConstructor] -> ShowS Source #
Eq TypeConstructor Source # |
Instance details Defined in Database.Persist.Quasi.Internal.TypeParser Methods (==) :: TypeConstructor -> TypeConstructor -> Bool Source # (/=) :: TypeConstructor -> TypeConstructor -> Bool Source #

typeExpr :: MonadParsec e String m => m TypeExpr Source #

Parses a Persistent-style type expression. Persistent's type expressions are largely similar to Haskell's, but with a few differences:

1. Syntactic sugar is not currently supported for constructing types other than List.
2. Only certain typelevel literals are supported: Strings, Ints, and promoted type constructors.
3. Because they must be parsed as part of an entity field definition, top-level applications of non-nullary type constructors (except for the sugary List constructor) must be parenthesized.

VALID: Int VALID: [Maybe Int] VALID: (Maybe Int) INVALID: Maybe Int

Since: 2.17.1.0

innerTypeExpr :: MonadParsec e String m => m TypeExpr Source #

Parses a type expression in non-top-level contexts, where an unparenthesized type constructor application is acceptable.

Since: 2.17.1.0

typeExprContent :: TypeExpr -> Text Source #

Given a TypeExpr, renders it back to a String in a canonical form that looks normal to humans and is re-parseable when making an UnboundEntityDef that uses it.

Since: 2.17.1.0