Would't this be a good solution to the partial null fields probleme?
--The field name and the value
type Field = (String,String)
--The form informations we get from the client
type FormResult = [Filed]
--An error message to send to teh client
type FormError = String
data Person = Person {
firstName :: String
,lastName :: String
,birthDate :: Date
,height :: Int
}
type PersonParseResult = Either FormError Person
--When receiving data froom the client you call this function and return the error to the client or continue normaly
getPersonneFromForm :: FormResult -> PersonParseResult
--You could go furter and do this:
class FromForm a where
fromForm :: FormResult -> Either FormError a
instance FromForm Person where
fromForm a = getPersonneFromForm a
--And then you could do this:
thisFunctionGetAForm :: FormResult -> HTTPResponse
thisFunctionGetAForm f =
case (fromForm f) :: PersonParseResult of
Left a -> toHTTPResponse "The form is invalid"
Right a -> toHTTPResponse "Ok, we got you"