Joey Eremondi
Joey Eremondi

Reputation: 8423

PersistMap in Yesod?

I'm using Yesod to design a website, and I'd like to use the PersistMap data type to map entries to text names. However, I can't seem to find any examples of how to declare a PersistMap field in the config/models file.

When I try

entryName [Text] Map

it seems to just make a [Text] variable, but when I do

entryName (Text, Text) Map

or

entryName [(Text, Text)] Map

I get a syntax error.

How can I declare a PersistMap entry in my config/models file?

Upvotes: 0

Views: 128

Answers (1)

Michael Snoyman
Michael Snoyman

Reputation: 31315

In your Haskell code, you can declare a type synonym, e.g.:

type TextPairs = [(Text, Text)]

Then use that synonym in your model definition.

Upvotes: 4

Related Questions