haskell-snap-framework

How to make nicEditor snaplet? (Several questions)

我的梦境 提交于 2020-01-15 08:01:12
问题 The example below defines a snaplet to bind nicEditor to textarea. The following questions are not only related to the example below, but probably they are related to some other similar cases.. Can a newbie follow the instructions below (how to clarify)? How to make the example use less steps or otherwise simpler? (Is it possible with approximately the same content as below?) This used interpreted splice. If possible, should a snaplet provide compiled splices, too? A snaplet probably could

Comparing Haskell's Snap and Yesod web frameworks

孤街醉人 提交于 2019-12-28 03:15:09
问题 The two Haskell web frameworks in the news recently are Yesod (at 0.8) and Snap (at 0.4). It's quite obvious that Yesod currently supports a lot more features than Snap. However, I can't stand the syntax Yesod uses for its HTML, CSS and Javascript. So, I'd like to understand what I'd be missing if I went with Snap instead. For example, doesn't look like database support is there. How about sessions? Other features? 回答1: Full disclosure: I'm one of the lead developers of Snap. First of all,

Haskell Web Framework

做~自己de王妃 提交于 2019-12-24 00:01:34
问题 I'm creating simple web application using haskell. First I used Snap in front and I was able to run the application, but I want to add user input to the application. I couldn't find a way to get user input parameters to the function. How might I do that? Other thing, I also used Happstack framework, I can not import "Happstack.Server". I use cabal installation configure Happstack. It was successfully installed, but when I try to import to "Happstack.Server", it gives me an error: <no location

Snap web framework and OSX Path

邮差的信 提交于 2019-12-23 02:02:38
问题 preface: new to OSX development. cabal install snap --this works fine. When I type snap into the terminal nothing happens. How do I export my snap path to my $PATH in OSX? same thing happens with happstack and yesod.... those are both installed as well 回答1: Simply do (in the terminal): export PATH="$HOME/.cabal/bin:$PATH" To make it permanent, add that line to the hidden .profile file in your home directory and re-login. You can edit ~/.profile using open ~/.profile . This can also be done

Snap web framework and OSX Path

为君一笑 提交于 2019-12-23 02:01:43
问题 preface: new to OSX development. cabal install snap --this works fine. When I type snap into the terminal nothing happens. How do I export my snap path to my $PATH in OSX? same thing happens with happstack and yesod.... those are both installed as well 回答1: Simply do (in the terminal): export PATH="$HOME/.cabal/bin:$PATH" To make it permanent, add that line to the hidden .profile file in your home directory and re-login. You can edit ~/.profile using open ~/.profile . This can also be done

Snap framework root (“/”) route not being handed?

六月ゝ 毕业季﹏ 提交于 2019-12-23 01:59:05
问题 I have added routes to my app in the following format: addRoutes [ ("/", redirect "/docs/home") , ... more routes ] But for some reason the root handler is being ignored altogether. What is happening here? 回答1: It turns out that if you have an index.tpl file then the SnapFramework will ignore any "/" mappings and go straight to that instead. To fix the problem I just ran: git rm snaplets/heist/templates/index.tpl And then reloaded my templates and the route on root started working. (I could

Deploy Haskell code that uses the Snap Framework

只谈情不闲聊 提交于 2019-12-22 12:18:29
问题 What's your experience with deploying Haskell code for production in Snap in a stable fashion? If the compilation fails on the server then I would like to abort the deployment and if it succeeds then I would like it to turn of the snap-server and start the new version instead. I know there are plenty of ways. Everything from rsync to git-hooks (git pull was a nightmare). But I would like to hear your experiences. 回答1: Where I work, we use Happstack and deploy on Ubuntu linux. We actually

How do I maintain a server-side state with Snap Framework?

大城市里の小女人 提交于 2019-12-22 07:03:05
问题 Server-side sessions are not [yet] part of the Snap Framework. Is there a way to add some sort of server side state? Let's pretend I want to increment a counter for each HTTP request. How would I do it? 回答1: Easiest way is to put the state behind an mvar: fooHandler :: MVar Int -> Snap () fooHandler mvar = do x <- liftIO $ modifyMVar mvar $ \y -> let y'=y+1 in (y',y') writeBS $ S.pack $ "Incremented counter to: " ++ show x Initialize the mvar when the site is initialized. Hope this helps. 回答2

Type error using snaplet-session

耗尽温柔 提交于 2019-12-13 01:00:16
问题 The App type data App = App { _heist :: Snaplet (Heist App) , _session :: Snaplet SessionManager } The initializer ... addRoutes [ ("/ss", companyHandler) , ("", heistServe) ] ... The handler companyHandler :: Handler b v () companyHandler = method GET getter <|> method POST setter where getter = do value <- getFromSession "name" writeText $ fromMaybe "nothing" value setter = do mname <- getParam "name" setInSession "name" (convert mname) getter convert = T.pack . B.unpack . (fromMaybe

Session is not shared between requests using Snaplet.Session

拈花ヽ惹草 提交于 2019-12-11 10:28:02
问题 A simple example of Snaplet and Session here $ curl http://localhost:8000/sessioin -d "key=k&value=v" k getter $ curl http://localhost:8000/sessioin getter I cannot get session in the 2nd request. 回答1: Depending on your definition of with , you probably forgot to commit your session after you set values in it. Also, you're using curl to test this system. curl doesn't preserve cookies by default, which is why your session cookie is lost. Try using this (works on my machine): curl -c cookies