yesod

MongoDB Example for Yesod / Persistent

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 14:39:43
问题 Haskell and Yesod newbie here. I've been trying to follow the Integration with Yesod example from the Persistent chapter in the Yesod book (http://www.yesodweb.com/book/persistent). The Sqlite compiles and runs fine it seems. However, I'm trying to use MongDB and am having a hard time getting things to work. Specifically: In the example for sqlite: share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persist| The Yesod book says "Mongo code will use mongoSettings instead." But I can't find

Yesod form with multiple buttons

ε祈祈猫儿з 提交于 2019-12-05 13:20:26
I have a Yesod form for editing the contents of some static pages which are written using markdown (processed using Pandoc). I want to have two buttons - a 'preview' button which processes the markup and displays the result underneath the form, and a 'submit' button which saves the contents to the database. What is the simplest way to do this with Yesod? All the form examples in the Yesod book have exactly one button. I've looked at the exposed functions / api, but I even if I add more than one submit button with different names and/or values to the form I can't figure out how to get Yesod to

Yesod devel server only listening on ipv6

我只是一个虾纸丫 提交于 2019-12-05 12:43:14
I'm running "cabal install && yesod devel" using yesod 0.9.2.2 but it is only listening using ipv6. Does anyone know how to configure it to listen on ipv4 as well? I'm running it on Windows 7. Thanks The symptom you describe have so far been observed on BSD and Debian, but it looks like Windows is also affected. It is a known problem with Yesod, or actually with Wasp, or, to be precise, with the network library. One place to follow up on this issue is this githup issue or the current discussion on haskell-lists , which was partly caused by your question. While I don't currently have a similar

Yesod auth: redirecting user to registration page

北慕城南 提交于 2019-12-05 12:36:50
I'm playing with scaffolded site and i want to send user to the registration page after he logged in for the first time with OpenID or Google Account. I've came up with this: getAuthId creds = runDB $ do x ← getBy $ UniqueUser $ credsIdent creds case x of Just (Entity uid _) → return $ Just uid Nothing → do return $ Just $ Key (PersistInt64 0) And in HomeR handler i check for UserId value, showing registration form in case of zero. This approach works, but seems hackish. What is the proper way to deal with such problem? I would recommend splitting the information up into two entities: a User

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

牧云@^-^@ 提交于 2019-12-05 06:42:10
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. Michael Snoyman 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 recommend sticking to the http-types package. One place to start would be urlEncode , though there

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

回眸只為那壹抹淺笑 提交于 2019-12-05 04:46:02
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 different object files which export the same symbol * Specifying the same object file twice on the GHCi

Websockets in Yesod?

别等时光非礼了梦想. 提交于 2019-12-05 01:39:38
I would like to create a website using Yesod and websockets (html5). Can I use websockets with Yesod webframework? Yes, as Thomas M. DuBuisson pointed out in the comments: a WebSocket handler is implemented in WAI which is the interface Yesod is using to communicate with it's backends. I can't comment on how well it works in it's current form, but you can download and try it from Hackage . 来源: https://stackoverflow.com/questions/10963175/websockets-in-yesod

Cabal install needs C library: Windows

人盡茶涼 提交于 2019-12-04 19:56:37
问题 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 upon. cabal: Missing dependency on a foreign library: * Missing C library: sqlite3 So I went to http://www.sqlite.org/download.html and grabbed both the C source and the precompiled binary. I tried using both, to no avail: cabal install persistent

Store existing data-type with Yesod's Persistent

ε祈祈猫儿з 提交于 2019-12-04 19:32:54
问题 All the tutorials and references that I could find about Persistent describe in great detail how Persistent can automatically create a new data-type, schema, migration, etc. out of a single definition in its DSL. However, I couldn't find an explanation on how to get Persistent to handle already existing data-types. An example: Suppose I have an already existing Haskell module for some game logic. It includes a record type for a player. (It's meant to be used through lenses, hence the

Foreign key constraints in Yesod/Persistent?

爷,独闯天下 提交于 2019-12-04 12:57:08
I am trying to use Database.Persistant to make a database for a Scotty app, and I cannot figure out the syntax for adding a foreign key constraint between tables. For example, I have a User table and a Post table, and I want the Post table to have an attribute authorId which references UserId in User . This can be accomplished quite easily in raw SQL, but I want to be able to access the data through haskell without resorting to raw sql commands. Also, the constraints would be overwritting upon database migrations. This is what I have at the moment to define the database: share [mkPersist