Questions tagged [yesod]

Yesod is a Haskell web framework for productive development of type-safe, RESTful, high performance web applications.

Yesod is a Haskell web framework for productive development of type-safe, RESTful, high performance web applications.

Yesod leverages Haskell's type system to turn runtime bugs into compule-time errors, for example to avoid XSS attacks or character encoding issues. Yesod contains several DSLs for templating ( for HTML, for Javascript, and or for CSS), to store data (Persistent), for routing, etc.

1334 questions
9
votes
3 answers

compile-time vs. run-time cost of Hamlet templates

For the Hamlet template mechanism, I understand that the template is parsed at compile time, resulting in source code that contains calls to blaze-html combinators (and possibly other expressions because of interpolation). So the points (subtrees)…
d8d0d65b3f7cf42
  • 2,597
  • 15
  • 28
9
votes
1 answer

Lookup query parameters in Yesod

I just initialized a Yesod project (no database) using yesod init. My HomeR GET handler looks like this: getHomeR :: Handler Html getHomeR = do (formWidget, formEnctype) <- generateFormPost sampleForm let submission = Nothing :: Maybe…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
9
votes
2 answers

What is a correct way of doing COUNT(id) in Esqueleto and Yesod

I'm trying to figure out how to write the following query using Esqueleto SELECT COUNT("person"."id") FROM "person" WHERE (("person"."admin" = 't' OR "person"."vip" = 't') // 't' as in True OR "person"."karma" >= 5000 AND "person"."hellbanned"…
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
9
votes
1 answer

How to do (role-based) access control in Yesod?

I'm wondering what the best approach for adding roles to users / permissions to Handlers or resources in Yesod is. Does anyone have prior art for this kind of thing? Are there any approaches that leverage the type-system to help prevent slip-ups…
Rehno Lindeque
  • 4,236
  • 2
  • 23
  • 31
9
votes
2 answers

Yesod sample projects

I am planning to write a yesod web application. And I'm wondering whether there are some large project using yesod that is well designed that I could look at and experiment with. I am looking for open source projects. I can learn from.
Attilah
  • 17,632
  • 38
  • 139
  • 202
9
votes
1 answer

Persistent: CRUD TypeClass

I am trying to write a typeclass that simplifies writing a CRUD backend using persistent, aeson and scotty Here is my idea: runDB x = liftIO $ do info <- mysqlInfo runResourceT $ SQL.withMySQLConn info $ SQL.runSqlConn x class…
agrafix
  • 765
  • 1
  • 5
  • 15
9
votes
1 answer

Haskell / Persistent-Sqlite: "No instance for (Control.Monad.Trans.Resource.MonadResource IO)"

I've been trying to come up with a simple and intuitive way to use databases with Haskell. I've taken this code from the Yesod book and tried to clean it up so that it can be easier to understand and use. {-# LANGUAGE QuasiQuotes, TemplateHaskell,…
subtlearray
  • 1,251
  • 1
  • 11
  • 23
9
votes
2 answers

Compile error when trying some Yesod examples

I am trying Yesod book examples documented on Yesod webpage. One of the examples is for Chat application embedded in Wiki. When I try it in ghci (loading Chat module from Wiki.hs which contains Wiki example code), I get the error below for…
Sal
  • 4,312
  • 1
  • 17
  • 26
9
votes
1 answer

Returning an error status in Haskell and Yesod

I am a Haskell newbie. I am trying to write a small Webdav server using the Yesod Framework and modelled after the WebdavServlet in the Apache Tomcat 7 source code. I have run into a problem returning an error from one of my functions. My webdav…
Ralph
  • 31,584
  • 38
  • 145
  • 282
9
votes
2 answers

Yesod delete cascade

According to http://www.yesodweb.com/blog/2010/07/database-migrations a DeleteCascade typeclass was added a few years ago. I can only assume that this is meant to be added to the models. After setting up my models config like this: Field ... …
abesto
  • 2,331
  • 16
  • 28
8
votes
1 answer

How to upload a file to the server using Yesod

I'm trying to write a form that allows users to upload a file to my server. I saw Yesod uses fileAFormReq for such a functionality but was unable to get it to work, running into compilation errors, the latest of which was: "No instance for…
Uri Barenholz
  • 693
  • 3
  • 13
8
votes
1 answer

Cabal install needs C library: Windows

I am trying to cabal install yesod on my Windows machine. I have a relatively fresh install of the Haskell Platform. The cabal install failed, reporting that I need the sqlite3 C library in order to install "persistent", a package which Yesod relies…
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
8
votes
0 answers

Yesod.Auth - how to require second-factor authentication?

I'm currently building a personal website in Yesod 1.4.5, and at the moment I'm implementing authentication. Authenticating with a username and password was easy enough - I used Yesod.Auth.HashDB - but as I'm quite security-conscious I'd like to…
8
votes
1 answer

How to use yesod per-request caching?

I'm trying to use the cached function to prevent multiple db queries in different widgets and handlers: newtype CachedBobId key = CachedBobId { unCachedBobId :: key } deriving Typeable getBob' :: Handler BobId getBob' = do uncle <-…
user2936306
  • 236
  • 2
  • 8
8
votes
1 answer

X {..} <- getYesod notation

I'm seeing this kind of notation all over sample code for Yesod web applications and have no idea what it means: getHomeR :: Handler Html getHomeR = do App {..} <- getYesod What does this syntax mean? I'm also seeing the following, I assume…
Richard Cook
  • 32,523
  • 5
  • 46
  • 71