Including list.

---------- Forwarded message ----------
From: Antoine Latter <aslat...@gmail.com>
Date: Tue, Nov 1, 2011 at 11:33 AM
Subject: Re: [Haskell-cafe] happstack file serving
To: Gary Klindt <gary.kli...@googlemail.com>


On Tue, Nov 1, 2011 at 11:24 AM, Gary Klindt <gary.kli...@googlemail.com> wrote:
> Hey Antoine,
>
> thank you for answering. Your strategy is quite similar to the one I prefer.
> I misunderstood the behaviour of serveDirectory. The problem with external
> javascript files is solved.
> The other problem I had, was, that the argument 'msum' is a list, which has
> elements with the same type, so I needed a conversion from
> m [Char]  to  m Response.
> In Happstack.Server.Response there is a function, which actually does that:
> flatten:
>
> module Main where
>
> import Happstack.Server
> import Control.Monad
>
> main :: IO ()
> main = simpleHTTP nullConf $
>    msum [ flatten $ dir "ok" $ ok "jeahh!"
>         , serveDirectory DisableBrowsing ["index.html"] "static" ]
>

I would likely write that particular example:

> dir "ok" $ ok $ toResponse "jeahh!"

I find it convenient to convert to a 'Response' as close to the
'bottom' of the stack as possible.

Antoine

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to