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

Safe Haskell | None
Language | Haskell2010

Database.Persist.Quasi.Internal.ModelParser

Synopsis

- data SourceLoc = SourceLoc {
  - locFile :: Text
  - locStartLine :: Int
  - locStartCol :: Int
  }
- data Attribute
  - = Assignment Text Text
  - | Parenthetical Text
  - | PText Text
  - | Quotation Text
- attribute :: Parser Attribute
- attributeContent :: Attribute -> Text
- data Directive = Directive {
  - directiveDocCommentBlock :: Maybe DocCommentBlock
  - directiveName :: DirectiveName
  - directiveAttributes :: [Attribute]
  - directivePos :: SourcePos
  }
- directiveContent :: Directive -> [Text]
- data EntityField = EntityField {
  - entityFieldDocCommentBlock :: Maybe DocCommentBlock
  - entityFieldStrictness :: Maybe FieldStrictness
  - entityFieldName :: FieldName
  - entityFieldType :: TypeExpr
  - entityFieldAttributes :: [Attribute]
  - entityFieldPos :: SourcePos
  }
- entityField :: Parser Member
- entityFieldContent :: EntityField -> [Text]
- newtype FieldName = FieldName Text
- fieldName :: Parser FieldName
- data ParsedEntityDef = ParsedEntityDef {
  - parsedEntityDefComments :: [Text]
  - parsedEntityDefEntityName :: EntityNameHS
  - parsedEntityDefIsSum :: Bool
  - parsedEntityDefEntityAttributes :: [Attribute]
  - parsedEntityDefFields :: [(EntityField, Maybe Text)]
  - parsedEntityDefDirectives :: [(Directive, Maybe Text)]
  - parsedEntityDefExtras :: Map Text [ExtraLine]
  - parsedEntityDefSpan :: Maybe SourceSpan
  }
- parseSource :: PersistSettings -> Maybe SourceLoc -> Text -> ParseResult [ParsedEntityDef]
- memberEntityFields :: Member -> [EntityField]
- data ParserWarning
- parserWarningMessage :: ParserWarning -> String
- type ParseResult a = (Set ParserWarning, Either (ParseErrorBundle String Void) a)
- type CumulativeParseResult a = (Set ParserWarning, Either [EntityParseError] a)
- toCumulativeParseResult :: Monoid a => [ParseResult a] -> CumulativeParseResult a
- renderErrors :: [EntityParseError] -> String
- runConfiguredParser :: PersistSettings -> ExtraState -> Parser a -> String -> String -> InternalParseResult a
- data ParserErrorLevel
  - = LevelError
  - | LevelWarning
- initialExtraState :: ExtraState

# Documentation

data SourceLoc Source #

Source location: file and line/col information. This is half of a `SourceSpan`.

Since: 2.16.0.0

Constructors

SourceLoc |

Fields

- locFile :: Text
- locStartLine :: Int
- locStartCol :: Int

#### Instances

Instances details

Show SourceLoc Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods showsPrec :: Int -> SourceLoc -> ShowS Source # show :: SourceLoc -> String Source # showList :: [SourceLoc] -> ShowS Source #
Lift SourceLoc Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods lift :: Quote m => SourceLoc -> m Exp Source # liftTyped :: forall (m :: Type -> Type). Quote m => SourceLoc -> Code m SourceLoc Source #

data Attribute Source #

An attribute of an entity field definition or a directive.

Since: 2.17.1.0

Constructors

Assignment Text Text |
Parenthetical Text |
PText Text |
Quotation Text | Quoted field attributes are deprecated since 2.17.1.0.

#### Instances

Instances details

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

Instance details

Defined in Database.Persist.Quasi.Internal.ModelParser

Methods

compare :: Attribute -> Attribute -> Ordering Source #

(<) :: Attribute -> Attribute -> Bool Source #

(<=) :: Attribute -> Attribute -> Bool Source #

(>) :: Attribute -> Attribute -> Bool Source #

(>=) :: Attribute -> Attribute -> Bool Source #

max :: Attribute -> Attribute -> Attribute Source #

min :: Attribute -> Attribute -> Attribute Source #

attribute :: Parser Attribute Source #

attributeContent :: Attribute -> Text Source #

Converts an attribute into a Text representation for second-stage parsing or presentation to the user

Since: 2.16.0.0

data Directive Source #

