Questions tagged [happstack]
Happstack is a fast and flexible Haskell web framework.
111
questions
1
vote
1
answer
87
views
Haskell do notation vs (>>) operator, happstack routing with 'method'
I am learning Haskell, and I'm trying to learn the happstack server as well.
I am following the guide at http://happstack.com/docs/crashcourse/index.html#matching-on-request-method-get-post-etc , and ...
0
votes
1
answer
61
views
Haskell web routes example with Happstack and blaze is not showing two different URLs
I've already done the the Happstack crash course and had working reform and web routes examples. I'm trying to combine the two like so, but showURL Home and showURL Login show the same URL for my ...
5
votes
0
answers
195
views
How to resolve dependency tree with different version ranges of same packages?
I'm trying to set up a happstack-lite application using stack.
I initialized project with these commands:
stack new my-happstack
cd my-happstack
stack setup
I changed package.yaml so it contains:
...
0
votes
1
answer
341
views
(How) can I host a Haskell website build on Windows on CentOS / Ubuntu?
I've built a website in Haskell (using Happstack) that I now want to host somewhere. I built it on Windows, using ghc to produce a file called website.exe. It's my first program in Haskell, and first ...
0
votes
1
answer
90
views
How to get value out of nested synonym type
I have defined my own type called CtrlV:
{-# LANGUAGE TemplateHaskell #-}
import Data.Data (Data, Typeable)
import Happstack.Server (Response, ServerPartT)
import Web.Routes (RouteT)
import Web....
1
vote
2
answers
234
views
How to host a Happstack website?
I've built a website using Happstack, but I have no experience in hosting. Everything I found online was either outdated or too complex for me. Is there an easy way, or tutorial I can follow to ...
1
vote
1
answer
43
views
Create a custom happstack response code
I have been trying to create a custom happstack response the 405 "Method not allowed" so if someone calls the API with a POST or PUT method they will get this response. I am new to happstack. Any ...
1
vote
1
answer
78
views
Reading request body twice in happstack-server
I have a problem reading the body twice in a happstack-server application.
I have embeded a library for user authentication (happstack-authenticate). happstack-authenticate has an JSON-Api to manage ...
1
vote
1
answer
113
views
How to pass HTTP request parameter to quickQuery?
I'm using Happstack to receive some parameters from an HTTP request then pass these parameters to a function that will retrieve data from the database and return this data in the HTTP response as ...
1
vote
1
answer
299
views
How to use "IO String" as an HTTP response in Happstack?
I'm retrieving data from a database using HDBC, then trying to send this data to a web client using Happstack.
myFunc :: Integer -> IO String
myFunc = ... fetch from db here ...
handlers :: ...
1
vote
0
answers
218
views
Happstack SSL error - wrong tag
I am trying to run happstack-tls server using certificate generated by certbot, however, when I run it I get user error (error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag) and program ...
1
vote
1
answer
73
views
What's the syntax of using multiple handlers in Happstack?
Sorry for my basic question, but I'm new to Haskell.
I'm following this example to receive some values from a request body, but my server also serves static files from a directory using the following ...
3
votes
1
answer
105
views
Catch program errors in Happstack request handler
I'm kind of a noob at Haskell, so I'm not entirely sure if this is a Happstack question or a general Haskell question.
Here's an example of the difficulty I'm having. This code "theoretically" ...
2
votes
1
answer
150
views
How to deal with a Haskell package's configured dependency range being out-of-date?
When attempting to install happstack via
$ stack install happstack
I get the following error:
Run from outside a project, using implicit global project config
Using resolver: lts-7.2 from ...
1
vote
1
answer
370
views
Haskell error: couldn't match expected type ‘ServerPartT IO a0’ with actual type '[Response]'
When I tried to compile the code, two errors occur.
the first one is:
Couldn't match expected type ‘ServerPartT IO a0’
with actual type ‘[Response]’
In a stmt of a 'do' block:
msum
...
0
votes
2
answers
110
views
The order of functions' execution in a high order function
I have a function here
(map (\ (a, b) -> dir a b) $ routes
where routes is a list of tuples and it contains
routes = [...
("graph-fb", seeOther redirectUrlGraphEmail $ toResponse "")...
-1
votes
1
answer
73
views
What's the type of LazyIO.readFile?
I am trying to find the type of privacyContents in
privacyContents <- LazyIO.readFile $ markdownPath ++ "PRIVACY.md"
Is the type of this variable defined by the return type of LazyIO.readFile? ...
1
vote
1
answer
107
views
How to define a variable contained in a tuple?
Every time I tried to run this code, the compiler returns a 'not in scope' error for the variables redirectUrlGraphEmail, redirectUrlGraphPost, aboutContents, and staticDir:
routes :: [ (String, ...
2
votes
1
answer
26k
views
How to apply a function on each element in a list in Haskell?
I have a list of tuples here, and I want to apply function dir..on the first element in each tuple. How can I do that? Thanks a lot in advance!
[ ("grid", gridResponse),
("graph", graphResponse),
("...
0
votes
1
answer
43
views
Does each Route include its Request and the Response returned by the Server?
For each dir.. , it is a Route which takes in a Request and returns a Response created by the Server. I am wondering if the Request and the Response included in each line of the code. Thanks in ...
1
vote
1
answer
63
views
What should a Route look like in Happstack code?
runServer :: IO ()
runServer = do
configureLogger
staticDir <- getStaticDir
redirectUrlGraphEmail <- retrieveAuthURL testUrl
redirectUrlGraphPost <- retrieveAuthURL ...
4
votes
1
answer
142
views
How to convert from happs -> happstack?
Can anyone help me "translate" the below from happs to happstack:
module Main where
import HAppS.Server.AlternativeHTTP
import HAppS.Server.HTTP.AltFileServe
import Control.Monad.State
import ...
2
votes
2
answers
144
views
Catching exceptions from pure functions in happstack
I can't find true way to catch exceptions throwed by pure functions in happstack application. I've tried this solution. It works well when exception throwed by IO function. But when pure function ...
1
vote
1
answer
186
views
GHCi interactive linking error during happstack-server installation
I’m trying to build a project in a cabal sandbox that depends on happstack-server, but this package fails to build. Here is the content of .cabal-sandbox/logs/happstack-server-7.4.6.1.log:
Building ...
2
votes
3
answers
488
views
How do I serve MathJax from a local Happstack server?
I'm not a developer/programmer. I'm just someone trying to use Gitit to take notes. I've got it to the point where it runs on Windows, but the math looks best using MathJax. I don't want to rely on a ...
3
votes
0
answers
198
views
Happstack seemingly random SSL failure
I have a Haskell application using Happstack that will run fine for anywhere from 1-5 days and then suddenly become unresponsive, with the log looking something like this:
ProtocolError "error:...
5
votes
1
answer
143
views
With IxSet, can I build an Indexable wrapper around an arbitrary Indexable type?
What I'd like to be able to do is something like the following:
import Data.IxSet
newtype Key a = Key Integer
deriving (Eq, Ord, Show)
data Keyed a = Keyed { key :: (Key a), value :: a }
...
3
votes
0
answers
115
views
Happstack ServerPart missing MonadIO instance?
The following code:
import Control.Monad.IO.Class
import Happstack.Server
test :: ServerPart String
test = liftIO (putStrLn "Test") >> ok "Test"
main = simpleHTTP nullConf test
is failing ...
0
votes
1
answer
189
views
Haskell Blaze HTML
been writing an application that consumes JSON data and then displays it using Happstack.
helloBlaze :: ServerPart Response
helloBlaze =
ok $ toResponse $
appTemplate "Hello, Blaze!"
...
0
votes
1
answer
114
views
Haskell Happstack, can I use a string with html tags as response?
module Main where
import Happstack.Lite
import Text.Html
main :: IO ()
main = serve Nothing $ msum [
nullDir >> ok homePage
, notFound page404
...
0
votes
1
answer
289
views
Haskell Happstack
trying to use happstack, got it to install correctly on windows but now it's chucking out some errors when I compile my test class any input would be appreciated.
module Main where
import Happstack....
0
votes
1
answer
49
views
Happstack: Empty Cookies
I am trying to access the rqCookies attribute of a Request in Happstack Server, however I continue to get an empty list, when there are cookies that are in the request headers.
I have also tried to ...
1
vote
1
answer
95
views
Happstack - hello world server
main = simpleHTTP nullConf $ ok "Hello, World!"
i am a newbie trying out haskell with happstack-server. In this hello world program, i got these doubts:
1) Server's default configuration, nullConf, ...
3
votes
2
answers
185
views
How can I upload a photo to Facebook using Haskell?
I am using Happstack, and I am trying to upload a photograph to Facebook using the Facebook Graph API.
I can successfully post a message to Facebook. I can use url, however I am trying to do this ...
2
votes
1
answer
61
views
Type names prefixed with package name and version
I'm pretty new to Haskell, and I'm trying to follow along with the Happstack Crash Course. I've done some of the examples, but when I tried the happstack-heist example, I got a strange compilation ...
2
votes
1
answer
389
views
Secure websockets with Happstack
Is there a way to use secure websockets (wss://) in Haskell server-side (preferably with Happstack)?
I tried to search Cabal for websocket server implementations, I get websockets and its multiple ...
1
vote
0
answers
119
views
Happstack dependency failure on Mac OS X 10.10 Yosemite
I am trying to install Happstack using the following command:
cabal install happstack
Specifications:
Mac OS X 10.10 (Yosemite)
GHC 7.8.3
cabal 1.20.0.2
Error Messages:
ld: library not found for -...
0
votes
1
answer
125
views
backend serving currenttime (in json) in haskell
I want to write a simple webserver in haskell which provides the current time. The time should be returned in json format.
Here is what I have so far:
{-# LANGUAGE DeriveDataTypeable #-}
import ...
0
votes
2
answers
150
views
How to carry non-Acidic value in Happstack?
I've read Happstack crashcourse. My web server has almost exact way described in the section Passing multiple AcidState handles around transparently
Problem I have is that, I have value which is non-...
1
vote
1
answer
65
views
Happstack handling
I'm parsing a form in happstack but I don't know of a more concise way to gather the form variables on the server.
Does anyone know if there are any tricks to reduce the amount of code needed here?
...
0
votes
1
answer
392
views
Happstack.lite tutorial failing to compile with "Illegal type signature: `String'"
I've been following this Happstack.Lite tutorial: http://www.happstack.com/page/view-page-slug/9/happstack-lite-tutorial with much success but I can't seem to get past this compile error:
$ ghc ...
1
vote
2
answers
119
views
How do I solve "HTTP request failed with: when is not a field" runtime errors in digestive-functors code?
I have a simple and incomplete Happstack application, that consists of a digestive-functors form defined as follows:
setRecFormSpec :: Monad m => Form Text m Reminder
setRecFormSpec = Reminder
...
1
vote
2
answers
491
views
Why can't a monad be decomposed?
I don't understand why I can't decompose a (let's say IO) monad. Like IO a -> a?
My question originated when using happstack and wanting to get the Text out of ServerPart (Maybe Text) which is ...
16
votes
2
answers
770
views
How can I implement HATEOAS in Haskell?
I have some old code which exposes services on a web API which works basically on HTTP verbs. I'd like to move this project to use hypermedia controls (HATEOAS). I'm wondering if there are any ...
2
votes
3
answers
380
views
Haskell, String vs ...String?
I'm currently following the Happstack lite tutorial from their website. http://happstack.com/page/view-page-slug/9/happstack-lite-tutorial
Right now, I'm implementing the echo function, and the ...
2
votes
1
answer
1k
views
cryptopp foreign library dependency
I tried to install happstack-server-tls package via cabal on Arch Linux (3.12.9), but got this error:
Resolving dependencies...
Configuring happstack-server-tls-7.1.0...
Failed to install happstack-...
5
votes
0
answers
294
views
happstack-server-tls only works with self-signed certificates
I am trying to create a web server using happstack-server-tls that will use a certificate signed by a private CA. Unfortunately, the TLS handshake only seems to succeed if I give the server a self-...
3
votes
2
answers
201
views
Is there a way to get the "current route" in Happstack?
Whenever I use a form in my website, I need to pass an "action" attribute to it (I don't want to leave it empty because I prefer to have validating markup). Right now it looks like this:
...
1
vote
1
answer
175
views
When creating a form with the Reform library, how do I put all the errors in a single list?
I'm following the tutorial for the reform library. I currently have a form with two required fields and its set up so the error message for each field shows up right next to it.
postForm :: MyForm ...
8
votes
2
answers
2k
views
How to use maybe monad inside another monad?
I have this code (inside happstack, but could be just the IO monad):
accountHandler conn = do
sessionId <- optional $ readCookieValue "sessionId"
case sessionId of
Nothing -> seeOther (...