yesod

Comparing Haskell's Snap and Yesod web frameworks

孤街醉人 提交于 2019-12-28 03:15:09
问题 The two Haskell web frameworks in the news recently are Yesod (at 0.8) and Snap (at 0.4). It's quite obvious that Yesod currently supports a lot more features than Snap. However, I can't stand the syntax Yesod uses for its HTML, CSS and Javascript. So, I'd like to understand what I'd be missing if I went with Snap instead. For example, doesn't look like database support is there. How about sessions? Other features? 回答1: Full disclosure: I'm one of the lead developers of Snap. First of all,

Running join on Maybe Relation

浪尽此生 提交于 2019-12-24 12:27:00
问题 I have a model Assignment blah Text .... and a model File assignmentId AssignmentId Maybe ... and I want to get all the files associated with an assignment in a join query. I have tried Esqueleto and runJoin with selectOneMany but haven't had any luck, so I am considering not using a join, or using rawSql. That really doesn't seem like a good idea, but I can't figure this out. Is there any support for that feature? 回答1: Update, working example: {-# LANGUAGE PackageImports, OverloadedStrings,

How to get a TypeSafe URL to a static resource in Yesod

大憨熊 提交于 2019-12-24 04:34:05
问题 I was wondering if someone could tell me how I get a TypeSafe URL to a static resource. I've got "/static" as a subsite serving files, but I'm unclear on how to refer to specific files from there using typesafe URLs. The idea is that I could include them in things like addScript and such. I am very new to Yesod, but I couldn't find an example like this in either the Yesod book or in the FPComplete tutorials. 回答1: Something like this: src=@{StaticR img_myimage_png} Yesod looks inside the

Using Licius + Hamlet + Julius in Servant

邮差的信 提交于 2019-12-24 01:19:12
问题 I would like to use Shakespearean Templates (Licius + Hamlet + Julius) from the Yesod.But I have some difficulty with this. The following code from enter link description here works: type TestAPI = "tests" :> Get '[JSON] [Test] :<|> "test" :> Get '[JSON] Test :<|> "TestHTML.html" :> Get '[HTML] Page_TestHTML serverTestAPI :: ServerT TestAPI AppM serverTestAPI = tests :<|> test :<|> testHtml data Page_TestHTML = Page_TestHTML instance ToMarkup Page_TestHTML where toMarkup Page_TestHTML =

Dynamically-Sized List of Fields in Yesod

Deadly 提交于 2019-12-23 20:28:06
问题 In HTML, multiple fields can be specified with a non-unique name like so: <input type="checkbox" name="breakfast" value="eggs"> <input type="checkbox" name="breakfast" value="bacon"> so that, when submitted, query parameters get passed like (if both boxes are ticked) breakfast=eggs&breakfast=bacon . The CGI specification states that this should be interpreted as an array or list of values, and this technique is also useful for dynamically-sized lists of inputs: <input type="text" name="url">

Haskell: Yesod and state

蹲街弑〆低调 提交于 2019-12-23 16:07:17
问题 I was reading through the code for a Toy URL Shortener. However, there's significant parts I just can't get my head around. It has the following code: data URLShort = URLShort { state :: AcidState URLStore } For testing purposes, I wrote something like this in my own app: data MyApp = MyApp { state :: Int } I could then compile by changing main = warpDebug 3000 MyApp to main = warpDebug 3000 (MyApp 42) And I could then do reads of the state in handlers by doing mystate <- fmap state getYesod

Yesod logInfo no output

吃可爱长大的小学妹 提交于 2019-12-23 12:34:07
问题 I am not getting any output from $logInfo in Yesod. I have a scaffolded site and when I run yesod devel , I see no output from the log lines I put in my application. I also tried building the application (with cabal) and running from the command line, but still, no output. I was under the impression that in development mode, all log levels are output. What am I doing wrong? UPDATE I built a "fresh" application using the latest version of Yesod (downloaded with cabal just now). I modified

Yesod ExitFailure 1 when installing scaffolded app

夙愿已清 提交于 2019-12-23 07:49:15
问题 I'm trying to install my first scaffolded Yesod app. When I run cabal-dev install && yesod --dev devel it fails with ExitFailure 1. I'm using sqlite for persistent. Application.hs:49:44: No instance for (monad-logger-0.3.1:Control.Monad.Logger.MonadLogger IO) arising from a use of `runMigration' Possible fix: add an instance declaration for (monad-logger-0.3.1:Control.Monad.Logger.MonadLogger IO) In the second argument of `Database.Persist.Store.runPool', namely `(runMigration migrateAll)' In

Using Servant with Yesod shakespeare (Hamlet, Julius, Lucius)

雨燕双飞 提交于 2019-12-23 03:30:52
问题 How i can use shakespeare (from yesod) for servant webservices APIs? I try: type TestAPI = "tests" :> Get '[JSON] [Test] :<|> "Test.html" :> Get '[HTML] Html serverTestAPI :: ServerT TestAPI AppM serverTestAPI = tests :<|> test :<|> testHtml tests :: AppM [Test] tests = do return [ Test 1 "Test 1" , Test 2 "Test 2" ] testHtml = [hamlet| $doctype 5 ......... |] But I get error! 回答1: As @Carsten points out, in this case what you want is shamlet . The key thing is implementing proper instances

Snap web framework and OSX Path

邮差的信 提交于 2019-12-23 02:02:38
问题 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