Chris Stryczynski

Software Developer / Consultant

My introduction with digestive-functors


Form is a type that encapsulates 'inputtable' form inputs and validation rules. View is a type that encapsulates a sort of 'form state' - a form, some input, their errors.

runView is a conventional function that is used to create a View from a Form and input. So there are a few 'bindings' for common web frameworks (snap / scotty / happstack) that implement this function.

If you were to implement your own runView function without any web framework, you'd essentially need to create a mock request (Network.Wai related).

data User = User
    { userName :: Text
    , userMail :: Text
    } deriving (Show)
userForm :: Monad m => Form Text m User
userForm = User
  <$> "name" .: text Nothing
  <*> "mail" .: check "Not a valid email address" checkEmail (text Nothing)

Gotchas: Get requests don't get processed with the relevant runForm functions implemented by all the web framework bindings. No idea.