Safe Haskell | None |
---|---|
Language | Haskell2010 |
Unstable, may change without warning.
Utility funcs to support Exigo.Persistent.TH.
Synopsis
- mkSaveAssessmentMetadata :: String -> AssessmentMetadata -> Q [Dec]
- mkQuestionFieldsAccessor :: MkPersistSettings -> String -> [EntityDef] -> Q [Dec]
- mkCommentFieldsAccessor :: MkPersistSettings -> String -> [EntityDef] -> Q [Dec]
- accessorName :: MkPersistSettings -> Text -> String
- isMarks :: EntityDef -> Bool
- fName :: FieldDef -> Text
- marksT :: Type
- x_to_listXT :: Type -> Type
- x_to_maybeXT :: Type -> Type
- marks_to_xT :: Type -> Type
- normalClause :: [Pat] -> Exp -> Clause
- lowerFirst :: Text -> Text
- upperFirst :: Text -> Text
- recNameNoUnderscore :: MkPersistSettings -> HaskellName -> HaskellName -> Text
- recName :: MkPersistSettings -> HaskellName -> HaskellName -> Text
Documentation
mkSaveAssessmentMetadata :: String -> AssessmentMetadata -> Q [Dec] Source #
create a function which returns at runtime the assessment metadata passed in at compile-time.
i.e., if mkSaveAssessmentMetadata myFunc mData
is called,
it creates a function like
myFunc :: AssessmentMetadata myFunc = mData
mkQuestionFieldsAccessor :: MkPersistSettings -> String -> [EntityDef] -> Q [Dec] Source #
create a function which returns all the question-type field accessors for Marks.
i.e., mkQuestionFieldsAccessor sqlSettings myName
in a call to share
should produce a result something like
myNHame :: [Marks -> Double] myName = [ marksQ1a, marksQ1b, marksQ1c .. ]
where the accessors are in the order they appear in the EntityDef.
mkCommentFieldsAccessor :: MkPersistSettings -> String -> [EntityDef] -> Q [Dec] Source #
create a function which returns all the comment-type field accessors for Marks.
i.e., mkCommentFieldsAccessor myName
should produce a result something like
myNHame :: [Marks -> Maybe Text] myName = [ marksQ1aComments, marksQ1bComments, marksQ1cComments .. ]
where the accessors are in the order they appear in the EntityDef.
accessorName :: MkPersistSettings -> Text -> String Source #
given some field from an entty def -- e.g. "q1a" -- get the actual accessor name (i.e. "marksQ1a")
x_to_listXT :: Type -> Type Source #
x_to_maybeXT :: Type -> Type Source #
marks_to_xT :: Type -> Type Source #
lowerFirst :: Text -> Text Source #
upperFirst :: Text -> Text Source #
recNameNoUnderscore :: MkPersistSettings -> HaskellName -> HaskellName -> Text Source #
recName :: MkPersistSettings -> HaskellName -> HaskellName -> Text Source #
name for a record field
If we call recName datatypeName fieldName
this returns a 'qualified field name' (i.e. data type name
is prepended, and the whole thing is camelCased.
i.e.
recName MyType "myfield" == "myTypeMyField"
(modulo name constructors).