[Haskell-cafe] web-routes and forms

Corentin Dupont corentin.dupont at gmail.com
Sun Jan 9 21:15:14 CET 2011


Hello,
after installing digestive-functors-blaze with:
cabal install digestive-functors-blaze

My prog doesn't compiles anymore:
Warning: This package indirectly depends on multiple versions of the same
package. This is highly likely to cause a compile failure.
Followed by an error on MonadCatchIO.


I'm using the following versions:
happstack-server-0.5.0.2
mtl-1.1.0.2
blaze-html-0.2.3
web-routes-0.22.0
text-0.7.2.1

But cabal tried to install newer versions for these:
mtl-2.0.1.0
blaze-html-0.3.2.1
text-0.11.0.1

I already add this problem in the past, when I tried to update my MTL...
With absolutely no success!!
I encountered the same sort of problem of multiple versions dependencies. I
was unable to solve it.

After some research, I followed an advise telling that you should stick with
the same version of the libraries during development, so that I did: I went
back to the previous versions.

Is there a safe way to update some base libraries like MTL and all depending
libraries?
Would I be able to use digestive-functors with my current set of libraries?

Thanks,
Corentin


On Sun, Jan 9, 2011 at 8:36 PM, Jeremy Shaw <jeremy at n-heptane.com> wrote:

> Hello,
>
> newRule also needs to have the type, RoutedNomicServer. The
> transformation of RoutedNomicServer into NomicServer is done in the
> handleSite function. Something like this:
>
>
> nomicSpec :: ServerHandle -> Site Route (ServerPartT IO Response)
> nomicSpec sh =
>      Site { handleSite          = \f url -> unRouteT (nomicSite sh url) f
>             ...
>
> main =
>    do ...
>      simpleHTTP nullConf $ siteImpl (nomicSpec sh)
>
> Or something like that -- it's hard to tell exactly what is going on
> in your app based on the snippets you provided.
>
> Also, I highly recommend using digestive functors instead of formlets.
> It is the successor to formlets. Same core idea, better implementation
> and actively maintained.
>
> I have attached a quick demo of using:
>
> happstack+digestive-functors+web-routes+HSP
>
> To use it you will need the latest happstack from darcs plus:
>
>  hsp
>  web-routes
>  web-routes-hsp
>  web-routes-happstack
>  web-routes-mtl
>  digestive-functors
>  digestive-functors-hsp
>
> I plan to clean up this example and document it better in the crash
> course for the upcoming release. Clearly things like the FormInput
> instance and the formPart function belong a library.
>
> let me know if you have more questions.
> - jeremy
>
> On Sat, Jan 8, 2011 at 6:44 PM, Corentin Dupont
> <corentin.dupont at gmail.com> wrote:
> > Hello,
> >
> > I have difficulties mixing web-routes and forms:
> > I have put routes in all my site, except for forms which remains with the
> > type ServerPartT IO Response.
> > How to make them work together?
> >
> > I have:
> > type NomicServer             = ServerPartT IO
> > type RoutedNomicServer = RouteT PlayerCommand NomicServer
> >
> > newRule :: ServerHandle -> NomicServer Response
> > newRule sh = do
> >    methodM POST -- only accept a post method
> >    mbEntry <- getData -- get the data
> >    case mbEntry of
> >       Nothing -> error $ "error: newRule"
> >       Just (NewRule name text code pn) -> do
> >          html <- nomicPageComm pn sh (submitRule name text code pn))
> >          ok $ toResponse html
> >
> >
> > nomicPageComm :: PlayerNumber -> ServerHandle -> Comm () ->
> > RoutedNomicServer Html
> > nomicPageComm pn sh comm =
> > (..)
> >
> >
> > launchWebServer :: ServerHandle -> IO ()
> > launchWebServer sh = do
> >    putStrLn "Starting web server...\nTo connect, drive your browser to
> > \"http://localhost:8000/Login\ <http://localhost:8000/Login%5C>""
> >    d <- liftIO getDataDir
> >    simpleHTTP nullConf $ mconcat [dir "postLogin" $ postLogin,
> >                                   fileServe [] d,
> >                                   dir "Login" $ ok $ toResponse $
> loginPage,
> >                                   dir "NewRule" $ newRule sh,
> >                                   dir "NewGame" $ newGameWeb sh,
> >                                   dir "Nomic" $ do
> >                                      html <- implSite
> > "http://localhost:8000/Nomic/" "" (nomicSite sh)
> >                                      ok $ toResponse html
> >                                   ]
> >
> >
> > The red line doesn't compile. I don't know how to transform a
> > RoutedNomicServer into a NomicServer.
> >
> > For the future I intend to use formlets: is these some examples of
> programs
> > using happstack + web-routes + formlets?
> >
> > Thanks,
> > Corentin
> >
> >
> >
> >
> > On Fri, Jan 7, 2011 at 5:10 PM, Jeremy Shaw <jeremy at n-heptane.com>
> wrote:
> >>
> >> Hello,
> >>
> >> The [(String, String)] argument is for adding query parameters.
> >>
> >> > encodePathInfo ["foo", "bar", "baz"] [("key","value")]
> >>
> >> "foo/bar/baz?key=value"
> >>
> >> Instead of showURL you would use showURLParams.
> >>
> >> hope this helps!d
> >> - jeremy
> >>
> >> On Fri, Jan 7, 2011 at 8:12 AM, Corentin Dupont
> >> <corentin.dupont at gmail.com> wrote:
> >> > Hello Jeremy,
> >> > I'm using Web routes with happstack.
> >> > I'm following this tutorial:
> >> > http://tutorialpedia.org/tutorials/Happstack+type+safe+URLs.html
> >> >
> >> > But It seems out of synch with the latest version of web-routes:
> 0.23.2.
> >> > The haddock documentation seems out of date also:
> >> >
> >> > encodePathInfo :: [String] -> [(String, String)] -> String
> >> >
> >> > For example:
> >> >
> >> >  encodePathInfo [\"foo\", \"bar\", \"baz\"]
> >> >
> >> > "foo/bar/baz"
> >> >
> >> > And I can't figure out what this [(String, String)] is for ;)
> >> >
> >> > Thanks,
> >> >
> >> > Corentin
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110109/7db71abc/attachment.htm>


More information about the Haskell-Cafe mailing list