Open cdupont opened 7 years ago
@stepcut Any idea?
I can not duplicate this error. This is my current test code:
{-# language OverloadedStrings #-}
{-# language TypeFamilies #-}
{-# language ApplicativeDo #-}
module Main where
import Data.Text (Text)
import Text.Blaze.Html
import qualified Text.Blaze.Html5 as H
import Happstack.Server
import Text.Reform
import Text.Reform.Happstack
import Text.Reform.Blaze.Text
instance FormError AppError where
type ErrorInputType AppError = [Input]
commonFormError = AppCFE
data AppError = AppCFE (CommonFormError [Input])
type SimpleForm = Form (ServerPartT IO) [Input] AppError Html ()
postForm :: SimpleForm Text
postForm =
label ("Any text value: " :: Text) ++> inputText "" <* inputSubmit "submit"
route =
do decodeBody (defaultBodyPolicy "/tmp/" 0 1000 1000)
html <- reform (form ("/" :: Text)) "post" success Nothing postForm
ok $ toResponse $ appTemplate "form" $ html
where
success :: Text -> ServerPartT IO Response
success msg =
ok $ toResponse $ appTemplate "Success" (H.p (toHtml msg))
appTemplate ttl bdy =
do H.html $
do H.head $ H.title ttl
H.body bdy
main = simpleHTTP nullConf route
One thing you could try is using the bifunctors
branch of reform:
https://github.com/Happstack/reform/tree/bifunctors
This switches from the local IndexedApplicative
to Bifunctors
and removes the bogus Monad Result
instance. Despite those big sounding changes, all my code compiled with out changes.
reform-blaze doesn't seem to play well with applicativeDo (from GHC 8). Just adding
{-# LANGUAGE ApplicativeDo #-}
to a code containingreform
forms makes the happstack server to return a blank page.