-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parse persistent model files -- -- Parse persistent model files @package persistent-parser @version 0.1.0.2 -- | Attempt to represent all possible Persistent data in a syntax tree. -- -- -- https://github.com/yesodweb/persistent/wiki/Persistent-entity-syntax -- contains relatively up to date information about Persistent syntax. -- -- -- https://github.com/yesodweb/persistent/tree/master/persistent-test/src -- gives clues about newer syntax elements that have not been added to -- the wiki. -- -- It is recommended that you import this qualified. import qualified -- Database.Persist.Syntax.Types as PST module Database.Persist.Syntax.Types -- | The root of the Persistent syntax tree. A collection of data types -- with which you can recontruct a Persist Model file or create an -- altered version. type ModelsFile = [ModelsFilePiece] -- | Top level pieces of a Persistent Model file. data ModelsFilePiece ModelsFileEntity :: Entity -> ModelsFilePiece ModelsFileComment :: Comment -> ModelsFilePiece ModelsFileWhiteSpace :: WhiteSpace -> ModelsFilePiece -- | A single Persist Model Entity. data Entity Entity :: Text -> Bool -> Maybe Text -> [EntityChild] -> Entity -- |
-- Person --[entityName] :: Entity -> Text -- |
-- Person json --[entityDeriveJson] :: Entity -> Bool -- |
-- Person sql=people --[entitySqlTable] :: Entity -> Maybe Text [entityChildren] :: Entity -> [EntityChild] -- | All of the child elements of a Persist Model Entity. | They are all -- indented in the Model File. data EntityChild EntityChildEntityField :: EntityField -> EntityChild EntityChildEntityUnique :: EntityUnique -> EntityChild EntityChildEntityDerive :: EntityDerive -> EntityChild EntityChildEntityPrimary :: EntityPrimary -> EntityChild EntityChildEntityForeign :: EntityForeign -> EntityChild EntityChildComment :: Comment -> EntityChild EntityChildWhiteSpace :: WhiteSpace -> EntityChild -- | An EntityField corresponds to a column in SQL or a key-value pair in -- MongoDB. The minimal definition of an EntityField in Persistent has a -- name and a type. data EntityField EntityField :: Text -> EntityFieldType -> Bool -> Bool -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Int -> EntityField -- | name, address, age [entityFieldName] :: EntityField -> Text -- | Text, [Text], Text Maybe, ~Int [entityFieldType] :: EntityField -> EntityFieldType -- |
-- MigrationOnly --[entityFieldIsMigrationOnly] :: EntityField -> Bool -- |
-- SafeToRemove --[entityFieldIsSafeToRemove] :: EntityField -> Bool -- | default=Nothing, default=now(), -- default=CURRENT_DATE [entityFieldDefault] :: EntityField -> Maybe Text -- |
-- sql=my_id_name --[entityFieldSqlRow] :: EntityField -> Maybe Text -- |
-- sqltype=varchar(255) --[entityFieldSqlType] :: EntityField -> Maybe Text -- |
-- maxlen=3 --[entityFieldMaxLen] :: EntityField -> Maybe Int -- | Table rows can be strict or lazy data Strictness -- | Persist Model types are strict without any notation Strict :: Strictness -- | "!" can be used to reemphasize that a type is strict ExplicitStrict :: Strictness -- | "~" means that a type is Lazy Lazy :: Strictness -- | An entity data row's type. data EntityFieldType EntityFieldType :: Text -> Strictness -> Bool -> Bool -> EntityFieldType -- | Text, Int, Double [entityFieldTypeText] :: EntityFieldType -> Text -- | ~Text, !Text, Text [entityFieldStrictness] :: EntityFieldType -> Strictness -- |
-- UniqueUserName --[entityUniqueName] :: EntityUnique -> Text -- |
-- userIdent --[entityUniqueEntityFieldName] :: EntityUnique -> [Text] -- | deriving Eq, deriving Show, etc. There may be custom -- generic typeclasses so there is no restriction on what the type might -- be , other than it starts with a capital letter. data EntityDerive EntityDerive :: [Text] -> EntityDerive -- | deriving Eq, deriving Show [entityDeriveTypes] :: EntityDerive -> [Text] -- | 'Primary name' data EntityPrimary EntityPrimary :: [Text] -> EntityPrimary [entityPrimaryType] :: EntityPrimary -> [Text] -- | 'Foreign Tree fkparent parent' data EntityForeign EntityForeign :: Text -> [Text] -> EntityForeign [entityForeignTable] :: EntityForeign -> Text [entityForeignTypes] :: EntityForeign -> [Text] -- | White space found in the Persistent file or QuasiQuoter. Need to save -- the white space in case you want to reproduce the original file or an -- altered version of the file from the Persist Syntax Tree. data WhiteSpace WhiteSpace :: Text -> WhiteSpace [whiteSpace] :: WhiteSpace -> Text -- | Haskell style comments that start with -- in Persistent. data Comment Comment :: Text -> Comment [comment] :: Comment -> Text -- | MigrationOnly persistent-template >= 1.2.0 marks a field -- that is ignored by normal processing but retained for migration -- purposes. Useful for implementing columns that other tools may need -- but Persistent does not. SafeToRemove is used to deprecate a -- field after MigrationOnly has been used. The field will be -- removed from the database if it is present. This is a destructive -- change which is marked as safe by the user. data MigrationOnlyAndSafeToRemoveOption MigrationOnly :: MigrationOnlyAndSafeToRemoveOption SafeToRemove :: MigrationOnlyAndSafeToRemoveOption -- | These items may occur at the very end of a Field's line and in any -- order. data EntityFieldLastItem FieldDefault :: Text -> EntityFieldLastItem FieldSqlRow :: Text -> EntityFieldLastItem FieldSqlType :: Text -> EntityFieldLastItem FieldMaxLen :: Int -> EntityFieldLastItem -- | Define equality to match based only on the type constructor. instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityFieldLastItem instance GHC.Show.Show Database.Persist.Syntax.Types.EntityFieldLastItem instance GHC.Read.Read Database.Persist.Syntax.Types.EntityFieldLastItem instance GHC.Generics.Generic Database.Persist.Syntax.Types.MigrationOnlyAndSafeToRemoveOption instance GHC.Show.Show Database.Persist.Syntax.Types.MigrationOnlyAndSafeToRemoveOption instance GHC.Read.Read Database.Persist.Syntax.Types.MigrationOnlyAndSafeToRemoveOption instance GHC.Classes.Eq Database.Persist.Syntax.Types.MigrationOnlyAndSafeToRemoveOption instance GHC.Generics.Generic Database.Persist.Syntax.Types.ModelsFilePiece instance GHC.Show.Show Database.Persist.Syntax.Types.ModelsFilePiece instance GHC.Read.Read Database.Persist.Syntax.Types.ModelsFilePiece instance GHC.Classes.Eq Database.Persist.Syntax.Types.ModelsFilePiece instance GHC.Generics.Generic Database.Persist.Syntax.Types.Entity instance GHC.Show.Show Database.Persist.Syntax.Types.Entity instance GHC.Read.Read Database.Persist.Syntax.Types.Entity instance GHC.Classes.Eq Database.Persist.Syntax.Types.Entity instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityChild instance GHC.Show.Show Database.Persist.Syntax.Types.EntityChild instance GHC.Read.Read Database.Persist.Syntax.Types.EntityChild instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityChild instance GHC.Generics.Generic Database.Persist.Syntax.Types.Comment instance GHC.Read.Read Database.Persist.Syntax.Types.Comment instance GHC.Show.Show Database.Persist.Syntax.Types.Comment instance GHC.Classes.Eq Database.Persist.Syntax.Types.Comment instance GHC.Generics.Generic Database.Persist.Syntax.Types.WhiteSpace instance GHC.Read.Read Database.Persist.Syntax.Types.WhiteSpace instance GHC.Show.Show Database.Persist.Syntax.Types.WhiteSpace instance GHC.Classes.Eq Database.Persist.Syntax.Types.WhiteSpace instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityForeign instance GHC.Read.Read Database.Persist.Syntax.Types.EntityForeign instance GHC.Show.Show Database.Persist.Syntax.Types.EntityForeign instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityForeign instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityPrimary instance GHC.Read.Read Database.Persist.Syntax.Types.EntityPrimary instance GHC.Show.Show Database.Persist.Syntax.Types.EntityPrimary instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityPrimary instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityDerive instance GHC.Read.Read Database.Persist.Syntax.Types.EntityDerive instance GHC.Show.Show Database.Persist.Syntax.Types.EntityDerive instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityDerive instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityUnique instance GHC.Read.Read Database.Persist.Syntax.Types.EntityUnique instance GHC.Show.Show Database.Persist.Syntax.Types.EntityUnique instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityUnique instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityField instance GHC.Show.Show Database.Persist.Syntax.Types.EntityField instance GHC.Read.Read Database.Persist.Syntax.Types.EntityField instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityField instance GHC.Generics.Generic Database.Persist.Syntax.Types.EntityFieldType instance GHC.Show.Show Database.Persist.Syntax.Types.EntityFieldType instance GHC.Read.Read Database.Persist.Syntax.Types.EntityFieldType instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityFieldType instance GHC.Generics.Generic Database.Persist.Syntax.Types.Strictness instance GHC.Read.Read Database.Persist.Syntax.Types.Strictness instance GHC.Show.Show Database.Persist.Syntax.Types.Strictness instance GHC.Classes.Eq Database.Persist.Syntax.Types.Strictness instance GHC.Classes.Eq Database.Persist.Syntax.Types.EntityFieldLastItem -- | Use Internal modules at your own risk. module Database.Persist.Internal.Parser -- | Parse a Persistent models file. parseModelsFile :: Text -> Either String ModelsFile -- | Parse Persistent QuasiQuoters from a Haskell file. parseQuasiQuotersFile :: Text -> Either String ModelsFile -- | Parse Persist Models that are in quasi-quoters in a Haskell file. parsePersistQuasiQuoters :: Parser ModelsFile -- | Parse a Persist Models file. parseEntities :: Parser ModelsFile -- | Parse a single Persist Entity. parseEntity :: Parser Entity -- | Parse the user defined SQL table name. parseEntitySqlTable :: Parser Text -- | Wrap a Parser in Maybe because it might fail. Useful for making -- choices. maybeOption :: Parser a -> Parser (Maybe a) -- | Parse a lowercase Char. lowerCase :: Parser Char -- | Parse an uppercase Char. upperCase :: Parser Char -- | Parse an underline. underline :: Parser Char -- | Parse strict marker "!" for haskellTypeName. exclamationMark :: Parser Char -- | Parse lazy marker "~" for haskellTypeName. tilde :: Parser Char -- | Parse any space Char excluding "n". spaceNoNewLine :: Parser Char -- | Parse a Haskell function name. It starts with underscore or lowercase -- letter then is followed by a combination of underscores, single -- quotes, letters and digits. E.g., "get", "_get", "get_1", etc. haskellFunctionName :: Parser Text -- | Parse a Haskell type name. It starts with an uppercase letter then is -- followed by a combination of underscores, single quotes, letters and -- digits. E.g., Person, Address, PhoneNumber, etc. haskellTypeName :: Parser Text -- | Parse a Haskell Type name that does not have a prefix. haskellTypeNameWithoutPrefix :: Parser Text -- | Parse a comment that starts with "--". singleLineComment :: Parser Comment -- | Parse and collect white space. collectWhiteSpace :: Parser WhiteSpace -- | Parse and collect an Entity name. parseEntityName :: Parser Text -- | Parse and collect an EntityField. parseEntityField :: Parser EntityField -- | Delete elements from the second list that exist in the first list. -- Removes any duplicates. deleteItems :: (Eq a) => [a] -> [a] -> [a] -- | Parse MigrationOnly. parseMigrationOnly :: Parser MigrationOnlyAndSafeToRemoveOption -- | Parse SafeToRemove. parseSafeToRemove :: Parser MigrationOnlyAndSafeToRemoveOption -- | Match one of the parsers. getMigrationOnlyAndSafeToRemoveOption :: MigrationOnlyAndSafeToRemoveOption -> Parser MigrationOnlyAndSafeToRemoveOption -- | Parse MigrationOnly and SafeToRemove. The occur in the -- same spot. parseMigrationOnlyAndSafeToRemove :: [MigrationOnlyAndSafeToRemoveOption] -> Parser [MigrationOnlyAndSafeToRemoveOption] -- | Match FieldDefault constructor, get its Text value. getFieldDefault :: [EntityFieldLastItem] -> Maybe Text -- | Match FieldSqlRow constructor, get its Text value. getFieldSqlRow :: [EntityFieldLastItem] -> Maybe Text -- | Match FieldSqlType constructor, get its Text value. getFieldSqlType :: [EntityFieldLastItem] -> Maybe Text -- | Match FieldMaxLen constructor, get its Text value. getFieldMaxLen :: [EntityFieldLastItem] -> Maybe Int -- | Get parser based on constructor match. getEntityFieldLastItemParser :: EntityFieldLastItem -> Parser EntityFieldLastItem -- | Parse FieldDefault. parseFieldDefault :: Parser EntityFieldLastItem -- | Parse FieldSqlRow. parseFieldSqlRow :: Parser EntityFieldLastItem -- | Parse FieldSqlType. parseFieldSqlType :: Parser EntityFieldLastItem -- | Parse FieldMaxLen. parseFieldMaxLen :: Parser EntityFieldLastItem -- | Parse EntityFieldLastItem. parseEntityFieldLastItem :: [EntityFieldLastItem] -> Parser [EntityFieldLastItem] -- | Parse Entity Field name. parseEntityFieldName :: Parser Text -- | Parse type Strictness. parseStrictness :: Parser Strictness -- | Parse EntityFieldType. parseEntityFieldType :: Parser EntityFieldType -- | Parse Maybe qualifier for a Field Type. parseMaybe :: Parser () -- | Parse EntityUnique. parseEntityUnique :: Parser EntityUnique -- | Parse Entity UniqueName parseEntityUniqueName :: Parser Text -- | Parse EntityUniqueEntityFieldName parseEntityUniqueEntityFieldName :: Parser [Text] -- | Parse EntityDerive. parseEntityDerive :: Parser EntityDerive -- | Parse EntityPrimary. parseEntityPrimary :: Parser EntityPrimary -- | Parse EntityForeign. parseEntityForeign :: Parser EntityForeign -- | Parse ForeignKeyType parseForeignKeyType :: Parser () module Database.Persist.Parser -- | Parse a Persistent models file. parseModelsFile :: Text -> Either String ModelsFile -- | Parse Persistent QuasiQuoters from a Haskell file. parseQuasiQuotersFile :: Text -> Either String ModelsFile