Constructors

Directive |

Fields

- directiveDocCommentBlock :: Maybe DocCommentBlock
- directiveName :: DirectiveName
- directiveAttributes :: [Attribute]
- directivePos :: SourcePos

#### Instances

Instances details

Show Directive Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods showsPrec :: Int -> Directive -> ShowS Source # show :: Directive -> String Source # showList :: [Directive] -> ShowS Source #

directiveContent :: Directive -> [Text] Source #

Converts a directive into a Text representation for second-stage parsing or presentation to the user

Since: 2.17.1.0

data EntityField Source #

Constructors

EntityField |

Fields

- entityFieldDocCommentBlock :: Maybe DocCommentBlock
- entityFieldStrictness :: Maybe FieldStrictness
- entityFieldName :: FieldName
- entityFieldType :: TypeExpr
- entityFieldAttributes :: [Attribute]
- entityFieldPos :: SourcePos

#### Instances

Instances details

Show EntityField Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods showsPrec :: Int -> EntityField -> ShowS Source # show :: EntityField -> String Source # showList :: [EntityField] -> ShowS Source #

entityField :: Parser Member Source #

entityFieldContent :: EntityField -> [Text] Source #

newtype FieldName Source #

Constructors

FieldName Text |

#### Instances

Instances details

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

fieldName :: Parser FieldName Source #

data ParsedEntityDef Source #

Constructors

ParsedEntityDef |

Fields

- parsedEntityDefComments :: [Text]
- parsedEntityDefEntityName :: EntityNameHS
- parsedEntityDefIsSum :: Bool
- parsedEntityDefEntityAttributes :: [Attribute]
- parsedEntityDefFields :: [(EntityField, Maybe Text)]
- parsedEntityDefDirectives :: [(Directive, Maybe Text)]
- parsedEntityDefExtras :: Map Text [ExtraLine]
- parsedEntityDefSpan :: Maybe SourceSpan

#### Instances

Instances details

Show ParsedEntityDef Source # |
Instance details Defined in Database.Persist.Quasi.Internal.ModelParser Methods showsPrec :: Int -> ParsedEntityDef -> ShowS Source # show :: ParsedEntityDef -> String Source # showList :: [ParsedEntityDef] -> ShowS Source #

parseSource :: PersistSettings -> Maybe SourceLoc -> Text -> ParseResult [ParsedEntityDef] Source #

memberEntityFields :: Member -> [EntityField] Source #

Represents an entity member as a list of EntityFields

Since: 2.16.0.0

data ParserWarning Source #

Since: 2.16.0.0

#### Instances

Instances details

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

Instance details

Defined in Database.Persist.Quasi.PersistSettings.Internal

Methods

compare :: ParserWarning -> ParserWarning -> Ordering Source #

(<) :: ParserWarning -> ParserWarning -> Bool Source #

(<=) :: ParserWarning -> ParserWarning -> Bool Source #

(>) :: ParserWarning -> ParserWarning -> Bool Source #

(>=) :: ParserWarning -> ParserWarning -> Bool Source #

max :: ParserWarning -> ParserWarning -> ParserWarning Source #

min :: ParserWarning -> ParserWarning -> ParserWarning Source #

parserWarningMessage :: ParserWarning -> String Source #

Uses `errorBundlePretty` to render a parser warning.

Since: 2.16.0.0

type ParseResult a = (Set ParserWarning, Either (ParseErrorBundle String Void) a) Source #

Result of parsing a single source text.

Since: 2.16.0.0

type CumulativeParseResult a = (Set ParserWarning, Either [EntityParseError] a) Source #

Cumulative result of parsing multiple source texts.

Since: 2.16.0.0

toCumulativeParseResult :: Monoid a => [ParseResult a] -> CumulativeParseResult a Source #

renderErrors :: [EntityParseError] -> String Source #

Renders a list of EntityParseErrors as a String using `errorBundlePretty`, separated by line breaks. @since 2.16.0.0

runConfiguredParser :: PersistSettings -> ExtraState -> Parser a -> String -> String -> InternalParseResult a Source #

Run a parser using provided PersistSettings and ExtraState @since 2.16.0.0

data ParserErrorLevel Source #

Since: 2.16.0.0

Constructors

LevelError |
LevelWarning |

#### Instances

Instances details

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

initialExtraState :: ExtraState Source #