yesod

How to perform database queries in GHCi in Yesod Application

♀尐吖头ヾ 提交于 2019-11-30 14:12:32
How to, for example, insert a new User into a database using Yesod application's models? Or is there a better way? I am dealing with scaffolded application. Now I created App instance and dont know how to perform requests using it. :i Extra data Extra = Extra {extraCopyright :: Data.Text.Internal.Text, extraAnalytics :: Maybe Data.Text.Internal.Text} -- Defined in `Settings let e = Extra "asdf" Nothing let c = AppConfig {appEnv = Development, appPort = 3000, appRoot = "/", appHost = "localhost", appExtra = e} f <- makeFoundation c :t f f :: App :i App data App = App {settings :: AppConfig

cabal install … failing - osx - many unsatisfied packages

∥☆過路亽.° 提交于 2019-11-30 08:52:53
Update: Running ghc-pkg check reported: ~: ghc-pkg check WARNING: cache is out of date: /Library/Frameworks/GHC.framework/Versions/7.0.3i386/usr/lib/ghc-7.0.3/package.conf.d/package.cache use 'ghc-pkg recache' to fix. ~: ghc-pkg recache and after that cabal seemed a lot happier! Trying to install yesod but the first install failure is: Building attoparsec-0.9.1.1... Building library... Creating dist/build (and its parents) /usr/bin/ghc --make -package-name attoparsec-0.9.1.1 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build

Allowing cross-origin requests in Yesod

别来无恙 提交于 2019-11-30 05:07:53
My application uses a bookmarklet, and I need to allow CORS for MyRouteR so my bookmarklet code can use this route for AJAX requests. In my first draft of config/routes I gave MyRouteR support for only one request method, PUT. But it turned out (duh) that I'd need to support the OPTIONS method as well, which browsers use for CORS preflight requests. I ended up with the following in config/routes: /myroute MyRouteR PUT OPTIONS I was kind of hoping there would be some relevant machinery in the Template Haskell that processes config/routes so that the addition of OPTIONS to this route's method

cabal install … failing - osx - many unsatisfied packages

十年热恋 提交于 2019-11-29 12:03:55
问题 Update: Running ghc-pkg check reported: ~: ghc-pkg check WARNING: cache is out of date: /Library/Frameworks/GHC.framework/Versions/7.0.3i386/usr/lib/ghc-7.0.3/package.conf.d/package.cache use 'ghc-pkg recache' to fix. ~: ghc-pkg recache and after that cabal seemed a lot happier! Trying to install yesod but the first install failure is: Building attoparsec-0.9.1.1... Building library... Creating dist/build (and its parents) /usr/bin/ghc --make -package-name attoparsec-0.9.1.1 -hide-all

Yesod: Getting a database entity by ID from an Int

非 Y 不嫁゛ 提交于 2019-11-28 20:07:37
I'm new to both Haskell and Yesod, and am trying to build a simple web application that can answer queries from an external API. I have built a parser (using Parsec), that gets me the ID of an entity I want to load as a regular Int value. However, I for the life of me can't figure out how to turn this Int into something that get will accept (i. e. a Key (?)). All the examples in the documentation only get the id from previous inserts, or from url dispatch. Any help would be greatly appreciated, since I seem to be stuck... :) Even if the answer can already be found in the comments, I would like

Yesod: Getting a database entity by ID from an Int

会有一股神秘感。 提交于 2019-11-27 12:43:49
问题 I'm new to both Haskell and Yesod, and am trying to build a simple web application that can answer queries from an external API. I have built a parser (using Parsec), that gets me the ID of an entity I want to load as a regular Int value. However, I for the life of me can't figure out how to turn this Int into something that get will accept (i. e. a Key (?)). All the examples in the documentation only get the id from previous inserts, or from url dispatch. Any help would be greatly

Comparing Haskell's Snap and Yesod web frameworks

被刻印的时光 ゝ 提交于 2019-11-27 09:56:57
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? mightybyte Full disclosure: I'm one of the lead developers of Snap. First of all, let's talk about what Snap is. Right now the Snap team maintains five different projects on hackage