yesod

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

In the Yesod ecosystem, what is the best way to urlencode some Text?

孤者浪人 提交于 2019-12-22 05:48:56
问题 I'd like to url-encode some Text (e.g., replace each space with a %20, etc.). I found "HTTP" Network.HTTP.Base.urlEncode and could use that, but I'm wondering if there's something else that's normally used in the Yesod ecosystem. 回答1: Unfortunately, due to the complexity of URL escaping, the real answer is "it depends." There are slightly different rules for the percent encoding of path segments and query strings, for example. I don't know exactly what you're trying to encode, but I'd

In the Yesod ecosystem, what is the best way to urlencode some Text?

你离开我真会死。 提交于 2019-12-22 05:47:45
问题 I'd like to url-encode some Text (e.g., replace each space with a %20, etc.). I found "HTTP" Network.HTTP.Base.urlEncode and could use that, but I'm wondering if there's something else that's normally used in the Yesod ecosystem. 回答1: Unfortunately, due to the complexity of URL escaping, the real answer is "it depends." There are slightly different rules for the percent encoding of path segments and query strings, for example. I don't know exactly what you're trying to encode, but I'd

Link to a static file from Hamlet

放肆的年华 提交于 2019-12-22 03:58:08
问题 I'm currently experimenting with Yesod by following the tutorial on the Yesod Wiki. First I created a yesod application using yesod init , and created a Root handler that renders a widget file called homepage : getRootR = do mu <- maybeAuth defaultLayout $ do h2id <- lift newIdent setTitle "Home" addWidget $(widgetFile "homepage") I have an image file in the static directory call static/img/logo.png After touching Settings/staticFiles.hs , I successfully managed to link this file from default

Deep maybe stack with yesod

ε祈祈猫儿з 提交于 2019-12-21 13:03:08
问题 I'm trying to set an authorization scheme where I check that 1. user is logged in 2. user has access to a certain object. For this I first call maybeAuthId , then try to get the current object, and 'join' to another table which lists permissions. There are two levels of maybe-cases and one level of empty-list case. I thought of using MaybeT, but either I'm too tired to get it to work or the "not really monad transformer"-handler-transformers can't be used with MaybeT. Is there a nice way to

use cabal2nix to create local nix environment for packages that aren't in nixpkgs

时间秒杀一切 提交于 2019-12-21 05:40:37
问题 I currently have a Yesod web application that I am developing on NixOS. I am using a default.nix file like described in O'Charles' blog post: { haskellPackages ? (import <nixpkgs> {}).haskellPackages }: haskellPackages.cabal.mkDerivation (self: { pname = "myblog"; version = "0.0.0"; src = ./.; isLibrary = true; isExecutable = true; buildDepends = with haskellPackages; [ aeson bson conduit dataDefault fastLogger hjsmin httpConduit monadControl monadLogger mongoDB persistent #persistentMongoDB

Correct way to do a “join” in persist with yesod

社会主义新天地 提交于 2019-12-21 01:07:54
问题 Consider the models: Player name Text nick Text email Text Maybe phone Text Maybe note Textarea Maybe minutes Int Maybe deriving Table name Text game Text pointsHour Int seats Int Maybe description Text Maybe deriving GamingSession start UTCTime end UTCTime Maybe player PlayerId table TableId seat Int Maybe deriving and the function getGamingSessionsR :: Handler RepHtml getGamingSessionsR = do sessions <- runDB $ selectList [GamingSessionEnd ==. Nothing] [Desc GamingSessionTable]

Yesod's shakespearean templates (hamlet) and IO

痞子三分冷 提交于 2019-12-20 02:28:32
问题 In Hamlet, how does one uses the result of an IO operation inside #{...} ? For instance : someIO :: IO String ----------------- $with stuff <- someIO <p>#{stuff} Fails with No instance for (blaze-markup-0.6.0.0:Text.Blaze.ToMarkup (IO String)) arising from a use of `toHtml' I fear that I have not approached the problem from the right angle, could someone shed some light on this issue for me? Thank you 回答1: Hamlet is just providing an alternate syntax for normal Haskell code, so like normal

YesodAuthEmail could not deduce m ~ HandlerFor site0 [duplicate]

我的梦境 提交于 2019-12-19 09:49:34
问题 This question already has an answer here : What's wrong with this YesodAuth instance? (1 answer) Closed last year . I'm trying to add instance YesodAuthEmail App to the Yesod-Postgres scaffolding (yesod version 1.6) and getting stuck on a compile error. The relevant code is: instance YesodAuth App where type AuthId App = UserId .... authPlugins :: App -> [AuthPlugin App] authPlugins app = [authOpenId Claimed []] ++ extraAuthPlugins where extraAuthPlugins = [ authEmail ] instance

Using UTCTime with Hamlet

空扰寡人 提交于 2019-12-19 08:49:10
问题 I am using Yesod on my first site and I have a list of news items: NewsItem date UTCTime default=CURRENT_TIME title String content String author String which are retrieved in my handler: newsitems <- runDB $ selectList [] [Desc NewsItemDate] and ultimately used in my template: $if null newsitems <p>No news. $else $forall Entity id entry <- newsitems <article> <h4>#{newsItemDate entry} <p>#{newsItemContent entry} But I get an error about datatypes: Handler/Home.hs:20:11: No instance for (Text