Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View error.log
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
 
test-hsp.hs:27:8:
Couldn't match type `XMLType (ServerPartT IO)' with `XML'
Expected type: XMLGenT (ServerPartT IO) XML
Actual type: XMLGenT (ServerPartT IO) (XMLType (ServerPartT IO))
In the return type of a call of `genElement'
In the first argument of `unXMLGenT', namely
`(genElement
(Nothing, fromStringLit "html")
[]
[asChild
((genElement
(Nothing, fromStringLit "head")
[]
[asChild
((genElement (Nothing, fromStringLit "title") [] [...]))])),
asChild
((genElement
(Nothing, fromStringLit "body")
[]
[asChild ((asChild (body)))]))])'
In the expression:
unXMLGenT
(genElement
(Nothing, fromStringLit "html")
[]
[asChild
((genElement
(Nothing, fromStringLit "head")
[]
[asChild
((genElement (Nothing, fromStringLit "title") [] [...]))])),
asChild
((genElement
(Nothing, fromStringLit "body") [] [asChild ((asChild (body)))]))])
 
test-hsp.hs:27:20:
Couldn't match type `StringType (ServerPartT IO)'
with `Data.Text.Internal.Lazy.Text'
Expected type: Maybe (StringType (ServerPartT IO))
Actual type: Maybe Data.Text.Internal.Lazy.Text
In the expression: Nothing
In the first argument of `genElement', namely
`(Nothing, fromStringLit "html")'
In the first argument of `unXMLGenT', namely
`(genElement
(Nothing, fromStringLit "html")
[]
[asChild
((genElement
(Nothing, fromStringLit "head")
[]
[asChild
((genElement (Nothing, fromStringLit "title") [] [...]))])),
asChild
((genElement
(Nothing, fromStringLit "body")
[]
[asChild ((asChild (body)))]))])'
 
test-hsp.hs:32:25:
Couldn't match type `Data.Text.Internal.Lazy.Text' with `XML'
In the expression: asChild (fromStringLit "Hello, HSP!")
In the third argument of `genElement', namely
`[asChild (fromStringLit "Hello, HSP!")]'
In the first argument of `asChild', namely
`((genElement
(Nothing, fromStringLit "title")
[]
[asChild (fromStringLit "Hello, HSP!")]))'
View error.log
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -F -pgmFhsx2hs #-}
 
import HSP
import HSP.Monad
import Happstack.Server.HSP.HTML
import Happstack.Server.XMLGenT
 
import Data.Functor
 
import Happstack.Server
( Happstack, HasRqData, Method(GET, POST), Request(rqMethod)
, Response
, ServerPartT(..), ServerPart, WebMonad, FilterMonad, ServerMonad
, askRq, decodeBody, dir, defaultBodyPolicy, lookText
, mapServerPartT, nullConf, nullDir, ok, simpleHTTP
, seeOther, method
, toResponse
)
 
main :: IO ()
main = simpleHTTP nullConf $ hello
 
template :: (XMLGenerator m, EmbedAsChild m body) => body -> ServerPartT IO XML
template body = unXMLGenT
<html>
<head>
<title>Hello, HSP!</title>
</head>
<body>
<% body %>
</body>
</html>
 
hello :: ServerPartT IO XML
hello = template $ unXMLGenT
<div>
<h1>Hello HSP!</h1>
<p>We can insert Haskell expression such as this:
<% show $ sum [1 .. (10 :: Int)] %></p>
<p>We can use the ServerPartT monad too.
Your request method was: <% getMethod %></p>
<hr/>
<p>We don't have to escape & or >. Isn't that nice?</p>
<p>If we want <% "<" %> then we have to do something funny.</p>
<p>But we don't have to worry about
escaping <% "<p>a string like this</p>" %></p>
<p>We can also nest <% <span>like <% "this." %> </span> %></p>
</div>
where
getMethod :: XMLGenT (HSPT XML (ServerPartT IO)) String
getMethod = show . rqMethod <$> askRq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.