yesod

How to use a CSS Framework with Yesod?

邮差的信 提交于 2019-12-10 17:11:45
问题 I want to use the Blueprint CSS Framework with Yesod. Are there any best practices? Because Yesod uses templates for CSS, it looks to me that I cannot use the .css-files directly? Do I have to rename them to .lucius-files? How do I add the CSS to the defaultLayout? 回答1: One approach would be to rename them to .lucius files, which should work perfectly. (If it doesn't, it's a bug in Lucius and you should report it.) But you could also store the CSS in the static folder and reference it with an

Yesod persistent type error

99封情书 提交于 2019-12-10 16:45:48
问题 I am trying out persistent in a Yesod application. My model file contains Job issuer MemberId addDate UTCTime lastDate UTCTime title Text description Text deriving Show Read And my Handler: getProfileR :: Handler RepHtml getProfileR = do jobs <- runDB $ selectList [] [Desc JobAddDate] defaultLayout $ do setTitle "title" $(widgetFile "profile") In profile.hamlet I loop trough the objects $forall Job issuer addDate lastDate title description <- jobs <p>#{issuer} However, I get the following

Yesod redirect to anchor on page

谁都会走 提交于 2019-12-10 14:47:12
问题 Is it possible to redirect to example.com/page#anchor using redirect and Yesod's routing system? If so, how? 回答1: You can use getUrlRender to get the URL renderer, and then append #anchor to that. For example: render <- getUrlRender redirect $ render myRoute <> "#anchor" It might be worth adding a convenience function to automate this process. 来源: https://stackoverflow.com/questions/20886254/yesod-redirect-to-anchor-on-page

Run Keter without GHC and cabal

我是研究僧i 提交于 2019-12-10 10:53:30
问题 I have a server and want to deploy my Yesod applications without installing GHC and Cabal. I am not sure if is possible: a Teacher told me that I must first compile Keter in my machine and, after that, put keter executable on the server, though I am not sure how to do that. 回答1: To build Keter, first you'll need to clone the sources from its GitHub repository. Then you'll need to set up a Haskell build environment and use cabal build or cabal install to build the sources. Personally, I use a

Getting “Could not find module `Yesod'” when I try to run first example from Yesod book

隐身守侯 提交于 2019-12-10 10:46:40
问题 I know this seems a duplicate to Could not find module `Yesod', but unlike that user, ghc-pkg list does not show Yesod in its output on my computer, they didn't seem to be using stack (I am, and I'm not sure if that means I don't need to worry about ghc-pkg list ), and additionally, the answer (code) to that question did not help my situation. The Yesod Book has an example that I've been trying to get to work for several hours now. I'll reprint it here {-# LANGUAGE OverloadedStrings #-} {-#

How can I include an hamletfile inside another using widgetFile?

。_饼干妹妹 提交于 2019-12-10 09:27:45
问题 For reusability, I want to re-use a widget inside another. For instance, the widget file blogpost.hamlet could contain how a post is displayed, and blog.hamlet could contain the full blog. The following content of blog.hamlet does not work: $forall post <- posts ^{widgetFile "blogpost") So, what is the correct syntax to embed one widget inside another? 回答1: The Hamlet syntax does not support embedding Template Haskell splices inside of it, which makes the code you're looking to do impossible.

How to work around duplicate symbol error when using Yesod and Darcs library?

血红的双手。 提交于 2019-12-10 03:39:58
问题 It seems impossible to use Yesod together with the Darcs library due to a linker problem. I tracked down the problem and need hints to work around it by people familiar with Darcs internals. When using the darcs library in a Yesod application, I get the following error: GHCi runtime linker: fatal error: I found a duplicate definition for symbol sha256_init whilst processing object file /home/sebfisch/.cabal/lib/darcs-2.9.5/ghc-7.4.2/libHSdarcs-2.9.5.a This could be caused by: * Loading two

Validation spanning multiple fields

旧城冷巷雨未停 提交于 2019-12-08 19:17:54
问题 I'm trying to grok applicative forms, and I've been wondering how to implement a form that validates fields that depend on other fields. For example a registration form which has password and confirm_password fields and I'd like to validate that password == confirm_password . I could be done after the form has ran, in the handler, but that would mean losing error messages. Edit: Forgot to mention, I'm mainly using Yesods applicative forms, but they seem to be quite close to digestive-functors

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

佐手、 提交于 2019-12-08 16:51:47
问题 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, TypeFamilies, OverloadedStrings #-} {-# LANGUAGE GADTs, FlexibleContexts #-} import Database.Persist import Database.Persist.Sqlite (withSqliteConn, runSqlConn, runMigration) import Database.Persist.TH (share, mkPersist, mkMigrate, sqlSettings,

Example of persistent with backend-specific operator

笑着哭i 提交于 2019-12-08 16:31:16
问题 I would like to do a LIKE query in persistent, I'm using sqlite. The yesod book gives an example of using raw SQL to do it, but says: you can express a LIKE operator directly in the normal syntax due to a feature added in Persistent 0.6, which allows backend-specific operators I couldn't find an example of that, though. Would somebody have an example of what it would mean to use a specific operator like LIKE with selectList or something equivalent? Thanks! 回答1: I know I've used it before, but