Defines a homogenous collection of field types to interface typeless HTTP and HTML with the application and with HaskellDB
- module Database.HaskellDB.FieldType
- type FieldName = String
- data WrapperType
- type Fields = Map FieldName WrapperType
- showField :: FieldName -> Fields -> String
- purge :: DBInfo -> Fields -> Fields
- class Wrappable a where
- wrap :: DBInfo -> FieldName -> a -> WrapperType
- unwrap :: WrapperType -> a
- wrapInt :: String -> WrapperType
- wrapBool :: String -> WrapperType
- wrapError :: WrapperType -> String
- isMandatory :: DBInfo -> FieldName -> Maybe Bool
- maybeUnwrap :: Maybe WrapperType -> WrapperType
- fromList' :: DBInfo -> [(FieldName, String)] -> Map FieldName WrapperType
- unwrapField :: Wrappable a => FieldName -> Fields -> Maybe a
Documentation
module Database.HaskellDB.FieldType
data WrapperType Source
Heterogeneous type wrapper
type Fields = Map FieldName WrapperTypeSource
Collection of heterogenous fields associated by FieldName
:: FieldName | Field name to look up |
-> Fields | Fields to look in |
-> String | String representation of field to return |
Casts the FieldName
in fields to string
Purge non mandatory empty fields
:: DBInfo | The database to check for the type |
-> FieldName | Field name that represents this value |
-> a | The value in question |
-> WrapperType | The wrapped value |
Function to wrap a value associated with a given FieldName
:: WrapperType | The wrapped type |
-> a | The originally typed value |
Function to unwrap a WrapperType
to its original type
:: WrapperType | The wrapped type to check |
-> String | Error message |
Returns an error message if there has been a wrapping error
:: Maybe WrapperType | The potential wrapped type |
-> WrapperType | Definitely a wrapped type (though perhaps an empty one) |
A potential WrapperType
is WrapEmpty
if Nothing