ditto-0.4: ditto is a type-safe HTML form generation and validation library

Safe HaskellNone
LanguageHaskell98

Ditto.Backend

Description

This module contains two classes. FormInput is a class which is parameterized over the input type used to represent form data in different web frameworks. There should be one instance for each framework, such as Happstack, Snap, WAI, etc.

The FormError class is used to map error messages into an application specific error type.

Synopsis

Documentation

data CommonFormError input Source #

an error type used to represent errors that are common to all backends

These errors should only occur if there is a bug in the ditto-* packages. Perhaps we should make them an Exception so that we can get rid of the FormError class.

Instances
Eq input => Eq (CommonFormError input) Source # 
Instance details

Defined in Ditto.Backend

Methods

(==) :: CommonFormError input -> CommonFormError input -> Bool #

(/=) :: CommonFormError input -> CommonFormError input -> Bool #

Ord input => Ord (CommonFormError input) Source # 
Instance details

Defined in Ditto.Backend

Show input => Show (CommonFormError input) Source # 
Instance details

Defined in Ditto.Backend

commonFormErrorStr Source #

Arguments

:: (input -> String)

show input in a format suitable for error messages

-> CommonFormError input

a CommonFormError

-> String 

some default error messages for CommonFormError

commonFormErrorText Source #

Arguments

:: (input -> Text)

show input in a format suitable for error messages

-> CommonFormError input

a CommonFormError

-> Text 

some default error messages for CommonFormError

class FormError input err where Source #

A Class to lift a CommonFormError into an application-specific error type

Methods

commonFormError :: CommonFormError input -> err Source #

Instances
FormError Text Text Source # 
Instance details

Defined in Ditto.Backend

class FormInput input where Source #

Class which all backends should implement.

Minimal complete definition

getInputFile

Associated Types

type FileType input Source #

input is here the type that is used to represent a value uploaded by the client in the request.

Methods

getInputString :: FormError input err => input -> Either err String Source #

Parse the input into a string. This is used for simple text fields among other things

getInputStrings :: input -> [String] Source #

getInputText :: FormError input err => input -> Either err Text Source #

Parse the input value into Text

getInputTexts :: input -> [Text] Source #

getInputFile :: FormError input err => input -> Either err (FileType input) Source #

Get a file descriptor for an uploaded file